Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
add docker buildx support
Browse files Browse the repository at this point in the history
  • Loading branch information
wawlian committed Apr 13, 2023
1 parent 9b6aabe commit 844eb35
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ build:
release:
bash hack/make-rules/release-images.sh

buildx-release:
docker buildx build --no-cache --push --platform linux/arm64,linux/amd64 -f hack/Dockerfile . -t ${IMG}

clean:
-rm -Rf bin
-rm -Rf _output
Expand Down
13 changes: 13 additions & 0 deletions hack/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM --platform=${BUILDPLATFORM} golang:1.18 as builder
ADD . /build
ARG TARGETOS TARGETARCH
WORKDIR /build/
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build

FROM --platform=${TARGETPLATFORM} alpine:3.17
ARG TARGETOS TARGETARCH
WORKDIR /
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
apk add ca-certificates bash libc6-compat iptables ip6tables && update-ca-certificates && rm /var/cache/apk/*
COPY --from=builder /build/_output/bin/${TARGETOS}/${TARGETARCH}/yurt-device-controller /yurt-device-controller
ENTRYPOINT ["/yurt-device-controller"]

0 comments on commit 844eb35

Please sign in to comment.