-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Docker image: Multi arch support #7397
Changes from all commits
c195eaa
0a55a79
1433c17
c5047c8
07a64a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
version: 2 | ||
version: 2.1 | ||
jobs: | ||
dockerhubuploadrelease: | ||
machine: true | ||
docker: | ||
- image: docker:git | ||
steps: | ||
- checkout | ||
- run: docker build -f docker/Dockerfile --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:${CIRCLE_TAG} -t matrixdotorg/synapse:${CIRCLE_TAG}-py3 . | ||
- setup_remote_docker: | ||
version: 18.09.3 | ||
- docker_prepare | ||
- run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD | ||
- run: docker push matrixdotorg/synapse:${CIRCLE_TAG} | ||
- run: docker push matrixdotorg/synapse:${CIRCLE_TAG}-py3 | ||
- docker_build: | ||
parameters: --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:${CIRCLE_TAG} -t matrixdotorg/synapse:${CIRCLE_TAG}-py3 | ||
|
||
dockerhubuploadlatest: | ||
machine: true | ||
docker: | ||
- image: docker:git | ||
steps: | ||
- checkout | ||
- run: docker build -f docker/Dockerfile --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:latest -t matrixdotorg/synapse:latest-py3 . | ||
- setup_remote_docker: | ||
version: 18.09.3 | ||
- docker_prepare | ||
- run: docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD | ||
- run: docker push matrixdotorg/synapse:latest | ||
- run: docker push matrixdotorg/synapse:latest-py3 | ||
- docker_build: | ||
parameters: --label gitsha1=${CIRCLE_SHA1} -t matrixdotorg/synapse:latest -t matrixdotorg/synapse:latest-py3 | ||
|
||
workflows: | ||
version: 2 | ||
build: | ||
jobs: | ||
- dockerhubuploadrelease: | ||
|
@@ -31,3 +37,40 @@ workflows: | |
filters: | ||
branches: | ||
only: master | ||
|
||
commands: | ||
docker_prepare: | ||
description: Downloads the buildx cli plugin and enables multiarch execution | ||
parameters: | ||
buildx_version: | ||
type: string | ||
default: "v0.4.1" | ||
steps: | ||
- run: apk add --no-cache curl | ||
- run: mkdir -vp ~/.docker/cli-plugins/ ~/dockercache | ||
- run: curl --silent -L "https://github.com/docker/buildx/releases/download/<< parameters.buildx_version >>/buildx-<< parameters.buildx_version >>.linux-amd64" > ~/.docker/cli-plugins/docker-buildx | ||
- run: chmod a+x ~/.docker/cli-plugins/docker-buildx | ||
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | ||
- run: docker context create old-style | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is the context called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name could be anything, but it was often called |
||
- run: docker buildx create old-style --use | ||
|
||
docker_build: | ||
description: Builds and pushed images to dockerhub using buildx | ||
parameters: | ||
dockerfile: | ||
type: string | ||
default: docker/Dockerfile | ||
push: | ||
type: boolean | ||
default: true | ||
Comment on lines
+60
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there any point in parameterising these? it seems to complicate the commandline without any real benefit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, not at this moment. I added these parameters so one could easily expand the pipeline. I can remove the unused parameters. |
||
platforms: | ||
type: string | ||
default: linux/arm64/v8,linux/amd64 | ||
context: | ||
type: string | ||
default: . | ||
parameters: | ||
type: string | ||
default: --label gitsha1=${CIRCLE_SHA1} | ||
steps: | ||
- run: docker buildx build -f << parameters.dockerfile >><<# parameters.push >> --push<</ parameters.push >> --platform << parameters.platforms >> << parameters.parameters >> << parameters.context >> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the default output format does not work well in circleci. suggest |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Build multi-arch docker images. Contributed by @Starbix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to pin the docker version here? Indeed my impression is that
buildx
works better with 19.03?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not responding earlier, I wasn't near a computer for the last 2 weeks.
If I remember correctly, 18.09 is the highest version CircleCI supports and it defaulted to a lower version.
A higher version would be beneficial, as there wouldn't be a need to create context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newest version available seems to be 19.03 now: https://circleci.com/docs/2.0/building-docker-images/#docker-version
I'll be able to test it and make the other changes this week.