@@ -35,14 +35,14 @@ RUN pip install --no-cache-dir --upgrade pip
3535WORKDIR /opt/python
3636# Setup backend build-time dependencies
3737RUN apt-get update
38- RUN apt-get install -y build-essential
39- RUN apt-get install -y \
38+ RUN apt-get install --no-install-recommends - y build-essential
39+ RUN apt-get install --no-install-recommends - y \
4040 postgresql-server-dev-15 \
4141 python3-dev \
4242 libffi-dev \
4343 libgeos-dev
4444# Setup backend Python dependencies
45- COPY --chown=appuser:appuser -- from=extract-deps \
45+ COPY --from=extract-deps \
4646 /opt/python/requirements.txt /opt/python/
4747USER appuser:appuser
4848RUN pip install --user --no-warn-script-location \
@@ -65,7 +65,7 @@ RUN apt-get update && \
6565 apt-get install --no-install-recommends -y \
6666 postgresql-client libgeos3.11.1 proj-bin && \
6767 apt-get clean && rm -rf /var/lib/apt/lists/*
68- COPY --chown=appuser:appuser -- from=build \
68+ COPY --from=build \
6969 /home/appuser/.local \
7070 /home/appuser/.local
7171USER appuser:appuser
@@ -80,17 +80,25 @@ COPY manage.py .
8080FROM runtime as debug
8181RUN pip install --user --no-warn-script-location \
8282 --no-cache-dir debugpy==1.6.7
83+ EXPOSE 5678/tcp
8384CMD ["python" , "-m" , "debugpy" , "--wait-for-client" , "--listen" , "0.0.0.0:5678" , \
8485 "-m" , "gunicorn" , "-c" , "python:backend.gunicorn" , "manage:application" , \
8586 "--reload" , "--log-level" , "error" ]
8687
8788
8889
8990FROM runtime as prod
90- # Pre-compile packages to .pyc (init speed gains)
9191USER root
92+ # Get the necessary bits for the health check
93+ RUN apt-get update && \
94+ apt-get install -y curl && \
95+ apt-get clean && \
96+ rm -rf /var/lib/apt/lists/*
97+ # Pre-compile packages to .pyc (init speed gains)
9298RUN python -c "import compileall; compileall.compile_path(maxlevels=10, quiet=1)"
93- USER appuser:appuser
9499RUN python -m compileall .
100+ EXPOSE 8000/tcp
101+ HEALTHCHECK --interval=60s --start-period=15s CMD ["curl" , "-f" , "http://localhost:8000/api/v2/system/heartbeat/" , "||" , "exit" , "1" ]
102+ USER appuser:appuser
95103CMD ["gunicorn" , "-c" , "python:backend.gunicorn" , "manage:application" , \
96104 "--workers" , "1" , "--log-level" , "error" ]
0 commit comments