Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (33 loc) · 1.47 KB
/
Copy pathDockerfile
File metadata and controls
41 lines (33 loc) · 1.47 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
39
40
41
# Stage 1: build wheels
FROM python:3.13-slim@sha256:6771159cd4fa5d9bba1258caf0b82e6b73458c694d178ad97c5e925c2d0e1a91 AS builder
WORKDIR /build
# Build dep wheels first - this layer + the pip cache mount survive
# unless pyproject.toml itself changes, so iterative app edits don't
# re-download/rebuild every transitive dep.
COPY pyproject.toml .
RUN --mount=type=cache,target=/root/.cache/pip \
pip wheel --wheel-dir /wheels \
$(python -c "import tomllib; \
d = tomllib.load(open('pyproject.toml','rb')); \
print(' '.join(d['project']['dependencies']))")
# Then build the app wheel on top, without re-resolving deps.
COPY app/ app/
RUN --mount=type=cache,target=/root/.cache/pip \
pip wheel --no-deps --wheel-dir /wheels .
# Stage 2: runtime image
FROM python:3.13-slim@sha256:6771159cd4fa5d9bba1258caf0b82e6b73458c694d178ad97c5e925c2d0e1a91
LABEL org.opencontainers.image.source="https://github.com/Jaano/matterregistry"
LABEL org.opencontainers.image.licenses="Apache-2.0"
RUN mkdir -p /config
WORKDIR /app
COPY --from=builder /wheels /wheels
COPY app/ app/
COPY alembic.ini .
COPY migrations/ migrations/
RUN pip install --no-cache-dir --no-index --find-links /wheels matterregistry && \
rm -rf /wheels
VOLUME ["/config"]
EXPOSE 5591
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD python -c "import urllib.request, sys; urllib.request.urlopen('http://127.0.0.1:5591/healthz'); sys.exit(0)" || exit 1
CMD ["python", "-m", "app"]