build-radicle-httpd.yml
1 name: Build and Push radicle-httpd Container 2 3 on: 4 push: 5 paths: 6 - "infra/containers/radicle-httpd/**" 7 - ".github/workflows/build-radicle-httpd.yml" 8 workflow_dispatch: 9 inputs: 10 radicle_httpd_version: 11 description: "Radicle HTTPD version" 12 required: false 13 default: "" 14 alpine_version: 15 description: "Version of Alpine base image" 16 required: false 17 default: "" 18 19 concurrency: 20 group: ${{ github.workflow }}-${{ github.ref }} 21 cancel-in-progress: true 22 23 env: 24 REGISTRY: quay.io 25 IMAGE_NAME: radicle_garden/radicle-httpd 26 RADICLE_HTTPD_VERSION: "0.24.0" 27 ALPINE_VERSION: "3.23" 28 29 jobs: 30 build-and-push: 31 strategy: 32 fail-fast: false 33 matrix: 34 include: 35 - platform: linux/amd64 36 value: x86_64-unknown-linux-musl 37 runner: ubuntu-latest 38 - platform: linux/arm64 39 value: aarch64-unknown-linux-musl 40 runner: ubuntu-24.04-arm 41 runs-on: ${{ matrix.runner }} 42 outputs: 43 radicle_httpd_version: ${{ steps.version.outputs.RADICLE_HTTPD_VERSION }} 44 45 steps: 46 - name: Checkout repository 47 uses: actions/checkout@v6 48 49 - name: Prepare 50 run: | 51 platform=${{ matrix.platform }} 52 echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV 53 54 - name: Set up QEMU 55 uses: docker/setup-qemu-action@v3 56 57 - name: Set up Docker Buildx 58 uses: docker/setup-buildx-action@v3 59 60 - name: Log in to Quay.io 61 uses: docker/login-action@v3 62 with: 63 registry: ${{ env.REGISTRY }} 64 username: ${{ secrets.QUAY_USERNAME }} 65 password: ${{ secrets.QUAY_PASSWORD }} 66 67 - name: Set up metadata 68 id: meta 69 uses: docker/metadata-action@v5 70 with: 71 images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 72 73 - name: Set version 74 id: version 75 run: | 76 RADICLE_HTTPD_VERSION="${{ github.event.inputs.radicle_httpd_version }}" 77 if [ -z "$RADICLE_HTTPD_VERSION" ]; then 78 RADICLE_HTTPD_VERSION="${{ env.RADICLE_HTTPD_VERSION }}" 79 fi 80 echo "RADICLE_HTTPD_VERSION=$RADICLE_HTTPD_VERSION" >> $GITHUB_OUTPUT 81 82 ALPINE_VERSION="${{ github.event.inputs.alpine_version }}" 83 if [ -z "$ALPINE_VERSION" ]; then 84 ALPINE_VERSION="${{ env.ALPINE_VERSION }}" 85 fi 86 echo "ALPINE_VERSION=$ALPINE_VERSION" >> $GITHUB_OUTPUT 87 88 - name: Build and push 89 uses: docker/build-push-action@v6 90 id: build 91 with: 92 context: infra/containers/radicle-httpd 93 file: infra/containers/radicle-httpd/Containerfile 94 tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 95 labels: ${{ steps.meta.outputs.labels }} 96 build-args: | 97 RADICLE_HTTPD_VERSION=${{ steps.version.outputs.RADICLE_HTTPD_VERSION }} 98 ALPINE_VERSION=${{ steps.version.outputs.ALPINE_VERSION }} 99 PLATFORM=${{ matrix.value }} 100 cache-from: type=gha 101 cache-to: type=gha,mode=max 102 platforms: ${{ matrix.platform }} 103 outputs: type=image,push-by-digest=true,name-canonical=true,push=true 104 105 - name: Export digest 106 run: | 107 mkdir -p ${{ runner.temp }}/digests 108 digest="${{ steps.build.outputs.digest }}" 109 touch "${{ runner.temp }}/digests/${digest#sha256:}" 110 111 - name: Upload digest 112 uses: actions/upload-artifact@v6 113 with: 114 name: digests-${{ env.PLATFORM_PAIR }} 115 path: ${{ runner.temp }}/digests/* 116 if-no-files-found: error 117 retention-days: 1 118 119 merge: 120 runs-on: ubuntu-latest 121 needs: 122 - build-and-push 123 steps: 124 - name: Download digests 125 uses: actions/download-artifact@v7 126 with: 127 path: ${{ runner.temp }}/digests 128 pattern: digests-* 129 merge-multiple: true 130 131 - name: Log in to Quay.io 132 uses: docker/login-action@v3 133 with: 134 registry: ${{ env.REGISTRY }} 135 username: ${{ secrets.QUAY_USERNAME }} 136 password: ${{ secrets.QUAY_PASSWORD }} 137 138 - name: Set up Docker Buildx 139 uses: docker/setup-buildx-action@v3 140 141 - name: Extract metadata 142 id: meta 143 uses: docker/metadata-action@v5 144 with: 145 images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 146 tags: | 147 type=ref,event=branch 148 type=raw,value=${{ needs.build-and-push.outputs.radicle_httpd_version }}${{ matrix.suffix }} 149 type=raw,value=latest,enable={{is_default_branch}} 150 labels: | 151 quay.expires-after=${{ github.ref_name != 'main' && '7d' || '' }} 152 153 - name: Create manifest list and push 154 working-directory: ${{ runner.temp }}/digests 155 run: | 156 docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ 157 $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) 158 159 - name: Inspect image 160 run: | 161 docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}