Repository navigation
Expand file tree
/
Copy pathDockerfile.executor
More file actions
54 lines (52 loc) · 2.29 KB
/
Copy pathDockerfile.executor
File metadata and controls
54 lines (52 loc) · 2.29 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
# Multi-stage: build with uv, run with slim
#
# Mirror config ARGs — same pattern as Dockerfile.controller so build
# works behind restricted egress (catown.cloud); override at build time
# on hosts with direct pypi/debian.org access.
ARG PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple/
ARG APT_MIRROR=mirrors.aliyun.com
FROM python:3.12-slim AS builder
ARG PIP_INDEX_URL
ARG APT_MIRROR
ENV PIP_INDEX_URL=${PIP_INDEX_URL}
ENV UV_INDEX_URL=${PIP_INDEX_URL}
ENV UV_DEFAULT_INDEX=${PIP_INDEX_URL}
WORKDIR /app
RUN pip install --no-cache-dir uv==0.11.9
# 1) Deps-only layer — keyed on pyproject.toml + uv.lock ALONE, so a
# source-only edit below does NOT re-trigger the (slow) dependency
# install. --no-install-project installs deps without building `dlw`
# itself, so src/ + README.md aren't needed here. The uv cache mount
# persists downloaded wheels across builds even when this layer is
# busted by a lockfile change (requires DOCKER_BUILDKIT=1).
COPY pyproject.toml uv.lock ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --no-install-project
# 2) Project layer — now copy source + the metadata the wheel build needs
# (README is referenced by [project].readme), then install `dlw` itself
# (fast: all deps are already present from step 1).
COPY alembic.ini README.md ./
COPY src/ src/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev
FROM python:3.12-slim
ARG PIP_INDEX_URL
ARG APT_MIRROR
ENV PIP_INDEX_URL=${PIP_INDEX_URL}
WORKDIR /app
COPY --from=builder /app/.venv /app/.venv
COPY --from=builder /app/src /app/src
COPY --from=builder /app/alembic.ini ./alembic.ini
RUN echo "deb http://${APT_MIRROR}/debian bookworm main contrib non-free non-free-firmware" \
> /etc/apt/sources.list \
&& echo "deb http://${APT_MIRROR}/debian bookworm-updates main contrib non-free non-free-firmware" \
>> /etc/apt/sources.list \
&& echo "deb http://${APT_MIRROR}/debian-security bookworm-security main contrib non-free non-free-firmware" \
>> /etc/apt/sources.list \
&& rm -f /etc/apt/sources.list.d/debian.sources \
&& apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
ENV PATH="/app/.venv/bin:${PATH}"
ENV PYTHONPATH=/app/src
ENTRYPOINT ["dlw-executor"]