Skip to content

Commit

Permalink
Create multi-arch images
Browse files Browse the repository at this point in the history
  • Loading branch information
jamezrin committed Oct 23, 2021
1 parent 8c70a39 commit 12389a8
Showing 1 changed file with 46 additions and 9 deletions.
55 changes: 46 additions & 9 deletions .github/workflows/build-images-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,61 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Create docker context
id: buildx-create-context
run: docker context create builders
- uses: docker/setup-buildx-action@v1
with:
buildkitd-flags: --debug
endpoint: builders
- name: Login to my Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- name: Create docker context
run: docker context create builders
- uses: docker/setup-buildx-action@v1
with:
buildkitd-flags: --debug
endpoint: builders
- name: Get package version
id: build_version
run: |
version=$(jq -r .version ./packages/${{ matrix.package }}/package.json)
echo "::set-output name=version::$version"
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: linux/${{ matrix.platform }}
file: ./packages/${{ matrix.package }}/Dockerfile
tags: ${{ env.REGISTRY }}/timeit-webapp/timeit-${{ matrix.package }}:latest
tags: ${{ env.REGISTRY }}/timeit-webapp/timeit-${{ matrix.package }}:${{ steps.build_version.outputs.version }}-${{ matrix.platform }}

create-manifest:
needs: [build-packages]
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
package: ['frontend', 'backend']
steps:
- uses: actions/checkout@v2
- name: Login to my Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- name: Get package version
id: build_version
run: |
version=$(jq -r .version ./packages/${{ matrix.package }}/package.json)
echo "::set-output name=version::$version"
- name: Create manifest
run: |
docker manifest create ${{ env.REGISTRY }}/timeit-webapp/timeit-${{ matrix.package }}:${{ steps.build_version.outputs.version }} \
--amend ${{ env.REGISTRY }}/timeit-webapp/timeit-${{ matrix.package }}:${{ steps.build_version.outputs.version }}-arm64 \
--amend ${{ env.REGISTRY }}/timeit-webapp/timeit-${{ matrix.package }}:${{ steps.build_version.outputs.version }}-amd64
docker manifest push ${{ env.REGISTRY }}/timeit-webapp/timeit-${{ matrix.package }}:${{ steps.build_version.outputs.version }}
- name: Tag to latest
run: |
docker tag ${{ env.REGISTRY }}/timeit-webapp/timeit-${{ matrix.package }}:${{ steps.build_version.outputs.version }} \
${{ env.REGISTRY }}/timeit-webapp/timeit-${{ matrix.package }}:latest
docker push ${{ env.REGISTRY }}/timeit-webapp/timeit-${{ matrix.package }}:latest

0 comments on commit 12389a8

Please sign in to comment.