This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
try vz vm type #45
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
name: Build and Publish Docker images | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
env: | |
ERLANG_MAJOR: "26" | |
ERLANG: "26.1.1" | |
OS_VERSION: "3.18.4" | |
ELIXIR: "1.15.6" | |
IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/elixir | |
jobs: | |
build: | |
strategy: | |
matrix: | |
include: | |
- runner: ubuntu-22.04-firezone | |
platform: linux/amd64 | |
- runner: macos-13-xlarge | |
platform: linux/arm64 | |
runs-on: ${{ matrix.runner }} | |
steps: | |
- name: Setup Docker on macOS | |
if: matrix.runner == 'macos-13-xlarge' | |
run: | | |
brew install colima docker docker-buildx | |
mkdir -p ~/.docker/cli-plugins | |
ln -sfn $(which docker-buildx) ~/.docker/cli-plugins/docker-buildx | |
docker buildx install | |
colima start --runtime docker --vm-type=vz | |
echo DOCKER_HOST="unix:///${HOME}/.colima/default/docker.sock" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- uses: actions/checkout@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.IMAGE }} | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
id: build | |
with: | |
push: true | |
file: Dockerfile | |
platforms: ${{ matrix.platform }} | |
build-args: | | |
ELIXIR=${{ env.ELIXIR }} | |
ERLANG_MAJOR=${{ env.ERLANG_MAJOR }} | |
OS_VERSION=${{ env.OS_VERSION }} | |
ERLANG=${{ env.ERLANG }} | |
labels: ${{ steps.meta.outputs.labels }} | |
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true | |
cache-from: type=registry,ref=${{ env.IMAGE }}:${{ env.ELIXIR }}-otp-${{ env.ERLANG }} | |
cache-to: type=registry,ref=${{ env.IMAGE }}:${{ env.ELIXIR }}-otp-${{ env.ERLANG }} | |
- 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: | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.IMAGE }} | |
- name: Download digests | |
uses: actions/download-artifact@v3 | |
with: | |
name: digests | |
path: /tmp/digests | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Create manifest list and push | |
working-directory: /tmp/digests | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.IMAGE }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.IMAGE }}:${{ steps.meta.outputs.version }} |