-
-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6554 from spwoodcock/build/cleanup-dockerfiles
Cleanup dockerfiles, remove duplicates, upgrade PDM
- Loading branch information
Showing
6 changed files
with
127 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
ARG DEBIAN_IMG_TAG=slim-bookworm | ||
ARG PYTHON_IMG_TAG=3.10 | ||
|
||
|
||
|
||
FROM docker.io/python:${PYTHON_IMG_TAG}-${DEBIAN_IMG_TAG} as base | ||
ARG APP_VERSION=0.1.0 | ||
ARG DOCKERFILE_VERSION=0.5.0 | ||
ARG ALPINE_IMG_TAG | ||
ARG DEBIAN_IMG_TAG | ||
ARG PYTHON_IMG_TAG | ||
ARG [email protected] | ||
LABEL org.hotosm.tasks.app-version="${APP_VERSION}" \ | ||
|
@@ -25,7 +28,7 @@ FROM base as extract-deps | |
RUN pip install --no-cache-dir --upgrade pip | ||
WORKDIR /opt/python | ||
COPY pyproject.toml pdm.lock README.md /opt/python/ | ||
RUN pip install --no-cache-dir pdm==2.7.4 | ||
RUN pip install --no-cache-dir pdm==2.18.1 | ||
RUN pdm export --prod --without-hashes > requirements.txt | ||
|
||
|
||
|
@@ -34,13 +37,13 @@ FROM base as build | |
RUN pip install --no-cache-dir --upgrade pip | ||
WORKDIR /opt/python | ||
# Setup backend build-time dependencies | ||
RUN apt-get update | ||
RUN apt-get install --no-install-recommends -y build-essential | ||
RUN apt-get install --no-install-recommends -y \ | ||
RUN apt-get update && apt-get install --no-install-recommends -y \ | ||
build-essential \ | ||
libffi-dev \ | ||
libgeos-dev \ | ||
postgresql-server-dev-15 \ | ||
python3-dev \ | ||
libffi-dev \ | ||
libgeos-dev | ||
&& rm -rf /var/lib/apt/lists/* | ||
# Setup backend Python dependencies | ||
COPY --from=extract-deps \ | ||
/opt/python/requirements.txt /opt/python/ | ||
|
@@ -63,8 +66,8 @@ ENV PYTHONDONTWRITEBYTECODE=1 \ | |
# Setup backend runtime dependencies | ||
RUN apt-get update && \ | ||
apt-get install --no-install-recommends -y \ | ||
postgresql-client libgeos3.11.1 proj-bin && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* | ||
libgeos3.11.1 postgresql-client proj-bin && \ | ||
rm -rf /var/lib/apt/lists/* | ||
COPY --from=build \ | ||
/home/appuser/.local \ | ||
/home/appuser/.local | ||
|
@@ -79,7 +82,7 @@ COPY manage.py . | |
|
||
FROM runtime as debug | ||
RUN pip install --user --no-warn-script-location \ | ||
--no-cache-dir debugpy==1.6.7 | ||
--no-cache-dir debugpy==1.8.5 | ||
EXPOSE 5678/tcp | ||
CMD ["python", "-m", "debugpy", "--wait-for-client", "--listen", "0.0.0.0:5678", \ | ||
"-m", "gunicorn", "-c", "python:backend.gunicorn", "manage:application", \ | ||
|
@@ -91,12 +94,13 @@ FROM runtime as prod | |
USER root | ||
RUN apt-get update && \ | ||
apt-get install -y curl && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
# Pre-compile packages to .pyc (init speed gains) | ||
RUN python -c "import compileall; compileall.compile_path(maxlevels=10, quiet=1)" | ||
RUN python -m compileall . | ||
EXPOSE 5000/tcp | ||
USER appuser:appuser | ||
# Default gunicorn worker count is 1 | ||
# For prod the WEB_CONCURRENCY env var can be used to set this | ||
CMD ["gunicorn", "-c", "python:backend.gunicorn", "manage:application", \ | ||
"--workers", "1", "--log-level", "error"] | ||
"--log-level", "error"] |
Oops, something went wrong.