Files

64 lines
1.6 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Use the official Python runtime image
FROM python:3.13-alpine
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
RUN apk add --no-cache sqlite
# 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 \
--shell "/sbin/nologin" \
--uid "${UID}" \
appuser
# Set environment variables
## Python
# 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
## uv
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1
# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy
# Disable development dependencies
ENV UV_NO_DEV=1
# copy project settings
COPY pyproject.toml uv.lock /app/
# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-install-project
RUN chown appuser:appuser /app
# Copy the Django project files to the container
COPY --chown=appuser:appuser excel_mimic /app/excel_mimic
COPY --chown=appuser:appuser sheets /app/sheets
COPY --chown=appuser:appuser manage.py db.sqlite3 /app/
# Expose the Django port
EXPOSE 8000
# Switch to the non-privileged user to run the application.
USER appuser
# Allow all hosts
ENV DJANGO_ALLOWED_HOSTS=*
# Run Djangos development server
CMD ["uv", "run", "manage.py", "runserver", "0.0.0.0:8000"]