如何使用Docker Buildx从Github Releases拉取打包后的多架构发布版本创建多架构镜像
Base Releases
Dockerfile
1 2 3 4 5 6 7 8 9 10 11 |
FROM debian:stable-slim ENV FRP_VERSION=0.36.2 ARG TARGETOS ARG TARGETARCH ENV OS_ARCH=${TARGETOS}_${TARGETARCH} RUN apt update \ && apt install -y wget \ && rm -rf /var/lib/apt/lists/* \ && rm -rf /var/cache/* \ && wget -O - "https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_${OS_ARCH}.tar.gz" | tar -xzf - frp_${FRP_VERSION}_${OS_ARCH}/frps frp_${FRP_VERSION}_${OS_ARCH}/frpc --strip-components 1 ENTRYPOINT ["/frps"] |
这里用到了两个buildx的全局函数,TARGETOS以及TARGETARCH,使用buildx构建镜像时会按照–platform中指定的架构进行动态赋值,然后通过一个ENV将OS和ARCH组装成和FRP发布版本文件名。
Build
Intel
1 |
docker buildx build --push --platform linux/amd64,linux/386 -t minirplus/frp -f ./Dockerfile.frp . |
ARM
1 |
docker buildx build --push --platform linux/arm64,linux/arm/v7,linux/arm/v6 -t minirplus/frp:arm -f ./Dockerfile.frp . |
docker desktop
1 |
docker buildx build --push --platform linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6 -t minirplus/frp -f ./Dockerfile.frp . |
Test Run
1 |
docker run -it --rm --network host -v /root/frp/frps.ini:/frps.ini --entrypoint /frps minirplus/frp -c /frps.ini |
There are no comments yet