File tree Expand file tree Collapse file tree 6 files changed +53
-15
lines changed
Expand file tree Collapse file tree 6 files changed +53
-15
lines changed Original file line number Diff line number Diff line change 33#
44# SPDX-License-Identifier: CC0-1.0
55
6- FROM quay.io/fedora/fedora:42
6+ ARG build_type
7+ # Dependency build stage
8+ FROM ghcr.io/confidential-clusters/buildroot AS builder
9+ ARG build_type
10+ WORKDIR /cocl-operator
11+
12+ COPY Cargo.toml Cargo.lock .
13+ COPY crds crds
14+ COPY rv-store rv-store
15+ COPY operator/Cargo.toml operator/
16+ COPY operator/src/lib.rs operator/src/
717
8- COPY target/debug/operator /usr/bin/operator
18+ # Set only required crates as members to minimize rebuilds upon changes.
19+ # In debug builds, build dependencies to avoid full rebuild.
20+ RUN sed -i 's/members = .*/members = ["crds", "operator", "rv-store"]/' Cargo.toml && \
21+ if [ "$build_type" = debug ]; then cargo build -p operator --lib; fi
922
10- ENTRYPOINT ["/usr/bin/operator" ]
23+ # Target build stage
24+ COPY operator/src operator/src
25+ RUN cargo build -p operator $(if [ "$build_type" = release ]; then echo --release; fi)
26+
27+ # Distribution stage
28+ FROM quay.io/fedora/fedora:42
29+ ARG build_type
30+ COPY --from=builder "/cocl-operator/target/$build_type/operator" /usr/bin
Original file line number Diff line number Diff line change @@ -11,9 +11,12 @@ REGISTRY ?= quay.io
1111OPERATOR_IMAGE =$(REGISTRY ) /confidential-clusters/cocl-operator:latest
1212COMPUTE_PCRS_IMAGE =$(REGISTRY ) /confidential-clusters/compute-pcrs:latest
1313
14+ BUILD_TYPE ?= release
15+
1416all : build tools
1517
1618build :
19+ cargo build -p compute-pcrs
1720 cargo build -p operator
1821
1922tools :
@@ -34,11 +37,9 @@ cluster-up:
3437cluster-down :
3538 scripts/delete-cluster-kind.sh
3639
37- image : build
38- podman build -t $(OPERATOR_IMAGE ) -f Containerfile .
39- podman build -t $(COMPUTE_PCRS_IMAGE ) \
40- -f compute-pcrs/Containerfile \
41- --env K8S_OPENAPI_ENABLED_VERSION=$(K8S_VERSION ) .
40+ image :
41+ podman build --build-arg build_type=$(BUILD_TYPE ) -t $(OPERATOR_IMAGE ) -f Containerfile .
42+ podman build --build-arg build_type=$(BUILD_TYPE ) -t $(COMPUTE_PCRS_IMAGE ) -f compute-pcrs/Containerfile .
4243
4344# TODO: remove the tls-verify, right now we are pushing only on the local registry
4445push : image
Original file line number Diff line number Diff line change @@ -32,8 +32,7 @@ the operator.
3232
3333``` bash
3434make cluster-up
35- make REGISTRY=localhost:5000 image
36- make REGISTRY=localhost:5000 push
35+ make REGISTRY=localhost:5000 image push # optional: use BUILD_TYPE=debug
3736make REGISTRY=localhost:5000 manifests
3837make install-trustee
3938make install
Original file line number Diff line number Diff line change 33#
44# SPDX-License-Identifier: CC0-1.0
55
6+ ARG build_type
67FROM ghcr.io/confidential-clusters/buildroot AS builder
8+ ARG build_type
79WORKDIR /compute-pcrs
10+
811COPY Cargo.toml Cargo.lock .
9- COPY compute-pcrs compute-pcrs
1012COPY rv-store rv-store
11- # Hack: Set required crates as only members to avoid needing to copy other crates.
12- # In that case, a rebuild would be triggered upon any change in those crates.
13+ COPY compute-pcrs/Cargo.toml compute-pcrs/
14+ COPY compute-pcrs/src/lib.rs compute-pcrs/src/
15+
16+ # Set only required crates as members to minimize rebuilds upon changes.
17+ # In debug builds, build dependencies to avoid full rebuild.
1318RUN sed -i 's/members =.*/members = ["compute-pcrs", "rv-store"]/' Cargo.toml && \
1419 git clone --depth 1 https://github.com/confidential-clusters/reference-values && \
15- cargo build --release -p compute-pcrs
20+ if [ "$build_type" = debug ]; then cargo build -p compute-pcrs --lib; fi
21+
22+ COPY compute-pcrs/src compute-pcrs/src
23+ RUN cargo build -p compute-pcrs $(if [ "$build_type" = release ]; then echo --release; fi)
1624
1725FROM quay.io/fedora/fedora:42
18- COPY --from=builder /compute-pcrs/target/release/compute-pcrs /usr/local/bin
26+ ARG build_type
27+ COPY --from=builder "/compute-pcrs/target/$build_type/compute-pcrs" /usr/bin
1928COPY --from=builder /compute-pcrs/reference-values /reference-values
Original file line number Diff line number Diff line change 1+ // SPDX-FileCopyrightText: Jakob Naucke <jnaucke@redhat.com>
2+ //
3+ // SPDX-License-Identifier: MIT
4+
5+ // This pseudo-library exists to build dependencies in a lower
6+ // container layer, which speeds up development.
Original file line number Diff line number Diff line change 1+ // SPDX-FileCopyrightText: Jakob Naucke <jnaucke@redhat.com>
2+ //
3+ // SPDX-License-Identifier: MIT
You can’t perform that action at this time.
0 commit comments