From 0b979cfadaf2991a6a370818d37d85dbc4eb351a Mon Sep 17 00:00:00 2001 From: Markus Rosenstihl Date: Tue, 14 Apr 2026 08:40:14 +0200 Subject: [PATCH] Initial container build --- Dockerfile | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 3 +++ 2 files changed, 64 insertions(+) create mode 100644 Dockerfile create mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..871253b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,61 @@ +# 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 + +## 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 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 + +# Run Django’s development server +CMD ["python", "manage.py", "migrate"] +CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..14324ca --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +asgiref==3.8.1 +Django==5.1.6 +sqlparse==0.5.3