Skip to content

Commit

Permalink
Update docker version and buildx version
Browse files Browse the repository at this point in the history
Fix flaky arm64 emulator issue docker/buildx#542

Use Go 1.17.2 and fix golint installation

fix drone build failure

`go install ginkgo` followed by `which ginkgo` is newly added in the upstream repo.
This is making the drone build fail for arm64 arch. The ginkgo library
gets installed under $GOPATH/bin/linux_arm64 dir. This is unlike amd64 images
which typically install go libraries under $GOPATH/bin. Since the previously mentioned
dir is not in PATH, the command `which ginkgo` fails. I've added this location to PATH
to fix the build failure. See upstream PRs linked below for more info:
kubernetes#8566
kubernetes#8569

use go 1.21.5 | go mod tidy

Signed-off-by: Chirayu Kapoor <chirayu.kapoor@suse.com>
  • Loading branch information
Daishan authored and krunalhinguu committed Aug 20, 2024
1 parent d154b06 commit 5ee32c6
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM docker:19.03.9
ARG DAPPER_HOST_ARCH
ARG STEP=ci
ENV ARCH=${DAPPER_HOST_ARCH}
RUN mkdir -p /.docker/cli-plugins
RUN apk update && apk upgrade && apk add bash && ln -sf /bin/bash /bin/sh # use bash for subsequent variable expansion
ENV DOCKER_BUILDX_URL_arm=https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-arm-v7 \
DOCKER_BUILDX_URL_arm64=https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-arm64 \
DOCKER_BUILDX_URL_amd64=https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64 \
DOCKER_BUILDX_URL=DOCKER_BUILDX_URL_${ARCH}
RUN wget -O - ${!DOCKER_BUILDX_URL} > /.docker/cli-plugins/docker-buildx && chmod +x /.docker/cli-plugins/docker-buildx

FROM ubuntu:18.04
ARG DAPPER_HOST_ARCH
ARG DOCKER_USER
ARG DOCKER_PASS
ENV HOST_ARCH=${DAPPER_HOST_ARCH} \
ARCH=${DAPPER_HOST_ARCH} \
DOCKER_USER=${DOCKER_USER} \
DOCKER_PASS=${DOCKER_PASS}
RUN apt-get update && \
apt-get install -y gcc ca-certificates git wget curl vim less file zip make && \
rm -f /bin/sh && ln -s /bin/bash /bin/sh
ENV GOLANG_ARCH_amd64=amd64 GOLANG_ARCH_arm=armv6l GOLANG_ARCH_arm64=arm64 GOLANG_ARCH=GOLANG_ARCH_${ARCH} \
GOPATH=/go PATH=/go/bin:/usr/local/go/bin:${PATH} SHELL=/bin/bash
RUN wget -O - https://golang.org/dl/go1.21.5.linux-${!GOLANG_ARCH}.tar.gz | tar -xzf - -C /usr/local && \
curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.41.0
COPY --from=0 /usr/local/bin/docker /usr/bin/docker
RUN mkdir -p /.docker/cli-plugins
COPY --from=0 /.docker/cli-plugins/docker-buildx /.docker/cli-plugins/docker-buildx
ENV DOCKER_CLI_EXPERIMENTAL=enabled \
DOCKER_CONFIG=/.docker
RUN docker buildx install
ENV DAPPER_SOURCE /go/src/k8s.io/ingress-nginx/
ENV DAPPER_OUTPUT ./bin ./dist
ENV DAPPER_DOCKER_SOCKET true
ENV DAPPER_ENV CROSS TAG
ENV DAPPER_RUN_ARGS="--net host"
ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache
ENV HOME ${DAPPER_SOURCE}
ENV GIT_IN_DAPPER true
RUN mkdir -p /etc/nginx/geoip
WORKDIR ${DAPPER_SOURCE}
ENTRYPOINT ["./scripts/entry"]
CMD [${STEP}]
1 change: 1 addition & 0 deletions build/run-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ if [[ "$DOCKER_IN_DOCKER_ENABLED" == "true" ]]; then
#go env
go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo@v2.20.0
find / -type f -name ginkgo 2>/dev/null
PATH=$PATH:$GOPATH/bin/linux_arm64
which ginkgo
/bin/bash -c "${FLAGS}"
else
Expand Down
9 changes: 9 additions & 0 deletions hack/init-buildx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ if ! grep -q "^Driver: docker$" <<<"${current_builder}" && \
exit 0
fi

# Ensure qemu is in binfmt_misc
# Docker desktop already has these in versions recent enough to have buildx
# We only need to do this setup on linux hosts
if [ "$(uname)" == 'Linux' ]; then
# NOTE: this is pinned to a digest for a reason!
# https://github.com/docker/buildx/issues/542#issuecomment-778835576
docker run --rm --privileged tonistiigi/binfmt --uninstall qemu-aarch64 && docker run --rm --privileged tonistiigi/binfmt --install arm64
docker run --rm --privileged tonistiigi/binfmt
fi

# Ensure we use a builder that can leverage it (the default on linux will not)
docker buildx rm ingress-nginx || true
Expand Down

0 comments on commit 5ee32c6

Please sign in to comment.