-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (48 loc) · 1.98 KB
/
Copy pathDockerfile
File metadata and controls
63 lines (48 loc) · 1.98 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# syntax=docker/dockerfile:1.7
# ----------------------------------------------------------------------------
# sourcerykit container layout
# ----------------------------------------------------------------------------
# Stage 1 (builder) : produces a wheel from the current source tree.
# Stage 2 (runtime) : minimal image with just the wheel installed, suitable
# for use as a base by services that consume the SDK.
#
# Local development and CI run via `uv` directly; the image intentionally
# does not bundle test tooling. See README.md "Development" / "Tests" for
# the uv-based workflow.
#
# Build:
# docker build -t sourcerykit:runtime .
#
# Smoke-import:
# docker run --rm sourcerykit:runtime
# ----------------------------------------------------------------------------
ARG PYTHON_VERSION=3.12
# ---------- Stage 1: builder ------------------------------------------------
FROM python:${PYTHON_VERSION}-slim AS builder
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1
WORKDIR /build
RUN pip install --upgrade pip hatch
COPY pyproject.toml README.md LICENSE.md ./
COPY src ./src
COPY alembic ./alembic
RUN hatch build -t wheel /dist
# ---------- Stage 2: runtime ------------------------------------------------
FROM python:${PYTHON_VERSION}-slim AS runtime
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1
WORKDIR /app
# psycopg2-binary ships its own libpq, but installing libpq5 keeps
# runtime tooling (psql, diagnostics) usable in derived images.
RUN apt-get update \
&& apt-get install -y --no-install-recommends libpq5 \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /dist /dist
RUN pip install --upgrade pip \
&& pip install /dist/*.whl \
&& rm -rf /dist
CMD ["python", "-c", "import importlib.metadata as m, sourcerykit; print('sourcerykit', m.version('sourcerykit'), 'imported as', sourcerykit.__name__)"]