Skip to content

Commit

Permalink
Updated Dockerfile for arm64 build
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Bonafiglia <[email protected]>
  • Loading branch information
rbrtbnfgl committed Apr 23, 2024
1 parent f5f2b2b commit 4e9b372
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
ARG BCI_IMAGE=registry.suse.com/bci/bci-base
ARG GO_IMAGE=rancher/hardened-build-base:v1.21.9b1
FROM ${BCI_IMAGE} as bci
FROM ${GO_IMAGE} as builder
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
FROM --platform=$TARGETPLATFORM ${BCI_IMAGE} as bci
FROM --platform=$TARGETPLATFORM ${GO_IMAGE} as builder
# setup required packages
COPY --from=xx / /
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN set -x && \
apk --no-cache add \
file \
Expand All @@ -11,9 +15,11 @@ RUN set -x && \
linux-headers \
make
# setup the build
ARG ARCH="amd64"
ARG K3S_ROOT_VERSION=v0.13.0
ADD https://github.com/rancher/k3s-root/releases/download/${K3S_ROOT_VERSION}/k3s-root-xtables-${ARCH}.tar /opt/xtables/k3s-root-xtables.tar
RUN xx-info env
RUN mkdir -p /opt/xtables/
RUN export ARCH=$(xx-info arch) &&\
wget https://github.com/rancher/k3s-root/releases/download/${K3S_ROOT_VERSION}/k3s-root-xtables-${ARCH}.tar -O /opt/xtables/k3s-root-xtables.tar
RUN tar xvf /opt/xtables/k3s-root-xtables.tar -C /opt/xtables
ARG TAG=v0.25.1
ARG PKG="github.com/flannel-io/flannel"
Expand All @@ -24,9 +30,15 @@ RUN git fetch --all --tags --prune
RUN git checkout tags/${TAG} -b ${TAG}
# build and assert statically linked executable(s)
ENV GO_LDFLAGS="-X ${PKG}/version.Version=${TAG}"
RUN go-build-static.sh -gcflags=-trimpath=${GOPATH}/src -o bin/flanneld .
RUN go-assert-static.sh bin/*
RUN if [ "${ARCH}" = "amd64" ]; then \
RUN export GOOS=$(xx-info os) &&\
export GOARCH=$(xx-info arch) &&\
export ARCH=$(xx-info arch) &&\
go-build-static.sh -gcflags=-trimpath=${GOPATH}/src -o bin/flanneld .
RUN export GOOS=$(xx-info os) &&\
export GOARCH=$(xx-info arch) &&\
export ARCH=$(xx-info arch) &&\
go-assert-static.sh bin/*
RUN if [ "$(xx-info arch)" = "amd64" ]; then \
go-assert-boring.sh bin/* ; \
fi
RUN install -s bin/* /usr/local/bin
Expand Down

0 comments on commit 4e9b372

Please sign in to comment.