Skip to content

Commit

Permalink
WIP: save license info
Browse files Browse the repository at this point in the history
  • Loading branch information
BenTheElder committed May 9, 2023
1 parent e35c483 commit 0a6241b
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions images/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ COPY --chmod=0755 scripts/third_party/gimme/gimme /usr/local/bin/
RUN clean-install git make libseccomp-dev gcc libc-dev pkg-config
# set by makefile to .go-version
ARG GO_VERSION
RUN gimme "${GO_VERSION}"
RUN eval "$(gimme "${GO_VERSION}")" \
&& go install github.com/google/go-licenses@latest


# stage for building containerd
Expand All @@ -115,7 +116,9 @@ RUN git clone --filter=tree:0 "${CONTAINERD_CLONE_URL}" /containerd \
&& cd /containerd \
&& git checkout "${CONTAINERD_VERSION}" \
&& eval "$(gimme "${GO_VERSION}")" \
&& make bin/ctr bin/containerd bin/containerd-shim-runc-v2
&& make bin/ctr bin/containerd bin/containerd-shim-runc-v2 \
&& go-licenses save --save_path=/LICENSES \
./cmd/ctr ./cmd/containerd ./cmd/containerd-shim-runc-v2

# stage for building runc
FROM go-build as build-runc
Expand All @@ -126,7 +129,8 @@ RUN git clone --filter=tree:0 "${RUNC_CLONE_URL}" /runc \
&& cd /runc \
&& git checkout "${RUNC_VERSION}" \
&& eval "$(gimme "${GO_VERSION}")" \
&& make runc
&& make runc \
&& go-licenses save --save_path=/LICENSES .

# stage for building crictl
FROM go-build as build-crictl
Expand All @@ -137,7 +141,8 @@ RUN git clone --filter=tree:0 "${CRI_TOOLS_CLONE_URL}" /cri-tools \
&& cd /cri-tools \
&& git checkout "${CRICTL_VERSION}" \
&& eval "$(gimme "${GO_VERSION}")" \
&& make BUILD_BIN_PATH=./build crictl
&& make BUILD_BIN_PATH=./build crictl \
&& go-licenses save --save_path=/LICENSES ./cmd/crictl

# stage for building cni-plugins
FROM go-build as build-cni
Expand All @@ -152,7 +157,11 @@ RUN git clone --filter=tree:0 "${CNI_PLUGINS_CLONE_URL}" /cni-plugins \
&& go build -o ./bin/host-local -mod=vendor ./plugins/ipam/host-local \
&& go build -o ./bin/loopback -mod=vendor ./plugins/main/loopback \
&& go build -o ./bin/ptp -mod=vendor ./plugins/main/ptp \
&& go build -o ./bin/portmap -mod=vendor ./plugins/meta/portmap
&& go build -o ./bin/portmap -mod=vendor ./plugins/meta/portmap \
&& go-licenses save --save_path=/LICENSES \
./plugins/ipam/host-local \
./plugins/main/loopback ./plugins/main/ptp \
./plugins/meta/portmap

# stage for building containerd-fuse-overlayfs
FROM go-build as build-fuse-overlayfs
Expand All @@ -163,7 +172,8 @@ RUN git clone --filter=tree:0 "${CONTAINERD_FUSE_OVERLAYFS_CLONE_URL}" /fuse-ove
&& cd /fuse-overlayfs-snapshotter \
&& git checkout "${CONTAINERD_FUSE_OVERLAYFS_VERSION}" \
&& eval "$(gimme "${GO_VERSION}")" \
&& make bin/containerd-fuse-overlayfs-grpc
&& make bin/containerd-fuse-overlayfs-grpc \
&& go-licenses save --save_path=/LICENSES ./cmd/containerd-fuse-overlayfs-grpc


# build final image layout from other stages
Expand All @@ -177,20 +187,24 @@ RUN ctr oci spec \
| jq 'del(.process.rlimits)' \
> /etc/containerd/cri-base.json \
&& containerd --version
COPY --from=build-containerd /LICENSES/* /LICENSES/
# copy over runc build and install
COPY --from=build-runc /runc/runc /usr/local/sbin/runc
RUN runc --version
COPY --from=build-runc /LICENSES/* /LICENSES/
# copy over crictl build and install
COPY --from=build-crictl /cri-tools/build/crictl /usr/local/bin/
COPY --from=build-crictl /LICENSES/* /LICENSES/
# copy over CNI plugins build and install
RUN mkdir -p /opt/cni/bin
COPY --from=build-cni /cni-plugins/bin/host-local /opt/cni/bin/
COPY --from=build-cni /cni-plugins/bin/loopback /opt/cni/bin/
COPY --from=build-cni /cni-plugins/bin/ptp /opt/cni/bin/
COPY --from=build-cni /cni-plugins/bin/portmap /opt/cni/bin/
COPY --from=build-cni /LICENSES/* /LICENSES/
# copy over containerd-fuse-overlayfs and install
COPY --from=build-fuse-overlayfs /fuse-overlayfs-snapshotter/bin/containerd-fuse-overlayfs-grpc /usr/local/bin/

COPY --from=build-fuse-overlayfs /LICENSES/* /LICENSES/

# squash down to one layer
FROM scratch
Expand Down

0 comments on commit 0a6241b

Please sign in to comment.