Repository navigation
Expand file tree
/
Copy pathContainerfile
More file actions
89 lines (76 loc) · 3.75 KB
/
Copy pathContainerfile
File metadata and controls
89 lines (76 loc) · 3.75 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Containerfile for composefs-rs integration testing
#
# Builds cfsctl and integration test binaries, then produces a bootable
# (bootc-compatible) container image suitable for privileged integration
# testing via `bcvk ephemeral run-ssh`.
#
# Build:
# podman build --tag composefs-rs-test .
# podman build --build-arg base_image=ghcr.io/bootcrew/debian-bootc:latest --tag composefs-rs-test-debian .
#
# Uses BuildKit-style cache mounts for fast incremental Rust builds.
# Note: when switching between base images locally, run
# podman system prune --volumes
# to clear stale build caches that may be incompatible across distros.
ARG base_image=quay.io/centos-bootc/centos-bootc:stream10
ARG cfsctl_features=pre-6.15
# "build": install a skopeo built from source that has OpenVarlinkSocket.
# "distro": keep the distribution's skopeo, to test the fallback.
ARG skopeo_source=build
# -- source snapshot (keeps layer graph clean) --
FROM scratch AS src
COPY . /src
# -- skopeo with the image proxy's OpenVarlinkSocket, which distributions don't
# ship yet; cfsctl needs it to import from containers-storage --
FROM ${base_image} AS skopeo-build
COPY --from=src /src/contrib /src/contrib
RUN mkdir -p /out && /src/contrib/packaging/build-skopeo.sh /out
# -- empty: leave the distribution's skopeo alone --
FROM ${base_image} AS skopeo-distro
RUN mkdir -p /out
# -- build stage --
FROM ${base_image} AS build
ARG cfsctl_features
COPY --from=src /src/contrib /src/contrib
RUN /src/contrib/packaging/install-build-deps.sh
COPY --from=src /src /src
WORKDIR /src
# Fetch dependencies (network-intensive, cached separately)
RUN --mount=type=cache,target=/src/target \
--mount=type=cache,target=/root/.cargo/registry \
--mount=type=cache,target=/root/.cargo/git \
cargo fetch
# Build cfsctl, the integration test binary and libcomposefs.
# Separate invocations: features are scoped to composefs-ctl and must not
# be passed to composefs-integration-tests, which has no optional features.
# libcomposefs only gets rhel9 (pre-6.15 is its default).
RUN --network=none \
--mount=type=cache,target=/src/target \
--mount=type=cache,target=/root/.cargo/registry \
--mount=type=cache,target=/root/.cargo/git \
cargo build --release -p composefs-ctl --features="${cfsctl_features}" && \
cargo build --release -p composefs-integration-tests && \
capi_features=$(echo "${cfsctl_features}" | tr ', ' '\n\n' | grep -x rhel9 || true) && \
cargo build --release -p composefs-capi --features="${capi_features}" && \
cp /src/target/release/cfsctl /usr/bin/cfsctl && \
cp /src/target/release/cfsctl-integration-tests /usr/bin/cfsctl-integration-tests && \
mkdir -p /usr/lib/composefs-rs-test && \
cp /src/target/release/libcomposefs_capi.so /usr/lib/composefs-rs-test/libcomposefs.so.1
# A C program calling our libcomposefs (not the distribution's), for the
# privileged libcomposefs tests
RUN --network=none \
ln -s libcomposefs.so.1 /usr/lib/composefs-rs-test/libcomposefs.so && \
gcc -o /usr/bin/lcfs-mount-test /src/crates/composefs-capi/tests/lcfs-mount-test.c \
-I/src/crates/composefs-capi/include -L/usr/lib/composefs-rs-test -lcomposefs \
-Wl,-rpath,/usr/lib/composefs-rs-test
# -- final bootable image --
FROM ${base_image}
COPY --from=src /src/contrib /src/contrib
RUN /src/contrib/packaging/install-test-deps.sh && rm -rf /src
# With skopeo_source=build, replaces the distribution's skopeo installed above
ARG skopeo_source
COPY --from=skopeo-${skopeo_source} /out/ /usr/bin/
COPY --from=build /usr/bin/cfsctl /usr/bin/cfsctl
COPY --from=build /usr/bin/cfsctl-integration-tests /usr/bin/cfsctl-integration-tests
COPY --from=build /usr/lib/composefs-rs-test /usr/lib/composefs-rs-test
COPY --from=build /usr/bin/lcfs-mount-test /usr/bin/lcfs-mount-test