|
5 | 5 |
|
6 | 6 | # Supervisor image build. |
7 | 7 | # |
8 | | -# The final image intentionally stays `scratch`: it only carries the static |
9 | | -# openshell-sandbox binary used by Docker extraction, Podman image volumes, and |
10 | | -# the Kubernetes init container copy-self path. |
| 8 | +# The final image is `scratch`: it only carries the static `openshell-sandbox` |
| 9 | +# binary used by Docker extraction, Podman image volumes, and the Kubernetes |
| 10 | +# init container copy-self path. A static musl binary lets the image stay |
| 11 | +# `scratch` while still being executable as an init container. |
11 | 12 | # |
12 | | -# Rust binaries are normally built natively before the image build and staged at: |
| 13 | +# The Rust binary is built natively before this image build runs and staged at: |
13 | 14 | # deploy/docker/.build/prebuilt-binaries/<arch>/openshell-sandbox |
14 | 15 | # |
15 | | -# Local dev callers such as Skaffold can pass BUILD_FROM_SOURCE=1 to compile the |
16 | | -# supervisor inside Docker instead. |
| 16 | +# Use tasks/scripts/docker-build-image.sh supervisor (or `mise run build:docker:supervisor`) |
| 17 | +# to stage the binary and build the image in one step. CI builds the binary |
| 18 | +# per-architecture via the `rust-native-build.yml` workflow (with the musl |
| 19 | +# target) and uploads it as an artifact, which is downloaded into the same |
| 20 | +# staging directory before the image build job runs. |
17 | 21 |
|
18 | | -ARG BUILD_FROM_SOURCE=0 |
19 | | - |
20 | | -FROM rust:1.95.0-slim-bookworm AS rust-builder |
21 | | -ARG TARGETARCH |
22 | | -ARG BUILDARCH |
23 | | - |
24 | | -RUN apt-get update && apt-get install -y --no-install-recommends \ |
25 | | - build-essential \ |
26 | | - ca-certificates \ |
27 | | - pkg-config \ |
28 | | - && rm -rf /var/lib/apt/lists/* |
29 | | - |
30 | | -COPY deploy/docker/cross-build.sh /usr/local/bin/cross-build.sh |
31 | | -RUN . /usr/local/bin/cross-build.sh \ |
32 | | - && install_musl_toolchain \ |
33 | | - && add_musl_target |
34 | | - |
35 | | -WORKDIR /build |
36 | | - |
37 | | -COPY Cargo.toml Cargo.lock ./ |
38 | | -COPY crates/ crates/ |
39 | | -COPY proto/ proto/ |
40 | | -COPY providers/ providers/ |
41 | | - |
42 | | -RUN --mount=type=cache,target=/usr/local/cargo/registry \ |
43 | | - --mount=type=cache,target=/build/target \ |
44 | | - . /usr/local/bin/cross-build.sh \ |
45 | | - && cargo_musl_build --release \ |
46 | | - --features "openshell-core/dev-settings" \ |
47 | | - -p openshell-sandbox \ |
48 | | - --bin openshell-sandbox \ |
49 | | - && mkdir -p /build/out \ |
50 | | - && install -m 0755 "$(musl_output_dir release)/openshell-sandbox" /build/out/openshell-sandbox |
| 22 | +FROM scratch AS supervisor |
51 | 23 |
|
52 | | -FROM scratch AS supervisor-binary-0 |
53 | 24 | ARG TARGETARCH |
54 | | -COPY --chmod=755 deploy/docker/.build/prebuilt-binaries/${TARGETARCH}/openshell-sandbox /build/out/openshell-sandbox |
55 | | - |
56 | | -FROM rust-builder AS supervisor-binary-1 |
57 | | - |
58 | | -FROM supervisor-binary-${BUILD_FROM_SOURCE} AS supervisor-binary |
59 | | - |
60 | | -FROM scratch AS supervisor |
61 | 25 |
|
62 | | -COPY --from=supervisor-binary /build/out/openshell-sandbox /openshell-sandbox |
| 26 | +# --chmod=755 preserves the executable bit through actions/upload-artifact + |
| 27 | +# download-artifact, which strip exec perms during the roundtrip. |
| 28 | +COPY --chmod=755 deploy/docker/.build/prebuilt-binaries/${TARGETARCH}/openshell-sandbox /openshell-sandbox |
63 | 29 |
|
64 | 30 | ENTRYPOINT ["/openshell-sandbox"] |
0 commit comments