Skip to content

Commit

Permalink
Build multi-arch rootless-cni-infra on GitHub Actions
Browse files Browse the repository at this point in the history
The image is built as a multi-arch OCI tar.gz and uploaded as a GitHub Artifact.

The image is NOT pushed to quay automatically.
A maintainer can use `skopeo` to push the artifact archive to quay.

Signed-off-by: Akihiro Suda <[email protected]>
  • Loading branch information
AkihiroSuda committed Nov 19, 2020
1 parent a18365c commit fc34be7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
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
- name: "Print SHA256SUM of rootless-cni-infra.tar.gz"
run: |
sha256sum rootless-cni-infra.tar.gz
- 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."
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

0 comments on commit fc34be7

Please sign in to comment.