@@ -20,6 +20,10 @@ RUN apt-get update \
20
20
RUN pip install --no-cache-dir -U pip
21
21
RUN pip install --no-cache-dir -U poetry
22
22
23
+ # We run everything by poetry run from now on, so that PATH will be handled
24
+ # for binaries installed in virtual environments
25
+ ENTRYPOINT ["poetry" , "run" ]
26
+
23
27
FROM base as base_builder
24
28
# Install build system requirements (gcc, library headers, etc.)
25
29
# for compiled Python requirements like psycopg2
@@ -37,9 +41,12 @@ COPY --chown=nonroot:nonroot pyproject.toml .
37
41
COPY --chown=nonroot:nonroot poetry.lock .
38
42
39
43
# Test image, contains all files and dependencies
40
- FROM base_builder as test
44
+ FROM base_builder as dev
41
45
RUN poetry install --with http,grpc,dev
42
46
COPY --chown=nonroot:nonroot . .
47
+ # Note that opentelemetry doesn't play well together with uvicorn reloader
48
+ # when signals are propagated, we disable it in dev image default CMD
49
+ CMD ["uvicorn" , "http_app:create_app" , "--host" , "0.0.0.0" , "--port" , "8000" , "--factory" , "--reload" ]
43
50
44
51
# Installs requirements to run production http application
45
52
FROM base_builder as http_builder
@@ -62,20 +69,17 @@ COPY --chown=nonroot:nonroot config.py .
62
69
COPY --chown=nonroot:nonroot di_container.py .
63
70
COPY --chown=nonroot:nonroot alembic.ini .
64
71
COPY --chown=nonroot:nonroot Makefile .
65
- ENTRYPOINT ["poetry" , "run" ]
66
72
67
73
# Copy the http python package and requirements from relevant builder
68
74
FROM base_app as http_app
69
75
COPY --from=http_builder /poetryvenvs /poetryvenvs
70
76
COPY --chown=nonroot:nonroot http_app ./http_app
71
- # opentelemetry-instrument will spawn a subprocess, therefore we use exec
72
- # to make sure the app runs on PID 1 and receives correctly system signals
73
- CMD opentelemetry-instrument uvicorn http_app:create_app --host 0.0.0.0 --port 8000 --factory
77
+ # Run CMD using array syntax, so it's uses `exec` and runs as PID1
78
+ CMD ["opentelemetry-instrument" , "uvicorn" , "http_app:create_app" , "--host" , "0.0.0.0" , "--port" , "8000" , "--factory" ]
74
79
75
80
# Copy the grpc python package and requirements from relevant builder
76
81
FROM base_app as grpc_app
77
82
COPY --from=grpc_builder /poetryvenvs /poetryvenvs
78
83
COPY --chown=nonroot:nonroot grpc_app ./grpc_app
79
- # opentelemetry-instrument will spawn a subprocess, therefore we use exec
80
- # to make sure the app runs on PID 1 and receives correctly system signals
81
- CMD exec opentelemetry-instrument python3 -m grpc_app
84
+ # Run CMD using array syntax, so it's uses `exec` and runs as PID1
85
+ CMD ["opentelemetry-instrument" , "python3" , "-m" , "grpc_app" ]
0 commit comments