swagger-ui
swagger-ui copied to clipboard
Crossbuilding docker image for different architectures
Content & configuration
Docker image should work on most common processor architectures.
Is your feature request related to a problem?
The image only works on the architecture with which it was built. Now docker image only works on x86-64 (maybe only x64). Docker image not working on Raspberry PI at least.
➜ ~ arch
armv7l
➜ ~ docker run -it swaggerapi/swagger-ui sh
standard_init_linux.go:211: exec user process caused "exec format error"
➜ ~ arch
x86_64
➜ ~ docker run -it swaggerapi/swagger-ui sh -c "echo 'works well'"
works well
Describe the solution you'd like
Something like
docker buildx build \
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x \
--output "type=image,push=false" \
--file ./Dockerfile \
--pull \
--tag swaggerapi/swagger-ui:latest \
.
Describe alternatives you've considered
https://docs.docker.com/engine/reference/commandline/manifest_create/
Additional context
docker buildx imagetools inspect nginx:1.17-alpine
Base image works on linux/amd64, linux/arm/v6, linux/arm64/v8, linux/386, linux/ppc64le, linux/s390x.
Swagger UI image not event annotated
docker buildx imagetools inspect swaggerapi/swagger-ui
I wrote Github Actions pipeline for crossbuilding swagger-ui image to 386, amd64, arm/v6, arm/v7, arm64, s390x architectures. https://github.com/Pentusha/swagger-ui/blob/master/.github/workflows/docker_crossbuild.yml It publish result images to Docker Hub: https://hub.docker.com/repository/docker/pentusha/swagger-ui-crossbuild/general Its works fine on my raspberry pi 4.
arch; docker run -it pentusha/swagger-ui-crossbuild:latest sh -c 'echo "works well"'
armv7l
works well
Maybe you could include this build steps to your Jenkins pipelines.
Would like to see ARM64 support :) Thank you to share your config. If we can enable Github Action pipeline for crossbuilding and testing in this upstream project, I think it's better.
Sad this hasn't happened in the parent project yet, e.g. for those of us on new macs
currently I get:
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
2021/09/28 09:39:09 [emerg] 70#70: io_setup() failed (38: Function not implemented)
I assume the error there is an issue with qemu emulation
the solution would be to publish a multi-arch docker image as suggested by the OP
Really love to see linux arm64 support. Since I am using an M1 macbook.
Hi guys,
Let's start the conversation about this. Give us some time to study the problem and possible solution. These are the resources I've been able to gather so far about the topic. Do you have some additional resources we can study?
Resources:
- https://docs.docker.com/buildx/working-with-buildx/
- https://github.com/moby/buildkit
- https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/
- https://docs.docker.com/build/building/multi-platform/
Thanks!
Would like to see ARM64 support :) Thank you to share your config. If we can enable Github Action pipeline for crossbuilding and testing in this upstream project, I think it's better.
Yepp, found out today that this image does not work with the new M1 Apple chips (arm64). Would love to see support for this added as well!
Would like to see ARM64 support :)
Would like to see support for ARM64!
I need ARM64 support too
Please support ARM64. I am having a very difficult time in my business and would like to fix it as soon as possible. If there is anything I can do to help improve the deployment flow, I would like to actively contribute.
It seems like the maintainers were hit hard by the first COVID wave, this issue is 2+ years old, and no action was taken. Please support ARM64.
It seems like the maintainers were hit hard by the first COVID wave, this issue is 2+ years old, and no action was taken. Please support ARM64.
Pretty funny, I'll give you that ;]
Today I've requested our DevOps team to install latest Docker version 20.10.18 in our Jenkins which we still for building and pushing the docker images. This will open the possibility to build and publish multi-arch images as the buildx
is baked-in in that version.
I've started to play with building multiarch image by running the suggested command (using Linux Mint 20.3 and Docker 20.10.18) in cloned swagger-ui repo:
$ docker buildx build -t swaggerapi/swagger-ui:latest --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/386,linux/ppc64le,linux/s390x .
What I got was: ERROR: multiple platforms feature is currently not supported for docker driver. Please switch to a different driver (eg. "docker buildx create --use")
After reading https://developer.broadleafcommerce.com/starter-projects/docker-configuration I've figured out I need to install QEMU to get rid of that error:
$ docker run --privileged --rm tonistiigi/binfmt --install all
$ docker run --privileged --rm tonistiigi/binfmt --install arm64,riscv64,arm
$ docker buildx create --name "my-blc-multiplat-builder" --driver="docker-container" --bootstrap --use
After running following command again, I've got following result:
command
$ docker buildx build -t swaggerapi/swagger-ui:latest --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/386,linux/ppc64le,linux/s390x .
output
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
[+] Building 176.7s (60/60) FINISHED
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 873B 0.0s
=> [internal] load .dockerignore 0.2s
=> => transferring context: 123B 0.0s
=> [linux/amd64 internal] load metadata for docker.io/library/nginx:1.23.1-alpine 7.4s
=> [linux/arm/v6 internal] load metadata for docker.io/library/nginx:1.23.1-alpine 7.4s
=> [linux/arm64 internal] load metadata for docker.io/library/nginx:1.23.1-alpine 8.1s
=> [linux/s390x internal] load metadata for docker.io/library/nginx:1.23.1-alpine 8.1s
=> [linux/arm/v7 internal] load metadata for docker.io/library/nginx:1.23.1-alpine 7.9s
=> [linux/386 internal] load metadata for docker.io/library/nginx:1.23.1-alpine 7.9s
=> [linux/ppc64le internal] load metadata for docker.io/library/nginx:1.23.1-alpine 8.0s
=> [auth] library/nginx:pull token for registry-1.docker.io 0.0s
=> [internal] load build context 0.7s
=> => transferring context: 8.56MB 0.2s
=> [linux/arm/v7 1/7] FROM docker.io/library/nginx:1.23.1-alpine@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74 29.8s
=> => resolve docker.io/library/nginx:1.23.1-alpine@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74 0.2s
=> => sha256:205e03a611f5606fc0a9be67b595de37e134d97852b7750c62228da68734ec11 1.40kB / 1.40kB 1.1s
=> => sha256:4c5e4e3ec411ad590fd72ad0e8e5ed588f3280a74d085b8beeaefc2c9db80480 667B / 667B 0.6s
=> => sha256:d44dff4044b74b5911b99e6a7a6fbe6cfbdb507b71c1bafb7c967ecaafa09dec 897B / 897B 1.1s
=> => sha256:766f0b0527824d8b3b8849e601ab72acbae315f32d19221d59e4d4931a79994f 6.49MB / 6.49MB 16.2s
=> => sha256:1e9dee1c21d984ac33307cf0bb5e450572c4943e02df66b6586d6cc83f2f744e 601B / 601B 0.3s
=> => sha256:c6556b3b6858c6fa1e328377cc2c4becdc9cd1bc3e7302aa7299936522cf93ba 2.42MB / 2.42MB 7.3s
=> => extracting sha256:c6556b3b6858c6fa1e328377cc2c4becdc9cd1bc3e7302aa7299936522cf93ba 0.2s
=> => extracting sha256:766f0b0527824d8b3b8849e601ab72acbae315f32d19221d59e4d4931a79994f 0.6s
=> => extracting sha256:1e9dee1c21d984ac33307cf0bb5e450572c4943e02df66b6586d6cc83f2f744e 0.0s
=> => extracting sha256:d44dff4044b74b5911b99e6a7a6fbe6cfbdb507b71c1bafb7c967ecaafa09dec 0.0s
=> => extracting sha256:4c5e4e3ec411ad590fd72ad0e8e5ed588f3280a74d085b8beeaefc2c9db80480 0.0s
=> => extracting sha256:205e03a611f5606fc0a9be67b595de37e134d97852b7750c62228da68734ec11 0.0s
=> [linux/s390x 1/7] FROM docker.io/library/nginx:1.23.1-alpine@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74 16.6s
=> => resolve docker.io/library/nginx:1.23.1-alpine@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74 0.2s
=> => sha256:c0c31323e703cfb1d34a17b36ed34ec861ebca64456df78fa0d15bec2f5be9f0 668B / 668B 1.0s
=> => sha256:d32f89bca1cf94c7b19f588ac82e45e8af34bd9a91a059feb923d175c479ea3c 1.40kB / 1.40kB 1.3s
=> => sha256:e43502f67f01a5a29cb7ac82c8a96077c885169a207c4c326d14f039ecb95067 895B / 895B 0.8s
=> => sha256:a4e0fa4eb76309e1ed501a3d63419a2708c053b4f4724e7c30ec672d175f2117 601B / 601B 0.4s
=> => sha256:373b7d4d3b16681685a0856a94a84738930af96fddce400c0811e09ba10ff344 7.32MB / 7.32MB 11.7s
=> => sha256:790c84f1f3409eab952345157df7fa804ba6b5f06d4ceb6f2dfa3c6de2064397 2.59MB / 2.59MB 9.5s
=> => extracting sha256:790c84f1f3409eab952345157df7fa804ba6b5f06d4ceb6f2dfa3c6de2064397 0.2s
=> => extracting sha256:373b7d4d3b16681685a0856a94a84738930af96fddce400c0811e09ba10ff344 0.7s
=> => extracting sha256:a4e0fa4eb76309e1ed501a3d63419a2708c053b4f4724e7c30ec672d175f2117 0.0s
=> => extracting sha256:e43502f67f01a5a29cb7ac82c8a96077c885169a207c4c326d14f039ecb95067 0.0s
=> => extracting sha256:c0c31323e703cfb1d34a17b36ed34ec861ebca64456df78fa0d15bec2f5be9f0 0.0s
=> => extracting sha256:d32f89bca1cf94c7b19f588ac82e45e8af34bd9a91a059feb923d175c479ea3c 0.0s
=> [linux/386 1/7] FROM docker.io/library/nginx:1.23.1-alpine@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74 23.1s
=> => resolve docker.io/library/nginx:1.23.1-alpine@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74 0.2s
=> => sha256:d98bd6b1812efebcbcd7ea0d33a1e7d97133c035eefc4a600de73b92e5ff3377 668B / 668B 0.2s
=> => sha256:1e585aed483ea0f9278296376df988071b3c60fee4f959ec841184d8acabc6f2 1.40kB / 1.40kB 0.2s
=> => sha256:b0f21039ca2e0f9f64ea059db3e44308e45502527c073080d2754c9884637e4e 893B / 893B 0.2s
=> => sha256:8ee07030d0e457ce0086ed25b559a07bf26d8bbcf90ba36fb7009c40665bbf2b 603B / 603B 0.2s
=> => sha256:7554fc233b7fc34d01374cb9387550560a772e686ef1fb694bb36ee2e5f6a492 7.88MB / 7.88MB 20.2s
=> => sha256:6c0d3b419d848ea31ca748254611d5d5ce3b76e3d7bba520fd87400fbb75f3b9 2.81MB / 2.81MB 8.1s
=> => extracting sha256:6c0d3b419d848ea31ca748254611d5d5ce3b76e3d7bba520fd87400fbb75f3b9 0.3s
=> => extracting sha256:7554fc233b7fc34d01374cb9387550560a772e686ef1fb694bb36ee2e5f6a492 0.7s
=> => extracting sha256:8ee07030d0e457ce0086ed25b559a07bf26d8bbcf90ba36fb7009c40665bbf2b 0.1s
=> => extracting sha256:b0f21039ca2e0f9f64ea059db3e44308e45502527c073080d2754c9884637e4e 0.0s
=> => extracting sha256:d98bd6b1812efebcbcd7ea0d33a1e7d97133c035eefc4a600de73b92e5ff3377 0.0s
=> => extracting sha256:1e585aed483ea0f9278296376df988071b3c60fee4f959ec841184d8acabc6f2 0.0s
=> [linux/arm/v6 1/7] FROM docker.io/library/nginx:1.23.1-alpine@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74 53.7s
=> => resolve docker.io/library/nginx:1.23.1-alpine@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74 0.2s
=> => sha256:a9f836315f345f6936fff793be0c73be717b733144cd3b5b0c7002495fd8a7e6 1.40kB / 1.40kB 0.3s
=> => sha256:89fdfff1a2cebe51c369db78ff9e712b4700d2d89412a96429533c1b46e075e4 895B / 895B 0.6s
=> => sha256:1c99366acb1d48f421bb842ca694cf9babb31fa3d1f2d5553848dafa4c60f6f2 667B / 667B 0.4s
=> => sha256:26792532ccfad8bb213635b9c68d86659ac9627c71ea89a17d7ed330e4b5718a 601B / 601B 0.3s
=> => sha256:de1535b5de7d073c92dd0cd51628cb3862ff7177407102cae7add335e573b684 7.10MB / 7.10MB 35.7s
=> => sha256:9506b835437abb4d8ba1683e00c500b8f77e1975e930b356fbb72f2dbdc274d9 2.61MB / 2.61MB 7.4s
=> => extracting sha256:9506b835437abb4d8ba1683e00c500b8f77e1975e930b356fbb72f2dbdc274d9 0.2s
=> => extracting sha256:de1535b5de7d073c92dd0cd51628cb3862ff7177407102cae7add335e573b684 0.6s
=> => extracting sha256:26792532ccfad8bb213635b9c68d86659ac9627c71ea89a17d7ed330e4b5718a 0.0s
=> => extracting sha256:89fdfff1a2cebe51c369db78ff9e712b4700d2d89412a96429533c1b46e075e4 0.0s
=> => extracting sha256:1c99366acb1d48f421bb842ca694cf9babb31fa3d1f2d5553848dafa4c60f6f2 0.0s
=> => extracting sha256:a9f836315f345f6936fff793be0c73be717b733144cd3b5b0c7002495fd8a7e6 0.0s
=> [linux/amd64 1/7] FROM docker.io/library/nginx:1.23.1-alpine@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74 135.3s
=> => resolve docker.io/library/nginx:1.23.1-alpine@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74 0.2s
=> => sha256:9a1e8d85723aa657f9eefde367fa01a844eeca2091d75fa118b49bbd567d3dc4 666B / 666B 0.4s
=> => sha256:5056d2fafbf237305281e02d3dd64601e2c86c45773ab3b7816f47e3bd2024be 1.39kB / 1.39kB 0.6s
=> => sha256:56424afbb509680a28e24aadb5bd354a0421ca0c0da8531309116637b2c23a53 894B / 894B 0.5s
=> => sha256:f294ffcdfaa8b9d8bf8c0995661ad4cf4f185587cc2313a8cc4b9afc6bb9a6ee 602B / 602B 0.5s
=> => sha256:6779501a69bab3ee492a189f6bf25b1bde2a9e879b133b1f3ce1591c31cb11a1 7.39MB / 7.39MB 103.4s
=> => sha256:213ec9aee27d8be045c6a92b7eac22c9a64b44558193775a1a7f626352392b49 2.81MB / 2.81MB 48.7s
=> => extracting sha256:213ec9aee27d8be045c6a92b7eac22c9a64b44558193775a1a7f626352392b49 0.2s
=> => extracting sha256:6779501a69bab3ee492a189f6bf25b1bde2a9e879b133b1f3ce1591c31cb11a1 0.6s
=> => extracting sha256:f294ffcdfaa8b9d8bf8c0995661ad4cf4f185587cc2313a8cc4b9afc6bb9a6ee 0.0s
=> => extracting sha256:56424afbb509680a28e24aadb5bd354a0421ca0c0da8531309116637b2c23a53 0.0s
=> => extracting sha256:9a1e8d85723aa657f9eefde367fa01a844eeca2091d75fa118b49bbd567d3dc4 0.0s
=> => extracting sha256:5056d2fafbf237305281e02d3dd64601e2c86c45773ab3b7816f47e3bd2024be 0.0s
=> [linux/ppc64le 1/7] FROM docker.io/library/nginx:1.23.1-alpine@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74 134.3s
=> => resolve docker.io/library/nginx:1.23.1-alpine@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74 0.2s
=> => sha256:c947c2dd2a2ac5b7227934fc0af1d59ed64a1e47669fded9d3b94bae29527a24 1.39kB / 1.39kB 0.2s
=> => sha256:75063bee2ecc814ee06dc2596cc0d197711e4f95dda90aec74ee3919c05313ea 894B / 894B 0.4s
=> => sha256:1f888da15041859b6e4752cea141a39a815847350a888a9a9ed9a356d0b1d0d3 666B / 666B 0.7s
=> => sha256:3ad5206fcb85442b0bdffa8b98efc2d673c5e72d13e2a41f155beed2246f560a 601B / 601B 0.4s
=> => sha256:227a9f16f4ebf1c6ebe45927973d6699cab82ccb0ad03ada687080e9aef57b97 7.72MB / 7.72MB 109.4s
=> => sha256:c79e5d1a8c89b87020a754c8a5c8370faaa37bfb5bca1d8af66770d522ef1caf 2.80MB / 2.80MB 8.1s
=> => extracting sha256:c79e5d1a8c89b87020a754c8a5c8370faaa37bfb5bca1d8af66770d522ef1caf 0.3s
=> => extracting sha256:227a9f16f4ebf1c6ebe45927973d6699cab82ccb0ad03ada687080e9aef57b97 0.7s
=> => extracting sha256:3ad5206fcb85442b0bdffa8b98efc2d673c5e72d13e2a41f155beed2246f560a 0.0s
=> => extracting sha256:75063bee2ecc814ee06dc2596cc0d197711e4f95dda90aec74ee3919c05313ea 0.0s
=> => extracting sha256:1f888da15041859b6e4752cea141a39a815847350a888a9a9ed9a356d0b1d0d3 0.0s
=> => extracting sha256:c947c2dd2a2ac5b7227934fc0af1d59ed64a1e47669fded9d3b94bae29527a24 0.0s
=> [linux/arm64 1/7] FROM docker.io/library/nginx:1.23.1-alpine@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74 138.7s
=> => resolve docker.io/library/nginx:1.23.1-alpine@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74 0.2s
=> => sha256:f4555f21bc2373ee9df51434b728987be7dd8d79af3b7eb4638ad01438c04d4b 1.40kB / 1.40kB 2.1s
=> => sha256:25335db77b7b2778010d1c00f309ad8addedc0c379834ead2080fcfecda2c8cd 667B / 667B 0.7s
=> => sha256:2559dc84f9d03b5cda6a84604553f32bc131e4cc2dcc3cf3c350d337d81a6c03 894B / 894B 0.6s
=> => sha256:7c5926dd2d26daf8afbddcf82c37158c5e3c791959b612ed017336026088222f 603B / 603B 0.4s
=> => sha256:9b18e9b68314027565b90ff6189d65942c0f7986da80df008b8431276885218e 2.71MB / 2.71MB 23.7s
=> => extracting sha256:9b18e9b68314027565b90ff6189d65942c0f7986da80df008b8431276885218e 0.2s
=> => sha256:d9111b1cfaed10fc9c5af1549ee01ff5c830298b737b71d05bf6c2f39c950499 7.29MB / 7.29MB 57.4s
=> => extracting sha256:d9111b1cfaed10fc9c5af1549ee01ff5c830298b737b71d05bf6c2f39c950499 0.6s
=> => extracting sha256:7c5926dd2d26daf8afbddcf82c37158c5e3c791959b612ed017336026088222f 0.0s
=> => extracting sha256:2559dc84f9d03b5cda6a84604553f32bc131e4cc2dcc3cf3c350d337d81a6c03 0.0s
=> => extracting sha256:25335db77b7b2778010d1c00f309ad8addedc0c379834ead2080fcfecda2c8cd 0.0s
=> => extracting sha256:f4555f21bc2373ee9df51434b728987be7dd8d79af3b7eb4638ad01438c04d4b 0.0s
=> [linux/s390x 2/7] RUN apk update && apk add --no-cache "nodejs>=16.17.1-r0" 44.9s
=> [linux/386 2/7] RUN apk update && apk add --no-cache "nodejs>=16.17.1-r0" 88.0s
=> [linux/arm/v7 2/7] RUN apk update && apk add --no-cache "nodejs>=16.17.1-r0" 94.0s
=> [linux/arm/v6 2/7] RUN apk update && apk add --no-cache "nodejs>=16.17.1-r0" 79.0s
=> [linux/s390x 3/7] COPY --chown=nginx:nginx --chmod=0666 ./docker/nginx.conf ./docker/cors.conf /etc/nginx/ 0.1s
=> [linux/s390x 4/7] COPY --chmod=0666 ./dist/* /usr/share/nginx/html/ 0.2s
=> [linux/s390x 5/7] COPY --chmod=0555 ./docker/docker-entrypoint.d/ /docker-entrypoint.d/ 0.1s
=> [linux/s390x 6/7] COPY --chmod=0666 ./docker/configurator /usr/share/nginx/configurator 0.1s
=> [linux/s390x 7/7] RUN chmod 777 /usr/share/nginx/html/ /etc/nginx/ /var/cache/nginx/ /var/run/ 0.3s
=> [linux/386 3/7] COPY --chown=nginx:nginx --chmod=0666 ./docker/nginx.conf ./docker/cors.conf /etc/nginx/ 0.1s
=> [linux/386 4/7] COPY --chmod=0666 ./dist/* /usr/share/nginx/html/ 0.1s
=> [linux/386 5/7] COPY --chmod=0555 ./docker/docker-entrypoint.d/ /docker-entrypoint.d/ 0.1s
=> [linux/386 6/7] COPY --chmod=0666 ./docker/configurator /usr/share/nginx/configurator 0.1s
=> [linux/386 7/7] RUN chmod 777 /usr/share/nginx/html/ /etc/nginx/ /var/cache/nginx/ /var/run/ 0.3s
=> [linux/arm/v7 3/7] COPY --chown=nginx:nginx --chmod=0666 ./docker/nginx.conf ./docker/cors.conf /etc/nginx/ 0.1s
=> [linux/arm/v7 4/7] COPY --chmod=0666 ./dist/* /usr/share/nginx/html/ 0.1s
=> [linux/arm/v7 5/7] COPY --chmod=0555 ./docker/docker-entrypoint.d/ /docker-entrypoint.d/ 0.1s
=> [linux/arm/v7 6/7] COPY --chmod=0666 ./docker/configurator /usr/share/nginx/configurator 0.1s
=> [linux/arm/v7 7/7] RUN chmod 777 /usr/share/nginx/html/ /etc/nginx/ /var/cache/nginx/ /var/run/ 0.3s
=> [linux/arm/v6 3/7] COPY --chown=nginx:nginx --chmod=0666 ./docker/nginx.conf ./docker/cors.conf /etc/nginx/ 0.1s
=> [linux/arm/v6 4/7] COPY --chmod=0666 ./dist/* /usr/share/nginx/html/ 0.1s
=> [linux/arm/v6 5/7] COPY --chmod=0555 ./docker/docker-entrypoint.d/ /docker-entrypoint.d/ 0.1s
=> [linux/arm/v6 6/7] COPY --chmod=0666 ./docker/configurator /usr/share/nginx/configurator 0.1s
=> [linux/arm/v6 7/7] RUN chmod 777 /usr/share/nginx/html/ /etc/nginx/ /var/cache/nginx/ /var/run/ 0.3s
=> [linux/ppc64le 2/7] RUN apk update && apk add --no-cache "nodejs>=16.17.1-r0" 33.0s
=> [linux/amd64 2/7] RUN apk update && apk add --no-cache "nodejs>=16.17.1-r0" 17.8s
=> [linux/arm64 2/7] RUN apk update && apk add --no-cache "nodejs>=16.17.1-r0" 28.5s
=> [linux/amd64 3/7] COPY --chown=nginx:nginx --chmod=0666 ./docker/nginx.conf ./docker/cors.conf /etc/nginx/ 0.1s
=> [linux/amd64 4/7] COPY --chmod=0666 ./dist/* /usr/share/nginx/html/ 0.1s
=> [linux/amd64 5/7] COPY --chmod=0555 ./docker/docker-entrypoint.d/ /docker-entrypoint.d/ 0.1s
=> [linux/amd64 6/7] COPY --chmod=0666 ./docker/configurator /usr/share/nginx/configurator 0.1s
=> [linux/amd64 7/7] RUN chmod 777 /usr/share/nginx/html/ /etc/nginx/ /var/cache/nginx/ /var/run/ 0.2s
=> [linux/arm64 3/7] COPY --chown=nginx:nginx --chmod=0666 ./docker/nginx.conf ./docker/cors.conf /etc/nginx/ 0.2s
=> [linux/ppc64le 3/7] COPY --chown=nginx:nginx --chmod=0666 ./docker/nginx.conf ./docker/cors.conf /etc/nginx/ 0.2s
=> [linux/arm64 4/7] COPY --chmod=0666 ./dist/* /usr/share/nginx/html/ 0.2s
=> [linux/ppc64le 4/7] COPY --chmod=0666 ./dist/* /usr/share/nginx/html/ 0.2s
=> [linux/arm64 5/7] COPY --chmod=0555 ./docker/docker-entrypoint.d/ /docker-entrypoint.d/ 0.2s
=> [linux/ppc64le 5/7] COPY --chmod=0555 ./docker/docker-entrypoint.d/ /docker-entrypoint.d/ 0.2s
=> [linux/arm64 6/7] COPY --chmod=0666 ./docker/configurator /usr/share/nginx/configurator 0.1s
=> [linux/ppc64le 6/7] COPY --chmod=0666 ./docker/configurator /usr/share/nginx/configurator 0.2s
=> [linux/arm64 7/7] RUN chmod 777 /usr/share/nginx/html/ /etc/nginx/ /var/cache/nginx/ /var/run/ 0.3s
=> [linux/ppc64le 7/7] RUN chmod 777 /usr/share/nginx/html/ /etc/nginx/ /var/cache/nginx/ /var/run/
This gives us recipe how to setup docker on Jenkins to be able to build and push multiarch images. I'll keep you posted about further developement.
Right, I have a bit bad news. Our current Jenkins CICD pipeline is not able to build multiarch images - there are multitude of reasons I won't bother you with those.
So I was thinking about the possible alternative - utilize a GitHub Actions that will detect that Jenkins has pushed a new tag with single arch image to the dockerhub, build a new multiarch image and push it to the dockerhub.
Docker tags are mutable, and this fact allow us to re-push the multiarch image. One thing that we need to be aware of is that we cannot change the image digest
, or at least we shouldn't. I need to do some testing to figure out the digest part and will keep you updated.
Any progress now?
In case this can help, I've just built amd64 / arm64 images for the last couple of versions of the v3 and v4 families. The images are in lucj/swagger-ui. Do not hesitate to tell me if there are working fine. I'll make sure to automate the process and have a new image created after each new official swagger-ui release. That's a pity a little hack has not been done before on the official repo with a GitHub Action for instance :( Example of a sample Github action I use to build multiarch images for a little project ArgoCD Helmfile Plugin
Hi everybody,
Here is the update:
Right, I have a bit bad news. Our current Jenkins CICD pipeline is not able to build multiarch images - there are multitude of reasons I won't bother you with those.
We're still constrained with this.
Docker tags are mutable, and this fact allow us to re-push the multiarch image. One thing that we need to be aware of is that we cannot change the image digest, or at least we shouldn't. I need to do some testing to figure out the digest part and will keep you updated.
This proved to be false assumption. The digest will change with re-push. To solve this I'm proposing the following:
Introduce unprivileged + multi platform docker image
This has already been introduced for SwaggerEditor. We can introduce unprivileged
+ multi platform
docker image for SwaggerUI as well. This will two birds with one stone. By exposing unprivileged version of the image, we would be able to run it with non-root privileged for example in Kubernetes cluster with runAsNonRoot: true
. We'll also make this image multi platform.
The difference between standard and unprivileged image will be in the base image:
Dockerfile (stadard)
FROM nginx:1.24.0-alpine
Dockerfile.unprivileged
FROM nginxinc/nginx-unprivileged:1.24.0-alpine
The docker tags will look like this after the change:
- v4.19.0
- v4.19.0-unprivileged (new unprivileged + multi platform tag)
- v5.0.0-alpha.13
- v5.0.0-alpha.13-unprivileged (new unprivileged + multi platform tag)
NOTE: Use templating as it's been used in SwaggerEditor@4 docker image.
GitHUB Action will handle build+push and will be triggered by GitHUB release event.
Question: does anybody has any objections against this solution or any reason why this shouldn't work?
it's relatively easy with GitHub Actions https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
there might be a clue in there how they achieve that, it seems to involve:
- push each individual arch build as untagged anonymous images using
push-by-digest
feature of repository https://github.com/moby/buildkit#imageregistry - after all arch images are pushed, download the digests and re-push the combined image to the desired name/tag
Hi @anentropic,
Thanks for the resources, checking if that's a viable option.
Again thank you very much @anentropic! I was able to build a GitHub action that creates multi platform image from single platform image. The digest
of the original platform image doesn't change. The action is available here:
# inspired by https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
name: Build & Push SwaggerUI multi platform Docker image
on:
workflow_dispatch:
inputs:
tag:
description: Git tag
type: string
required: true
env:
REGISTRY_IMAGE: swaggerapi/swagger-ui
jobs:
build:
name: Build & Push SwaggerUI platform specific Docker images
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
# linux/amd64 is already built by Jenkins
- linux/arm/v6
- linux/arm/v7
- linux/arm64/v8
- linux/386
- linux/ppc64le
- linux/s390x
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.tag }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY_IMAGE }}
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_SB_USERNAME }}
password: ${{ secrets.DOCKERHUB_SB_PASSWORD }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v4
with:
context: .
platforms: ${{ matrix.platform }}
provenance: false
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
name: Merge platform specific Docker image into multi platform image
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: digests
path: /tmp/digests
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_SB_USERNAME }}
password: ${{ secrets.DOCKERHUB_SB_PASSWORD }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ inputs.tag }} \
${{ env.REGISTRY_IMAGE }}:${{ inputs.tag }} \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ inputs.tag }}
I'll retrospectively add multi platform support for all previous v5 releases. I won't be adding multi platform support for v4 images. Next I'll make the action react to git tag
creation so that it runs automatically on every release.
latest
and unstable
tags needs to be handled as well.
Closing this one as the goal has been achieved. All v5 docker tags has been transformed to multi platform. I'll create a follow up tickets for handling latest
, unstable
and automatic multi platform builds on release. Thanks everybody!