Skip to content

Commit 24e24f1

Browse files
committed
Fix some lint issues, expose ports, and add a healthcheck
Signed-off-by: Taylor Smock <[email protected]>
1 parent 11610c2 commit 24e24f1

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

.dockerignore

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@
66
**/node_modules
77
**/npm-debug.log
88
**/venv
9+
**/.venv
910
docs-old/
1011
docs/
11-
frontend/
1212
logs/
13+
14+
# Generated frontend #
15+
frontend/node_modules/
16+
frontend/build/
17+
frontend/public/static/
18+
frontend/assets/styles/
19+
frontend/package-lock.json
20+
frontend/.env
21+
frontend/.eslintcache
22+
frontend/coverage/
23+

Dockerfile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ RUN pip install --no-cache-dir --upgrade pip
3535
WORKDIR /opt/python
3636
# Setup backend build-time dependencies
3737
RUN 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/
4747
USER appuser:appuser
4848
RUN 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
7171
USER appuser:appuser
@@ -80,17 +80,25 @@ COPY manage.py .
8080
FROM runtime as debug
8181
RUN pip install --user --no-warn-script-location \
8282
--no-cache-dir debugpy==1.6.7
83+
EXPOSE 5678/tcp
8384
CMD ["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

8990
FROM runtime as prod
90-
# Pre-compile packages to .pyc (init speed gains)
9191
USER 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)
9298
RUN python -c "import compileall; compileall.compile_path(maxlevels=10, quiet=1)"
93-
USER appuser:appuser
9499
RUN 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
95103
CMD ["gunicorn", "-c", "python:backend.gunicorn", "manage:application", \
96104
"--workers", "1", "--log-level", "error"]

scripts/docker/Dockerfile.backend

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ RUN pip install --no-cache-dir --upgrade pip
3535
WORKDIR /opt/python
3636
# Setup backend build-time dependencies
3737
RUN 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/
4747
USER appuser:appuser
4848
RUN 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
7171
USER appuser:appuser
@@ -90,7 +90,7 @@ FROM runtime as prod
9090
# Pre-compile packages to .pyc (init speed gains)
9191
USER root
9292
RUN python -c "import compileall; compileall.compile_path(maxlevels=10, quiet=1)"
93-
USER appuser:appuser
9493
RUN python -m compileall .
94+
USER appuser:appuser
9595
CMD ["gunicorn", "-c", "python:backend.gunicorn", "manage:application", \
9696
"--workers", "1", "--log-level", "error"]

0 commit comments

Comments
 (0)