-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e95a5d8
commit 19a3165
Showing
3 changed files
with
37 additions
and
18 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
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 |
---|---|---|
@@ -1,38 +1,49 @@ | ||
ARG BCI_IMAGE=registry.suse.com/bci/bci-busybox | ||
ARG GO_IMAGE=rancher/hardened-build-base:v1.20.14b1 | ||
|
||
FROM --platform=$BUILDPLATFORM ${BCI_IMAGE} as bci | ||
FROM --platform=$BUILDPLATFORM ${GO_IMAGE} as base | ||
# Image that provides cross compilation tooling. | ||
FROM --platform=$BUILDPLATFORM rancher/mirrored-tonistiigi-xx:1.3.0 as xx | ||
|
||
FROM ${BCI_IMAGE} as bci | ||
|
||
FROM --platform=$BUILDPLATFORM ${GO_IMAGE} as base | ||
COPY --from=xx / / | ||
RUN set -x && \ | ||
apk --no-cache add \ | ||
file \ | ||
gcc \ | ||
git \ | ||
make | ||
apk add file make git clang lld | ||
|
||
FROM base as builder | ||
ARG K3S_ROOT_VERSION=v0.13.0 | ||
ARG TARGETPLATFORM | ||
RUN set -x && \ | ||
xx-apk add musl-dev gcc lld | ||
ARG TAG=1.23.0 | ||
ARG ARCH | ||
ADD https://github.com/rancher/k3s-root/releases/download/${K3S_ROOT_VERSION}/k3s-root-xtables-${ARCH}.tar /opt/xtables/k3s-root-xtables.tar | ||
ARG K3S_ROOT_VERSION=v0.13.0 | ||
RUN export ARCH=$(xx-info arch) &&\ | ||
mkdir -p /opt/xtables/ &&\ | ||
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 SRC=github.com/kubernetes/dns | ||
ARG PKG=github.com/kubernetes/dns | ||
RUN git clone --depth=1 https://${SRC}.git $GOPATH/src/${PKG} | ||
WORKDIR $GOPATH/src/${PKG} | ||
RUN git tag --list | ||
RUN git fetch --all --tags --prune | ||
RUN git checkout tags/${TAG} -b ${TAG} | ||
RUN GOARCH=${ARCH} GO_LDFLAGS="-linkmode=external -X ${PKG}/pkg/version.VERSION=${TAG}" \ | ||
RUN xx-go --wrap &&\ | ||
GO_LDFLAGS="-linkmode=external -X ${PKG}/pkg/version.VERSION=${TAG}" \ | ||
go-build-static.sh -gcflags=-trimpath=${GOPATH}/src -o . ./... | ||
RUN go-assert-static.sh node-cache | ||
RUN if [ "${ARCH}" = "amd64" ]; then \ | ||
RUN if [ `xx-info arch` = "amd64" ]; then \ | ||
go-assert-boring.sh node-cache; \ | ||
fi | ||
RUN install -s node-cache /usr/local/bin | ||
RUN install node-cache /usr/local/bin | ||
|
||
FROM bci | ||
#strip needs to run on TARGETPLATFORM, not BUILDPLATFORM | ||
FROM ${GO_IMAGE} as strip_binary | ||
COPY --from=builder /usr/local/bin/node-cache /node-cache | ||
RUN strip /node-cache | ||
|
||
FROM bci | ||
COPY --from=strip_binary /node-cache /node-cache | ||
COPY --from=builder /opt/xtables/bin/ /usr/sbin/ | ||
ENTRYPOINT ["/node-cache"] |
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