Copy docker buildx create --name multi-platform --use --platform linux/amd64,linux/arm64 --driver docker-container
Copy docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
Copy docker buildx create --use --name mybuilder
Copy docker buildx inspect mybuilder --bootstrap
Name: mybuilder
Driver: docker-container
Nodes:
Name: mybuilder0
Endpoint: unix:///var/run/docker.sock
Status: running
Platforms: linux/amd64, linux/arm64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6, linux/riscv64, linux/mips64le, linux/mips64
登录master主机创建k8s多平台构建器并默认使用
Copy kubectl create ns docker-builder
docker buildx create --use --name mutil-arth-k8s --driver kubernetes --driver-opt nodeselector=kubernetes.io/arch=amd64 --driver-opt replicas= 1 --driver-opt qemu.install= true --driver-opt namespace=docker-builder
Copy docker buildx inspect mutil-arth-k8s --bootstrap
Name: mutil-arth-k8s
Driver: kubernetes
Nodes:
Name: mutil-arth-k8s0-76b5c6d889-47qbg
Endpoint:
Status: running
Platforms: linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6
Copy FROM golang:1.17-alpine as builder
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.io
COPY rnode-exporter/. ./rnode-exporter/
RUN cd ./rnode-exporter/ && \
go mod download && \
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o rnode-exporter && \
cp rnode-exporter /
FROM alpine:3.15 as prod
COPY --from=0 rnode-exporter /
EXPOSE 9102
CMD [ "/rnode-exporter" ]
Copy docker login harbor.example.com
Copy docker buildx build -t harbor.example.com/bfs/rnode-exporter:v0.10.3 --platform=linux/arm64,linux/amd64 . --push