-
-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GitHub action for automatic multiarch Docker build #1613
Merged
neilalexander
merged 9 commits into
matrix-org:master
from
TR-SLimey:ci_multiarch_build_and_push
Jan 18, 2021
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
78b2977
Create docker-build-and-push.yml
TR-SLimey 91ff02d
Merge branch 'master' into ci_multiarch_build_and_push
TR-SLimey 42fc241
Switched to using official Docker buildx action
TR-SLimey a5dfeb6
Added comment to docker-build-and-push.yml
TR-SLimey 794e8dc
Merge branch 'master' into ci_multiarch_build_and_push
TR-SLimey f8de73e
Merge branch 'master' into ci_multiarch_build_and_push
TR-SLimey cd65916
Run only on release (and produce release tags)
TR-SLimey 0a080dd
Merge branch 'master' into ci_multiarch_build_and_push
neilalexander 5e95cdc
Add latest tag, test at neilalexander/dendrite*
neilalexander File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Based on https://github.com/docker/build-push-action | ||
|
||
name: "Docker Multiarch Build & Push" | ||
|
||
on: | ||
release: | ||
# types: [published] | ||
branches: [master] | ||
|
||
env: | ||
DOCKER_HUB_USER: neilalexander | ||
|
||
jobs: | ||
BuildAndPush: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
- | ||
name: Get release tag | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- | ||
name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ env.DOCKER_HUB_USER }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
- | ||
name: Build temporary (builder) image | ||
id: docker_build_temporary | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./build/docker/Dockerfile | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7 | ||
push: false | ||
tags: ${{ env.DOCKER_HUB_USER }}/dendrite:latest | ||
- | ||
name: Build monolith image | ||
id: docker_build_monolith | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./build/docker/Dockerfile.monolith | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7 | ||
push: true | ||
tags: | | ||
${{ env.DOCKER_HUB_USER }}/dendrite-monolith:latest | ||
${{ env.DOCKER_HUB_USER }}/dendrite-monolith:${{ env.RELEASE_VERSION }} | ||
- | ||
name: Build polylith image | ||
id: docker_build_polylith | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./build/docker/Dockerfile.polylith | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7 | ||
push: true | ||
tags: | | ||
${{ env.DOCKER_HUB_USER }}/dendrite-polylith:latest | ||
${{ env.DOCKER_HUB_USER }}/dendrite-polylith:${{ env.RELEASE_VERSION }} | ||
- | ||
name: Image digest | ||
run: | | ||
echo Monolith ( ${{ env.RELEASE_VERSION }} ) image digest - ${{ steps.docker_build_monolith.outputs.digest }} | ||
echo Polylith ( ${{ env.RELEASE_VERSION }} ) image digest - ${{ steps.docker_build_polylith.outputs.digest }} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why are we calling this a temporary builder image?
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.
From what I've gathered, that's the image which contains the go toolchain and which builds Dendrite, and only the binaries get copied to the actual monolith and polylith images (to save space I believe - Neil mentioned this somewhere), while this image is just discarded, hence it is temporary and a builder. That's mostly just from a quick glance at the
Dockerfile
s though so I may be wrong.EDIT: Having checked, I also can't find the
dendrite
image in matrixdotorg's docker repo (only the-monolith
and-polylith
ones) so it does indeed seem temporary.EDIT 2: As for testing, I think the easiest way is to just (1) fork Dendrite, (2) paste this into the correct file replacing
matrixdotorg
with a test user, (3) create a token for the test user, (4) create a dummy release.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.
Cool OK, and thanks for the info. Do you want to try that testing strategy? Otherwise I can do so sometime tomorrow possibly.
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.
I've done those tests already on my fork ( I'm nowhere near confident enough to open a PR without testing :P ), and it seemed to work pretty well, but I think it might be good for you to test also, to avoid "works on my end" kinds of bugs :P