Skip to content

Commit

Permalink
add arm64 support (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
briandowns authored May 23, 2023
1 parent dd600b8 commit 4816ad5
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 43 deletions.
59 changes: 54 additions & 5 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ platform:
steps:
- name: build
pull: always
image: rancher/hardened-build-base:v1.16.10b7
image: rancher/hardened-build-base:v1.20.4b11
commands:
- make DRONE_TAG=${DRONE_TAG}
volumes:
- name: docker
path: /var/run/docker.sock

- name: publish
image: rancher/hardened-build-base:v1.16.10b7
image: rancher/hardened-build-base:v1.20.4b11
commands:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- make DRONE_TAG=${DRONE_TAG} image-push
Expand All @@ -35,7 +35,55 @@ steps:
- tag

- name: scan
image: rancher/hardened-build-base:v1.16.10b7
image: rancher/hardened-build-base:v1.20.4b11
commands:
- make DRONE_TAG=${DRONE_TAG} image-scan
volumes:
- name: docker
path: /var/run/docker.sock

volumes:
- name: docker
host:
path: /var/run/docker.sock
---
kind: pipeline
type: docker
name: linux-arm64

platform:
os: linux
arch: arm64

steps:
- name: build
pull: always
image: rancher/hardened-build-base:v1.20.4b11
commands:
- make DRONE_TAG=${DRONE_TAG}
volumes:
- name: docker
path: /var/run/docker.sock

- name: publish
image: rancher/hardened-build-base:v1.20.4b11
commands:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- make DRONE_TAG=${DRONE_TAG} image-push
environment:
DOCKER_PASSWORD:
from_secret: docker_password
DOCKER_USERNAME:
from_secret: docker_username
volumes:
- name: docker
path: /var/run/docker.sock
when:
event:
- tag

- name: scan
image: rancher/hardened-build-base:v1.20.4b11
commands:
- make DRONE_TAG=${DRONE_TAG} image-scan
volumes:
Expand All @@ -61,15 +109,15 @@ node:
steps:
- name: build
pull: always
image: rancher/hardened-build-base:v1.16.10b7
image: rancher/hardened-build-base:v1.20.4b11
commands:
- make DRONE_TAG=${DRONE_TAG}
volumes:
- name: docker
path: /var/run/docker.sock

- name: publish
image: rancher/hardened-build-base:v1.16.10b7
image: rancher/hardened-build-base:v1.20.4b11
commands:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- make DRONE_TAG=${DRONE_TAG} image-push
Expand Down Expand Up @@ -110,5 +158,6 @@ steps:
- tag
depends_on:
- linux-amd64
- linux-arm64
- linux-s390x
...
68 changes: 34 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG ARCH="amd64"
ARG TAG="v1.2.0"
ARG FLANNEL_TAG="v1.1.2"
ARG BCI_IMAGE=registry.suse.com/bci/bci-base:15.4.27.14.55
ARG GO_IMAGE=rancher/hardened-build-base:v1.20.4b8
ARG BCI_IMAGE=registry.suse.com/bci/bci-base
ARG GO_IMAGE=rancher/hardened-build-base:v1.20.4b11
ARG GOEXPERIMENT=boringcrypto

### Build the cni-plugins ###
Expand All @@ -11,40 +11,40 @@ ARG ARCH
ARG TAG
ARG FLANNEL_TAG
ARG GOEXPERIMENT
RUN git clone --depth=1 https://github.com/containernetworking/plugins.git $GOPATH/src/github.com/containernetworking/plugins \
&& cd $GOPATH/src/github.com/containernetworking/plugins \
&& git fetch --all --tags --prune \
&& git checkout tags/${TAG} -b ${TAG} \
&& sh -ex ./build_linux.sh -v \
-gcflags=-trimpath=/go/src \
-ldflags " \
-X github.com/containernetworking/plugins/pkg/utils/buildversion.BuildVersion=${TAG} \
-linkmode=external -extldflags \"-static -Wl,--fatal-warnings\" \
"
RUN git clone --depth=1 https://github.com/flannel-io/cni-plugin $GOPATH/src/github.com/flannel-io/cni-plugin \
&& cd $GOPATH/src/github.com/flannel-io/cni-plugin \
&& git fetch --all --tags --prune \
&& git checkout tags/${FLANNEL_TAG} -b ${FLANNEL_TAG} \
&& make build_linux \
&& mv $GOPATH/src/github.com/flannel-io/cni-plugin/dist/flannel-${ARCH} $GOPATH/src/github.com/containernetworking/plugins/bin/flannel
RUN git clone --depth=1 https://github.com/containernetworking/plugins.git $GOPATH/src/github.com/containernetworking/plugins && \
cd $GOPATH/src/github.com/containernetworking/plugins && \
git fetch --all --tags --prune && \
git checkout tags/${TAG} -b ${TAG} && \
sh -ex ./build_linux.sh -v \
-gcflags=-trimpath=/go/src \
-ldflags " \
-X github.com/containernetworking/plugins/pkg/utils/buildversion.BuildVersion=${TAG} \
-linkmode=external -extldflags \"-static -Wl,--fatal-warnings\" \
"
RUN git clone --depth=1 https://github.com/flannel-io/cni-plugin $GOPATH/src/github.com/flannel-io/cni-plugin && \
cd $GOPATH/src/github.com/flannel-io/cni-plugin && \
git fetch --all --tags --prune && \
git checkout tags/${FLANNEL_TAG} -b ${FLANNEL_TAG} && \
make build_linux && \
mv $GOPATH/src/github.com/flannel-io/cni-plugin/dist/flannel-${ARCH} $GOPATH/src/github.com/containernetworking/plugins/bin/flannel

WORKDIR $GOPATH/src/github.com/containernetworking/plugins
RUN go-assert-static.sh bin/* \
&& if [ "${ARCH}" != "s390x" ]; then \
go-assert-boring.sh bin/bandwidth \
bin/bridge \
bin/dhcp \
bin/firewall \
bin/host-device \
bin/host-local \
bin/ipvlan \
bin/macvlan \
bin/portmap \
bin/ptp \
bin/vlan ; \
fi \
&& mkdir -vp /opt/cni/bin \
&& install -D -s bin/* /opt/cni/bin
RUN go-assert-static.sh bin/* && \
if [ "${ARCH}" = "amd64" ]; then \
go-assert-boring.sh bin/bandwidth \
bin/bridge \
bin/dhcp \
bin/firewall \
bin/host-device \
bin/host-local \
bin/ipvlan \
bin/macvlan \
bin/portmap \
bin/ptp \
bin/vlan ; \
fi && \
mkdir -vp /opt/cni/bin && \
install -D -s bin/* /opt/cni/bin

# Create image with the cni-plugins
FROM ${BCI_IMAGE}
Expand Down
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
SEVERITIES = HIGH,CRITICAL

ifeq ($(ARCH),)
ARCH=$(shell go env GOARCH)
UNAME_M = $(shell uname -m)
ARCH=
ifeq ($(UNAME_M), x86_64)
ARCH=amd64
else ifeq ($(UNAME_M), aarch64)
ARCH=arm64
else
ARCH=$(UNAME_M)
endif

BUILD_META=-build$(shell date +%Y%m%d)
ORG ?= rancher
TAG ?= v1.2.0$(BUILD_META)

ifneq ($(DRONE_TAG),)
TAG := $(DRONE_TAG)
TAG := $(DRONE_TAG)
endif

ifeq (,$(filter %$(BUILD_META),$(TAG)))
$(error TAG needs to end with build metadata: $(BUILD_META))
$(error TAG needs to end with build metadata: $(BUILD_META))
endif

.PHONY: image-build
Expand Down
5 changes: 5 additions & 0 deletions manifest.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ manifests:
platform:
architecture: amd64
os: linux
-
image: rancher/hardened-cni-plugins:{{build.tag}}-arm64
platform:
architecture: arm64
os: linux
-
image: rancher/hardened-cni-plugins:{{build.tag}}-s390x
platform:
Expand Down

0 comments on commit 4816ad5

Please sign in to comment.