Files
isotopetable/isotables/Dockerfile

64 lines
1.9 KiB
Docker

# 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 development server
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]