Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build multi-arch rootless-cni-infra on GitHub Actions #8415

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/rootless-cni-infra.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build rootless-cni-infra
on: [push, pull_request]
jobs:
release:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: "Register QEMU to /proc/sys/fs/binfmt_misc"
run: docker run --privileged --rm tonistiigi/binfmt --install all
- name: "Fetch buildx binary"
run: |
wget -O buildx https://github.com/docker/buildx/releases/download/v0.4.2/buildx-v0.4.2.linux-amd64
chmod +x buildx
- name: "Initialize buildx"
run: |
./buildx create --name cross --platform=amd64,arm,arm64,s390x,ppc64le --use
./buildx inspect --bootstrap
- name: "Build rootless-cni-infra.tar.gz (Multi-arch OCI archive)"
run: |
./buildx build \
--output type=oci,dest=rootless-cni-infra.tar \
--platform amd64,arm,arm64,s390x,ppc64le \
-f contrib/rootless-cni-infra/Containerfile \
contrib/rootless-cni-infra
gzip -9 rootless-cni-infra.tar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the compression is worthwhile here, actions/upload-artifact will create a compressed zip-file automatically.

- name: "Print SHA256SUM of rootless-cni-infra.tar.gz"
run: |
sha256sum rootless-cni-infra.tar.gz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this is my own ignorance: What is the purpose of calculating/printing the sha256sum of the tarball?

- name: "Upload rootless-cni-infra.tar.gz as a GitHub Artifact"
uses: actions/upload-artifact@v1
with:
name: rootless-cni-infra.tar.gz
path: rootless-cni-infra.tar.gz
- name: "Notice"
run: |
echo "The image is NOT pushed to quay. To push the image to quay, run skopeo manually with the artifact archive."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were you thinking of implementing the push to quay, or is that something I could/should do as a followup PR?

I'm okay either way, but since I need to create the accounts and add the secrets, it might be easier if done as a followup.

12 changes: 6 additions & 6 deletions contrib/rootless-cni-infra/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ ARG CNI_VERSION=v0.8.0
ARG CNI_PLUGINS_VERSION=v0.8.7
ARG DNSNAME_VESION=v1.0.0

FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} AS golang-base
FROM --platform=$BUILDPLATFORM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} AS golang-base
RUN apk add --no-cache git

FROM golang-base AS cnitool
FROM --platform=$BUILDPLATFORM golang-base AS cnitool
RUN git clone https://github.com/containernetworking/cni /go/src/github.com/containernetworking/cni
WORKDIR /go/src/github.com/containernetworking/cni
ARG CNI_VERSION
RUN git checkout ${CNI_VERSION}
RUN go build -o /cnitool ./cnitool
RUN GOARCH=$TARGETARCH go build -o /cnitool ./cnitool

FROM golang-base AS dnsname
FROM --platform=$BUILDPLATFORM golang-base AS dnsname
RUN git clone https://github.com/containers/dnsname /go/src/github.com/containers/dnsname
WORKDIR /go/src/github.com/containers/dnsname
ARG DNSNAME_VERSION
RUN git checkout ${DNSNAME_VERSION}
RUN go build -o /dnsname ./plugins/meta/dnsname
RUN GOARCH=$TARGETARCH go build -o /dnsname ./plugins/meta/dnsname

FROM alpine:${ALPINE_VERSION}
RUN apk add --no-cache curl dnsmasq iptables ip6tables iproute2
Expand All @@ -33,4 +33,4 @@ COPY rootless-cni-infra /usr/local/bin
ENV CNI_PATH=/opt/cni/bin
CMD ["sleep", "infinity"]

ENV ROOTLESS_CNI_INFRA_VERSION=3
ENV ROOTLESS_CNI_INFRA_VERSION=4