-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
csi-wrapper: Build csi-wrapper images via GHA
- clean Dockerfile - support local dev and remote release build - build three csi-wrappers images in one Dockerfile fixes #1030 Signed-off-by: Da Li Liu <[email protected]>
- Loading branch information
Showing
3 changed files
with
123 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# (C) Copyright Confidential Containers Contributors 2023. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Build and push csi wrapper images for each arch. | ||
--- | ||
name: csi wrapper images | ||
on: | ||
push: | ||
branches: | ||
- 'staging' | ||
- 'csi-wrapper-images' | ||
paths: | ||
- 'volumes/csi-wrapper/**' | ||
|
||
env: | ||
go_version: 1.19 | ||
|
||
jobs: | ||
build_push_job: | ||
name: build and push | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
binary: [csi-controller-wrapper, csi-node-wrapper, csi-podvm-wrapper] | ||
|
||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Golang version ${{ env.go_version }} | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.go_version }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Login to quay Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.QUAY_USERNAME }} | ||
password: ${{ secrets.QUAY_PASSWORD }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
tags: | | ||
quay.io/confidential-containers/${{matrix.binary}}:latest | ||
quay.io/confidential-containers/${{matrix.binary}}:${{ github.sha }} | ||
push: true | ||
context: volumes/csi-wrapper | ||
platforms: linux/amd64, linux/s390x, linux/ppc64le | ||
file: | | ||
volumes/csi-wrapper/Dockerfile.csi_wrappers | ||
build-args: | | ||
"BINARY=${{matrix.binary}}" | ||
"SOURCE_FROM=remote" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright Confidential Containers Contributors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Builds csi wrappers images inside container | ||
|
||
ARG SOURCE_FROM=remote | ||
|
||
##### Builder Dev Image ##### | ||
FROM --platform=${BUILDPLATFORM} golang:1.19 AS builder-local | ||
WORKDIR /src | ||
COPY go.mod go.sum ./cloud-api-adaptor/volumes/csi-wrapper/ | ||
COPY Makefile ./cloud-api-adaptor/volumes/csi-wrapper/ | ||
COPY cmd ./cloud-api-adaptor/volumes/csi-wrapper/cmd | ||
COPY pkg ./cloud-api-adaptor/volumes/csi-wrapper/pkg | ||
|
||
##### Builder Release Image ##### | ||
FROM --platform=${BUILDPLATFORM} golang:1.19 AS builder-remote | ||
ARG BINARY | ||
ARG CAA_SRC="https://github.com/confidential-containers/cloud-api-adaptor" | ||
ARG CAA_SRC_REF="staging" | ||
|
||
WORKDIR /src | ||
|
||
RUN echo $CAA_SRC | ||
RUN echo $CAA_SRC_REF | ||
RUN git clone ${CAA_SRC} -b ${CAA_SRC_REF} cloud-api-adaptor | ||
|
||
FROM builder-${SOURCE_FROM} AS builder | ||
ARG TARGETARCH | ||
ARG BINARY | ||
|
||
RUN cd cloud-api-adaptor/volumes/csi-wrapper/ && make ARCH=${TARGETARCH} ${BINARY} | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM --platform=${TARGETPLATFORM} gcr.io/distroless/static:nonroot | ||
ARG BINARY | ||
WORKDIR / | ||
COPY --from=builder /src/cloud-api-adaptor/volumes/csi-wrapper/build/${BINARY}/${BINARY} /usr/bin/${BINARY} | ||
|
||
ENTRYPOINT ["/usr/bin/${BINARY}"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters