-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (26 loc) · 1.13 KB
/
Dockerfile
File metadata and controls
38 lines (26 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
ARG POETRY_VERSION=2.1.3
ARG PYTHON_VERSION=3.12
FROM nanomad/poetry:${POETRY_VERSION}-python-${PYTHON_VERSION} AS builder
WORKDIR /usr/src/app
# --- Reproduce the environment ---
# You can comment the following two lines if you prefer to manually install
# the dependencies from inside the container.
COPY pyproject.toml poetry.lock /usr/src/app/
# Install the dependencies and clear the cache afterwards.
# This may save some MBs.
RUN poetry install --no-root && rm -rf $POETRY_CACHE_DIR
# Now let's build the runtime image from the builder.
# We'll just copy the env and the PATH reference.
FROM python:${PYTHON_VERSION}-slim AS runtime
ARG RELEASE_VERSION=latest
LABEL saic.mqtt.gateway.version="${RELEASE_VERSION}"
LABEL saic.mqtt.gateway.description="SAIC MQTT Gateway: A Python-based service that queries the SAIC API, processes the data, and publishes it to an MQTT broker."
WORKDIR /usr/src/app
ENV RELEASE_VERSION=${RELEASE_VERSION}
ENV VIRTUAL_ENV=/usr/src/app/.venv
ENV PATH="/usr/src/app/.venv/bin:$PATH"
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
COPY src/ .
COPY examples/ .
USER 185:185
CMD [ "python", "./main.py"]