Trying to use alpine toolchain on Docker #50
Workflow file for this run
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 container image | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- 'musubi.moe/main' | |
- 'musubi.moe/develop' | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+\+musubi-moe*' | |
paths: | |
- .github/workflows/build-image.yml | |
- Dockerfile | |
- src/**.rs | |
pull_request: | |
paths: | |
- .github/workflows/build-image.yml | |
- Dockerfile | |
- src/**.rs | |
permissions: | |
contents: read | |
packages: write | |
env: | |
DOCKER_IMAGE: ghcr.io/${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
docker-platforms: ['linux/amd64', 'linux/arm64'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: ${{ matrix.docker-platforms }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to the GitHub Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
if: github.event_name != 'pull_request' | |
- run: echo "DOCKER_IMAGE=${DOCKER_IMAGE,,}" >>${GITHUB_ENV} # repository name must be lowercase | |
- name: Generate Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.DOCKER_IMAGE }} | |
- name: Build and push by digest | |
id: build | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: docker/Dockerfile | |
platforms: ${{ matrix.docker-platforms }} | |
cache-from: type=gha,scope=$GITHUB_REF_NAME/${{ matrix.docker-platforms }} | |
cache-to: type=gha,scope=$GITHUB_REF_NAME/${{ matrix.docker-platforms }},mode=max | |
labels: ${{ steps.meta.outputs.labels }} | |
outputs: type=image,name=${{ env.DOCKER_IMAGE }},push-by-digest=${{ github.event_name != 'pull_request' }},name-canonical=true,push=${{ github.event_name != 'pull_request' }} | |
- name: Export digest | |
run: | | |
export DIGESTS_PATH="$RUNNER_TEMP/$(uuidgen)/digests" | |
echo "DIGESTS_PATH=$DIGESTS_PATH" >>${GITHUB_ENV} | |
mkdir -p $DIGESTS_PATH | |
digest="${{ steps.build.outputs.digest }}" | |
touch "$DIGESTS_PATH/${digest#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v3 | |
with: | |
name: digests | |
path: ${{ env.DIGESTS_PATH }}/* | |
if-no-files-found: error | |
retention-days: 1 | |
mix: | |
if: github.event_name != 'pull_request' | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create DIGESTS_PATH | |
run: | | |
export DIGESTS_PATH="$RUNNER_TEMP/$(uuidgen)/digests" | |
echo "DIGESTS_PATH=$DIGESTS_PATH" >>${GITHUB_ENV} | |
- name: Download digests | |
uses: actions/download-artifact@v3 | |
with: | |
name: digests | |
path: ${{ env.DIGESTS_PATH }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to the GitHub Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
if: github.event_name != 'pull_request' | |
- run: echo "DOCKER_IMAGE=${DOCKER_IMAGE,,}" >>${GITHUB_ENV} # repository name must be lowercase | |
- name: Generate Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.DOCKER_IMAGE }} | |
flavor: | | |
latest=auto | |
tags: | | |
type=edge,branch=musubi.moe/main | |
type=edge,branch=musubi.moe/develop | |
type=semver,pattern={{raw}} | |
type=ref,event=pr | |
- name: Create manifest list and push | |
working-directory: ${{ env.DIGESTS_PATH }} | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.DOCKER_IMAGE }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} |