Created
November 23, 2020 08:07
-
-
Save developer-guy/cc579e01bca14fc8dfb7f4037436f44f to your computer and use it in GitHub Desktop.
cross-build-dockerfile-with-args
This file contains hidden or 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
$ cat <<EOF >> Dockerfile | |
FROM alpine | |
ARG TARGETPLATFORM | |
ARG TARGETOS | |
ARG TARGETARCH | |
ARG TARGETVARIANT | |
ARG BUILDPLATFORM | |
ARG BUILDOS | |
ARG BUILDARCH | |
ARG BUILDVARIANT | |
RUN echo "Image target platform details :: " | |
RUN echo "TARGETPLATFORM : $TARGETPLATFORM" | |
RUN echo "TARGETOS : $TARGETOS" | |
RUN echo "TARGETARCH : $TARGETARCH" | |
RUN echo "TARGETVARIANT : $TARGETVARIANT" | |
RUN echo "Image build platform details :: " | |
RUN echo "BUILDPLATFORM : $BUILDPLATFORM" | |
RUN echo "BUILDOS : $BUILDOS" | |
RUN echo "BUILDARCH : $BUILDARCH" | |
RUN echo "BUILDVARIANT : $BUILDVARIANT" | |
EOF | |
$ docker buildx create --name my-new-builder --driver docker-container --use | |
$ docker buildx inspect --bootstrap | |
$ docker buildx build --platform=linux/amd64,linux/arm64,linux/s390x --push -t <dockerhub_id>/my-image:latest . |
Author
developer-guy
commented
Nov 23, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment