Skip to content

Instantly share code, notes, and snippets.

@tonistiigi
Created August 31, 2018 21:24
Show Gist options
  • Save tonistiigi/b1a2b52325f5cba3162aef9077c920c3 to your computer and use it in GitHub Desktop.
Save tonistiigi/b1a2b52325f5cba3162aef9077c920c3 to your computer and use it in GitHub Desktop.
» buildctl build --frontend=dockerfile.v0 --local dockerfile=. --local context=. --frontend-opt platform=linux/amd64,linux/arm,linux/arm64 --exporter=image --exporter-opt name=tonistiigi/copy:v0.1.4 --exporter-opt push=true
[+] Building 25.9s (41/41) FINISHED
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load Dockerfile 0.0s
=> => transferring dockerfile: 37B 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 1.0s
=> [internal] load metadata for docker.io/library/golang:latest 0.8s
=> [internal] load metadata for docker.io/library/golang:latest 0.8s
=> [internal] load metadata for docker.io/library/alpine:latest 0.8s
=> [internal] load metadata for docker.io/library/golang:latest 0.8s
=> [internal] load metadata for docker.io/library/alpine:latest 1.1s
=> [internal] load metadata for docker.io/gruebel/upx:latest 2.0s
=> [linux/arm64 release-noamd64 1/3] FROM docker.io/library/alpine@sha256:7043076348bf5040220df6 0.2s
=> => resolve docker.io/library/alpine@sha256:7043076348bf5040220df6ad703798fd8593a0918d06d3ce30 0.0s
=> => sha256:7043076348bf5040220df6ad703798fd8593a0918d06d3ce30c6c93be117e430 2.03kB / 2.03kB 0.0s
=> => sha256:30ebbffae9ba098b9c345b890c6610aa8422f067754d7e707978a954f3b7a601 735B / 735B 0.0s
=> => sha256:b4103359e1ecd9a7253d8b8a041d4e81db1ff4a5e1950bc0e02305d221c9e6c2 176B / 176B 0.0s
=> => sha256:def91cb894ef09cfa305b37c92e9abca641bcdcf30e08654d233b393ba829b8e 1.76kB / 1.76kB 0.0s
=> => sha256:47e04371c99027fae42871b720fdc6cdddcb65062bfa05f0c3bb0a594cb5bbbd 2.10MB / 2.10MB 0.0s
=> => unpacking docker.io/library/alpine@sha256:7043076348bf5040220df6ad703798fd8593a0918d06d3ce 0.2s
=> [internal] load build context 0.5s
=> => transferring context: 93.88kB 0.5s
=> [linux/amd64 main 1/3] FROM docker.io/library/golang@sha256:ba6460365925abbc6f10579d78e190a34 6.3s
=> => resolve docker.io/library/golang@sha256:ba6460365925abbc6f10579d78e190a343bee11bb450e71a37 0.0s
=> => sha256:1607093a898cc241de8712e4361dcd907898fff35b945adca42db3963f3827b3 10.74MB / 10.74MB 0.0s
=> => sha256:9989a901a73867f06c945ad0ffdb6fad9ae405dfad4d66abd27c9a9d8487817 127.17MB / 127.17MB 0.0s
=> => sha256:ba6460365925abbc6f10579d78e190a343bee11bb450e71a3788885095aa9cf4 3.10kB / 3.10kB 0.0s
=> => sha256:f769ad255dfe8618a7e0e7390dc6c8659708213f047a6d2af6d51e7f3d8d35ab 1.80kB / 1.80kB 0.0s
=> => sha256:9a8ea045c9261c180a34df19cfc9bb3c3f28f29b279bf964ee801536e8244f2f 4.34MB / 4.34MB 0.0s
=> => sha256:7e9ac7032e33f27575623ee7e610ddbeeda6739c4b6288d9938c3c96473b2b08 5.46kB / 5.46kB 0.0s
=> => sha256:9c35c9787a2f7a0fbd6829b8ee0df1aebe44929788186d352b3a12f2046b3948 57.59MB / 57.59MB 0.0s
=> => sha256:ed9dc2a1cc9468b1adf19957dee30eac264903dab9ce0723c92548ecc07b742c 126B / 126B 0.0s
=> => sha256:d4eee24d4dacb41c21411e0477a741655303cdc48b18a948632c31f0f3a70bb8 50.06MB / 50.06MB 0.0s
=> => sha256:55cbf04beb7001d222c71bfdeae780bda19d5cb37b8dbd65ff0d3e6a0b9b74e6 45.31MB / 45.31MB 0.0s
=> => unpacking docker.io/library/golang@sha256:ba6460365925abbc6f10579d78e190a343bee11bb450e71a 6.3s
=> CACHED [internal] helper image for file operations 0.0s
=> => resolve docker.io/tonistiigi/copy:v0.1.3@sha256:e57a3b4d6240f55bac26b655d2cfb751f8b9412d6f 0.0s
=> [linux/arm/v7 release-noamd64 1/3] FROM docker.io/library/alpine@sha256:7043076348bf5040220df 0.1s
=> => resolve docker.io/library/alpine@sha256:7043076348bf5040220df6ad703798fd8593a0918d06d3ce30 0.0s
=> => sha256:a1653f4692c1ccea69cd46121d4f1371957f66e97a20141371dd4da10ebaec19 175B / 175B 0.0s
=> => sha256:4407218c8304d3e30a2a0e967cf0355d037b3dbc4e19b0f05dbcb8d2241f7027 1.75kB / 1.75kB 0.0s
=> => sha256:ee7d700abbf209aa401ef5d53f86af298a25e8154b3259036e9307d08f255c5d 2.15MB / 2.15MB 0.0s
=> => sha256:7043076348bf5040220df6ad703798fd8593a0918d06d3ce30c6c93be117e430 2.03kB / 2.03kB 0.0s
=> => sha256:78f3ccd48cc6a55709b65c8fdb3ef81ed922c5393b064d63b0d35f51e0c9fb2e 735B / 735B 0.0s
=> => unpacking docker.io/library/alpine@sha256:7043076348bf5040220df6ad703798fd8593a0918d06d3ce 0.0s
=> CACHED [linux/amd64 wget 1/2] FROM docker.io/library/alpine@sha256:7043076348bf5040220df6ad70 0.0s
=> => resolve docker.io/library/alpine@sha256:7043076348bf5040220df6ad703798fd8593a0918d06d3ce30 0.0s
=> [linux/amd64 upx 1/3] FROM docker.io/gruebel/upx@sha256:99891d91d6e409ad0dcdb4c70839f105ebf20 1.7s
=> => resolve docker.io/gruebel/upx@sha256:99891d91d6e409ad0dcdb4c70839f105ebf20421bebf896bfc4df 0.0s
=> => sha256:99891d91d6e409ad0dcdb4c70839f105ebf20421bebf896bfc4df827d5a8b19e 737B / 737B 0.0s
=> => sha256:31b463253a089f6562ce119271a4d5519dc5b190ccc4c01a2b53918f4854cb1 568.28kB / 568.28kB 1.5s
=> => sha256:3c533895a64b8fb33e84961537e576b6897368d2b88b60c3492197544630dafa 2.33kB / 2.33kB 0.0s
=> => sha256:0ffadd58f2a61468f527cc4f0fc45272ee4a1a428abe014546c89de2aa6a0eb 715.30kB / 715.30kB 1.5s
=> => unpacking docker.io/gruebel/upx@sha256:99891d91d6e409ad0dcdb4c70839f105ebf20421bebf896bfc4 0.1s
=> [linux/amd64 wget 2/2] RUN apk add --no-cache wget 1.3s
=> [linux/amd64 tar 1/3] RUN wget http://s.minos.io/archive/bifrost/x86_64/tar-1.23-1.tar.gz 1.2s
=> [linux/amd64 bz 1/3] RUN wget http://s.minos.io/archive/bifrost/x86_64/bzip2-bin-1.0.5-1.tar. 0.9s
=> [linux/amd64 xz 1/3] RUN wget http://s.minos.io/archive/bifrost/x86_64/xz-5.0.3-1.tar.gz 1.6s
=> [linux/amd64 gz 1/3] RUN wget http://s.minos.io/archive/bifrost/x86_64/gzip-1.4-1.tar.bz2 0.8s
=> [linux/amd64 gz 2/3] RUN tar xvf gzip-1.4-1.tar.bz2 -C /out 0.2s
=> [linux/amd64 bz 2/3] RUN tar xvf bzip2-bin-1.0.5-1.tar.gz -C /out 0.2s
=> [linux/amd64 tar 2/3] RUN tar xvf tar-1.23-1.tar.gz -C /out 0.2s
=> [linux/amd64 xz 2/3] RUN tar xvf xz-5.0.3-1.tar.gz -C /out 0.2s
=> [linux/amd64 main 2/3] COPY . . 0.2s
=> [linux/amd64 main 3/3] RUN go build -o /copy -ldflags -s -w github.com/tonistiigi/copy/cmd/co 3.2s
=> [linux/amd64 main 3/3] RUN go build -o /copy -ldflags -s -w github.com/tonistiigi/copy/cmd/c 10.0s
=> [linux/amd64 main 3/3] RUN go build -o /copy -ldflags -s -w github.com/tonistiigi/copy/cmd/c 10.0s
=> [linux/amd64 upx 2/3] COPY --from=main /copy /copy 0.2s
=> [linux/amd64 upx 3/3] RUN [upx, /copy] 1.1s
=> CACHED [release-amd64 1/6] COPY --from=upx /copy /bin/ 0.0s
=> CACHED [linux/amd64 release-amd64 2/6] COPY --from=tar /out/bin /bin/ 0.0s
=> [linux/amd64 release-amd64 3/6] COPY --from=gz /out/bin /bin/ 0.2s
=> [linux/amd64 release-amd64 4/6] COPY --from=bz /out/bin /bin/ 0.2s
=> [linux/amd64 release-amd64 5/6] COPY --from=xz /out/usr/bin /bin/ 0.2s
=> [linux/arm/v7 release-noamd64 2/3] RUN apk add -U --no-cache tar gzip bzip2 xz && mv /usr/bin 1.4s
=> [linux/arm64 release-noamd64 2/3] RUN apk add -U --no-cache tar gzip bzip2 xz && mv /usr/bin/ 1.3s
=> [linux/arm/v7 release-noamd64 3/3] COPY --from=main /copy /bin/ 0.2s
=> [linux/arm64 release-noamd64 3/3] COPY --from=main /copy /bin/ 0.2s
=> exporting to image 5.8s
=> => exporting layers 0.4s
=> => exporting manifest sha256:1106b1559f4e2df73edbd277a27c8db3304f6fe0f94b125908e6af7d52483e73 0.0s
=> => exporting config sha256:6d1a5c2308004451a2760944947956a8ff9a17f4964987f39a2d7c9c894fc01b 0.0s
=> => exporting manifest sha256:1783292715b52c8c1f9ab976942ab484729b67cbe927468f2e8bca29d64b4484 0.0s
=> => exporting config sha256:797007a50689656b607e0747a85a8f134eea6bb3fc291791f18030a32129c120 0.0s
=> => exporting manifest sha256:324d2e219043a28ba176dd8d42a89b8ee324cc29e22ba557a1097ce0f18c3ad1 0.0s
=> => exporting config sha256:8167a5f9bce69576f4016727d619d3e6f697460ef3ea5da2c360049067636fa2 0.0s
=> => exporting manifest list sha256:d9d49bedbbe2b27df88115e6aff7b9cd11ed2fbd8d9013f02d3da735c08 0.0s
=> => pushing layers 3.5s
=> => pushing manifest for docker.io/tonistiigi/copy:v0.1.4 1.9s
from --platform=${BUILDPLATFORM} golang AS main
workdir /go/src/github.com/tonistiigi/copy
copy . .
env CGO_ENABLED=0
ARG TARGETARCH
env GOARCH=$TARGETARCH
run go build -o /copy -ldflags '-s -w' github.com/tonistiigi/copy/cmd/copy
from gruebel/upx AS upx
copy --from=main /copy /copy
run ["upx", "/copy"]
from alpine AS wget
workdir /out
run apk add --no-cache wget
from wget AS cp
run wget http://s.minos.io/archive/bifrost/x86_64/coreutils-7.6-5.tar.gz
run tar xvf coreutils-7.6-5.tar.gz -C /
from wget AS tar
run wget http://s.minos.io/archive/bifrost/x86_64/tar-1.23-1.tar.gz
run tar xvf tar-1.23-1.tar.gz -C /out
from wget AS gz
run wget http://s.minos.io/archive/bifrost/x86_64/gzip-1.4-1.tar.bz2
run tar xvf gzip-1.4-1.tar.bz2 -C /out
from wget AS bz
run wget http://s.minos.io/archive/bifrost/x86_64/bzip2-bin-1.0.5-1.tar.gz
run tar xvf bzip2-bin-1.0.5-1.tar.gz -C /out
from wget AS xz
run wget http://s.minos.io/archive/bifrost/x86_64/xz-5.0.3-1.tar.gz
run tar xvf xz-5.0.3-1.tar.gz -C /out
from scratch AS release-amd64
copy --from=upx /copy /bin/
# copy --from=cp /bin/cp /bin/
copy --from=tar /out/bin /bin/
copy --from=gz /out/bin /bin/
copy --from=bz /out/bin /bin/
copy --from=xz /out/usr/bin /bin/
from alpine as dev-env
copy --from=release /bin/ /bin/
entrypoint ["ash"]
from alpine AS release-noamd64
run apk add -U --no-cache tar gzip bzip2 xz && mv /usr/bin/bz* /bin/
# run apk add --no-cache tar
copy --from=main /copy /bin/
from release-noamd64 AS release-arm
from release-noamd64 AS release-arm64
from release-${TARGETARCH}
entrypoint ["/bin/copy"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment