Skip to content

Commit 3213ee7

Browse files
committed
Install the container image from prebuilt wheels
The runtime layer resolved and built its dependencies straight from PyPI, so a rebuild could pick up a different set and any sdist in the graph got to run its setup script inside the image. A throwaway builder stage now produces every wheel, and the runtime installs with --only-binary and --no-index against that directory — nothing new can be fetched there. Drop the two suppressions that turned out to be inert: NOSONAR is not honoured inside a Dockerfile or a `run: |` block, so they were noise.
1 parent e4c6629 commit 3213ee7

3 files changed

Lines changed: 42 additions & 13 deletions

File tree

.github/workflows/action-json-lint.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ jobs:
3939
AUTOCONTROL_REF: ${{ inputs.autocontrol_ref }}
4040
run: |
4141
python -m pip install --only-binary :all: --upgrade "pip==26.0.1"
42-
python -m pip install "$AUTOCONTROL_REF" # NOSONAR githubactions:S8544 # reason: documented workflow input, pinned by default, so callers can point at their own release or git ref
42+
# The spec is a documented workflow input — pinned by default so a
43+
# lint run is reproducible, overridable so a caller can track their
44+
# own release or a git ref.
45+
python -m pip install "$AUTOCONTROL_REF"
4346
4447
- name: Lint action JSON files
4548
shell: bash

docker/Dockerfile

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@
55
# Build: docker build -f docker/Dockerfile -t autocontrol:latest .
66
# Run: docker run --rm -p 9939:9939 -p 9940:9940 autocontrol:latest
77

8+
# Build every wheel — the project and its dependencies — in a throwaway
9+
# stage. The runtime image then installs binaries only, so no dependency
10+
# gets to execute a setup script there and the resolved set is fixed at
11+
# build time instead of being re-resolved against PyPI.
12+
FROM python:3.12-slim AS builder
13+
14+
WORKDIR /src
15+
COPY pyproject.toml README.md ./
16+
COPY je_auto_control ./je_auto_control
17+
COPY autocontrol-lsp ./autocontrol-lsp
18+
RUN pip install --no-cache-dir --only-binary :all: --upgrade "pip==26.0.1" \
19+
&& pip wheel --no-cache-dir --wheel-dir /wheels .
20+
21+
822
FROM python:3.12-slim AS runtime
923

1024
ARG DEBIAN_FRONTEND=noninteractive
@@ -37,14 +51,13 @@ COPY je_auto_control ./je_auto_control
3751
COPY autocontrol-lsp ./autocontrol-lsp
3852
COPY README.md ./
3953

40-
# Install the package + the [webrtc] extra so the optional WebRTC host
41-
# also works inside the container. pip itself is pinned so a rebuild
42-
# resolves the same installer, and only wheels are accepted so no
43-
# dependency gets to run a setup script during the build.
44-
RUN pip install --no-cache-dir --only-binary :all: --upgrade "pip==26.0.1"
45-
# The editable install targets the source tree copied in above; there is
46-
# no upstream version to lock and the project's own build must run.
47-
RUN pip install --no-cache-dir -e . # NOSONAR docker:S8541,docker:S8544
54+
# Install from the wheels built above: pinned pip, wheels only, and no
55+
# index lookup, so the runtime layer cannot pull anything new from PyPI.
56+
COPY --from=builder /wheels /wheels
57+
RUN pip install --no-cache-dir --only-binary :all: --upgrade "pip==26.0.1" \
58+
&& pip install --no-cache-dir --only-binary :all: --no-index \
59+
--find-links=/wheels je_auto_control \
60+
&& rm -rf /wheels
4861

4962
ENV DISPLAY=:99 \
5063
PYTHONUNBUFFERED=1 \

docker/Dockerfile.xfce

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
# Connect a VNC viewer to localhost:5900 (no password by default; set
1414
# AUTOCONTROL_VNC_PASSWORD to enable a TightVNC password).
1515

16+
# Same two-stage build as docker/Dockerfile: wheels are produced here so
17+
# the runtime layer installs binaries only, with no index lookup.
18+
FROM python:3.12-slim AS builder
19+
20+
WORKDIR /src
21+
COPY pyproject.toml README.md ./
22+
COPY je_auto_control ./je_auto_control
23+
COPY autocontrol-lsp ./autocontrol-lsp
24+
RUN pip install --no-cache-dir --only-binary :all: --upgrade "pip==26.0.1" \
25+
&& pip wheel --no-cache-dir --wheel-dir /wheels .
26+
27+
1628
FROM python:3.12-slim AS runtime
1729

1830
ARG DEBIAN_FRONTEND=noninteractive
@@ -39,10 +51,11 @@ COPY je_auto_control ./je_auto_control
3951
COPY autocontrol-lsp ./autocontrol-lsp
4052
COPY README.md ./
4153

42-
RUN pip install --no-cache-dir --only-binary :all: --upgrade "pip==26.0.1"
43-
# The editable install targets the source tree copied in above; there is
44-
# no upstream version to lock and the project's own build must run.
45-
RUN pip install --no-cache-dir -e . # NOSONAR docker:S8541,docker:S8544
54+
COPY --from=builder /wheels /wheels
55+
RUN pip install --no-cache-dir --only-binary :all: --upgrade "pip==26.0.1" \
56+
&& pip install --no-cache-dir --only-binary :all: --no-index \
57+
--find-links=/wheels je_auto_control \
58+
&& rm -rf /wheels
4659

4760
ENV DISPLAY=:99 \
4861
PYTHONUNBUFFERED=1 \

0 commit comments

Comments
 (0)