1- ARG PYTHON_VERSION=3.11
2- FROM python:$PYTHON_VERSION-slim as base
1+ ARG PYTHON_VERSION=3.12
2+ FROM python:$PYTHON_VERSION-slim AS base
33ARG UID=2000
44ARG GID=2000
55RUN addgroup --gid $GID nonroot && \
@@ -26,7 +26,7 @@ RUN pip install --no-cache-dir -U poetry
2626# for binaries installed in virtual environments
2727ENTRYPOINT ["poetry" , "run" ]
2828
29- FROM base as base_builder
29+ FROM base AS base_builder
3030# Install build system requirements (gcc, library headers, etc.)
3131# for compiled Python requirements like psycopg2
3232RUN apt-get update \
@@ -44,23 +44,23 @@ COPY --chown=nonroot:nonroot poetry.lock .
4444COPY --chown=nonroot:nonroot Makefile .
4545
4646# Test image, contains all files and dependencies
47- FROM base_builder as dev
47+ FROM base_builder AS dev
4848COPY --chown=nonroot:nonroot . .
4949RUN make dev-dependencies
5050# Note that opentelemetry doesn't play well together with uvicorn reloader
5151# when signals are propagated, we disable it in dev image default CMD
5252CMD ["uvicorn" , "http_app:create_app" , "--host" , "0.0.0.0" , "--port" , "8000" , "--factory" , "--reload" ]
5353
5454# Installs requirements to run production celery application
55- FROM base_builder as celery_builder
55+ FROM base_builder AS celery_builder
5656RUN poetry install --no-root
5757
5858# Installs requirements to run production http application
59- FROM base_builder as http_builder
59+ FROM base_builder AS http_builder
6060RUN poetry install --no-root --with http
6161
6262# Copy the shared python packages
63- FROM base as base_app
63+ FROM base AS base_app
6464USER nonroot
6565RUN poetry config virtualenvs.path /poetryvenvs
6666COPY --chown=nonroot:nonroot pyproject.toml .
@@ -73,16 +73,15 @@ COPY --chown=nonroot:nonroot src/alembic.ini .
7373COPY --chown=nonroot:nonroot Makefile .
7474
7575# Copy the http python package and requirements from relevant builder
76- FROM base_app as http_app
76+ FROM base_app AS http_app
7777COPY --from=http_builder /poetryvenvs /poetryvenvs
7878COPY --chown=nonroot:nonroot src/http_app ./http_app
7979# Run CMD using array syntax, so it's uses `exec` and runs as PID1
8080CMD ["opentelemetry-instrument" , "uvicorn" , "http_app:create_app" , "--host" , "0.0.0.0" , "--port" , "8000" , "--factory" ]
8181
8282# Copy the celery python package and requirements from relevant builder
83- FROM base_app as celery_app
83+ FROM base_app AS celery_app
8484COPY --from=celery_builder /poetryvenvs /poetryvenvs
8585COPY --chown=nonroot:nonroot src/celery_worker ./celery_worker
86- RUN ls
8786# Run CMD using array syntax, so it's uses `exec` and runs as PID1
8887CMD ["opentelemetry-instrument" , "celery" , "-A" , "celery_worker:app" , "worker" , "-l" , "INFO" ]
0 commit comments