added Dockerfile
This commit is contained in:
parent
9ea24e3bb5
commit
1a10e6d778
12
README.md
Normal file
12
README.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Installation/Development via pip
|
||||||
|
1. create virtual environment: `python3 -m venv venv`
|
||||||
|
2. activate it: `. venv/bin/activate`
|
||||||
|
3. install Django: `pip install -r requirements.txt`
|
||||||
|
4. Initialize DB: `python3 manage.py migrate`
|
||||||
|
5. Run Django project: `python3 manage.py runserver`
|
||||||
|
|
||||||
|
# Docker/Podman
|
||||||
|
podman build -t isotables isotables
|
||||||
|
podman run -p 8000:8000 localhost/isotable:latest
|
||||||
|
|
||||||
|
|
63
isotables/Dockerfile
Normal file
63
isotables/Dockerfile
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# Use the official Python runtime image
|
||||||
|
FROM python:3.13-alpine
|
||||||
|
|
||||||
|
# Create the app directory
|
||||||
|
RUN mkdir /app
|
||||||
|
|
||||||
|
# Set the working directory inside the container
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Create a non-privileged user that the app will run under.
|
||||||
|
# See https://docs.docker.com/go/dockerfile-user-best-practices/
|
||||||
|
ARG UID=10001
|
||||||
|
RUN adduser \
|
||||||
|
--disabled-password \
|
||||||
|
--gecos "" \
|
||||||
|
--home "/nonexistent" \
|
||||||
|
--shell "/sbin/nologin" \
|
||||||
|
--no-create-home \
|
||||||
|
--uid "${UID}" \
|
||||||
|
appuser
|
||||||
|
|
||||||
|
# Set environment variables
|
||||||
|
# Prevents Python from writing pyc files to disk
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
|
# Prevents Python from buffering stdout and stderr
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
# Ignore pip warning about running as root
|
||||||
|
ENV PIP_ROOT_USER_ACTION=ignore
|
||||||
|
|
||||||
|
# Upgrade pip
|
||||||
|
#RUN pip install --upgrade pip
|
||||||
|
|
||||||
|
# Download dependencies as a separate step to take advantage of Docker's caching.
|
||||||
|
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
|
||||||
|
# Leverage a bind mount to requirements.txt to avoid having to copy them into
|
||||||
|
# into this layer.
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||||
|
--mount=type=bind,source=requirements.txt,target=/requirements.txt \
|
||||||
|
python -m pip install -r /requirements.txt
|
||||||
|
|
||||||
|
## Copy the Django project and install dependencies
|
||||||
|
#COPY requirements.txt /app/
|
||||||
|
#
|
||||||
|
## run this command to install all dependencies
|
||||||
|
#RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
##RUN pip install --no-cache-dir django-tailwind
|
||||||
|
|
||||||
|
# Switch to the non-privileged user to run the application.
|
||||||
|
USER appuser
|
||||||
|
|
||||||
|
# allow all hosts
|
||||||
|
ENV DJANGO_ALLOWED_HOSTS=*
|
||||||
|
|
||||||
|
# Copy the Django project files to the container
|
||||||
|
COPY --chown=appuser:appuser isotables/ /app/isotables
|
||||||
|
COPY --chown=appuser:appuser isotopapp/ /app/isotopapp
|
||||||
|
COPY --chown=appuser:appuser manage.py db.sqlite3 /app/
|
||||||
|
|
||||||
|
# Expose the Django port
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
# Run Django’s development server
|
||||||
|
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
|
Loading…
x
Reference in New Issue
Block a user