Dockerfile 1009 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. FROM python:3.12 AS build-python
  2. ARG IS_CI
  3. ENV PYTHONUNBUFFERED=1 \
  4. PORT=8080 \
  5. UV_COMPILE_BYTECODE=1 \
  6. UV_SYSTEM_PYTHON=true \
  7. UV_PYTHON_DOWNLOADS=never \
  8. PIP_DISABLE_PIP_VERSION_CHECK=on
  9. WORKDIR /code
  10. COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
  11. COPY pyproject.toml uv.lock /code/
  12. RUN uv sync --frozen --no-install-project $(test "$IS_CI" = "True" && echo "--no-dev")
  13. FROM python:3.12-slim
  14. ARG GLITCHTIP_VERSION=local
  15. ENV GLITCHTIP_VERSION ${GLITCHTIP_VERSION}
  16. ENV PYTHONUNBUFFERED=1 \
  17. VIRTUAL_ENV=/code/.venv \
  18. PATH="/app/.venv/bin:$PATH" \
  19. PORT=8080
  20. RUN apt-get update && apt-get install -y libxml2 libpq5 && apt-get clean && rm -rf /var/lib/apt/lists/*
  21. WORKDIR /code
  22. COPY --from=build-python /code/.venv /code/.venv
  23. EXPOSE 8080
  24. COPY . /code/
  25. ARG COLLECT_STATIC
  26. RUN if [ "$COLLECT_STATIC" != "" ] ; then SECRET_KEY=ci ./manage.py collectstatic --noinput; fi
  27. RUN useradd -u 5000 app && chown app:app /code && chown app:app /code/uploads
  28. USER app:app
  29. CMD ["./bin/start.sh"]