- Dockerfile builds the npm bundle and serves the app with gunicorn - Gitea workflow runs tests, tags releases on main, pushes the image to the Gitea registry, and publishes to PyPI when PYPI_TOKEN is set - MANIFEST.in includes the built static bundle in distributions - License the project under BSD-3-Clause Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
1.4 KiB
Docker
51 lines
1.4 KiB
Docker
FROM node:24 AS nodebuild
|
|
|
|
WORKDIR /build
|
|
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci
|
|
|
|
COPY webpack.config.js ./
|
|
COPY src ./src
|
|
COPY privatestudio ./privatestudio
|
|
RUN mkdir -p privatestudio/static/bundle && npm run build
|
|
|
|
|
|
FROM python:3.13-slim-trixie
|
|
|
|
# Version used by setuptools_scm, since .git is not copied into the image.
|
|
ARG VERSION=0.0.0
|
|
|
|
RUN useradd --create-home privatestudio
|
|
|
|
EXPOSE 8000
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PORT=8000 \
|
|
DJANGO_SETTINGS_MODULE=privatestudio.settings.production \
|
|
STORAGE_PATH=/data/storage
|
|
|
|
RUN pip install --no-cache-dir "gunicorn~=23.0" "psycopg2-binary~=2.9.11"
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --chown=privatestudio:privatestudio . .
|
|
COPY --from=nodebuild --chown=privatestudio:privatestudio /build/privatestudio/static/bundle ./privatestudio/static/bundle
|
|
|
|
RUN SETUPTOOLS_SCM_PRETEND_VERSION="${VERSION}" pip install --no-cache-dir . \
|
|
&& mkdir -p /data/storage && chown -R privatestudio:privatestudio /data /app
|
|
|
|
USER privatestudio
|
|
|
|
RUN python manage.py collectstatic --noinput --clear
|
|
|
|
VOLUME ["/data"]
|
|
|
|
# Migrating at startup keeps "docker run" simple. Use a release step instead if
|
|
# you run more than one container against the same database.
|
|
CMD set -xe; \
|
|
python manage.py migrate --noinput; \
|
|
exec gunicorn privatestudio.wsgi:application \
|
|
--bind 0.0.0.0:${PORT} \
|
|
-k gthread --workers 2 --threads 8 --timeout 600
|