|
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
4 | 4 |
|
5 | | -FROM python:3.12-slim-bookworm AS base |
| 5 | +FROM python:3.12-alpine3.21 AS build-venv |
6 | 6 |
|
7 | | -# |
8 | | -# Fetch requirements |
9 | | -# |
10 | | -FROM base AS builder |
11 | | -RUN apt-get -qq update \ |
12 | | - && apt-get install -y --no-install-recommends g++ \ |
13 | | - && rm -rf /var/lib/apt/lists/* |
| 7 | +RUN apk update && \ |
| 8 | + apk add gcc g++ linux-headers |
14 | 9 |
|
15 | | -WORKDIR /usr/src/app/ |
16 | | -COPY ./src/recommendation/requirements.txt ./ |
| 10 | +COPY ./src/recommendation/requirements.txt requirements.txt |
17 | 11 |
|
18 | | -RUN pip install --upgrade pip |
19 | | -RUN pip install --prefix="/reqs" -r requirements.txt |
| 12 | +RUN python -m venv venv && \ |
| 13 | + venv/bin/pip install --no-cache-dir -r requirements.txt |
20 | 14 |
|
21 | | -# |
22 | | -# Runtime |
23 | | -# |
24 | | -FROM base AS runtime |
25 | | -WORKDIR /usr/src/app/ |
26 | | -COPY --from=builder /reqs /usr/local |
27 | | -COPY ./src/recommendation/ ./ |
| 15 | +RUN venv/bin/opentelemetry-bootstrap -a install |
28 | 16 |
|
29 | | -RUN opentelemetry-bootstrap -a install |
| 17 | +FROM python:3.12-alpine3.21 |
| 18 | + |
| 19 | +COPY --from=build-venv /venv/ /venv/ |
| 20 | + |
| 21 | +WORKDIR /app |
| 22 | + |
| 23 | +COPY ./src/recommendation/demo_pb2_grpc.py demo_pb2_grpc.py |
| 24 | +COPY ./src/recommendation/demo_pb2.py demo_pb2.py |
| 25 | +COPY ./src/recommendation/logger.py logger.py |
| 26 | +COPY ./src/recommendation/metrics.py metrics.py |
| 27 | +COPY ./src/recommendation/recommendation_server.py recommendation_server.py |
30 | 28 |
|
31 | 29 | EXPOSE ${RECOMMENDATION_PORT} |
32 | | -ENTRYPOINT [ "opentelemetry-instrument", "python", "recommendation_server.py" ] |
| 30 | +ENTRYPOINT [ "/venv/bin/opentelemetry-instrument", "/venv/bin/python", "recommendation_server.py" ] |
0 commit comments