diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml new file mode 100644 index 0000000..da98bd9 --- /dev/null +++ b/.github/workflows/build_docker.yml @@ -0,0 +1,98 @@ +name: Build Docker image +on: + push: + branches: ["main", "release-12_v1"] + tags: ["v*"] + +concurrency: docker + +jobs: + base_image: + name: Build Docker image + runs-on: ubuntu-latest + steps: + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/educelab/ci-docker + flavor: | + latest=false + tags: | + type=ref,prefix="base.",event=pr + type=semver,prefix="base.",pattern={{version}} + type=semver,prefix="base.",pattern={{major}}.{{minor}} + type=raw,prefix="base.",value=edge,enable={{is_default_branch}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build base image + uses: docker/build-push-action@v3 + with: + file: ./Dockerfile.base + push: ${{ github.event_name != 'pull_request' }} + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-to: type=gha,mode=max + cache-from: type=gha + + vcdeps_images: + name: Build Docker image + runs-on: ubuntu-latest + needs: base_image + strategy: + fail-fast: false + matrix: + type: ["static", "dynamic"] + steps: + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/educelab/ci-docker + flavor: | + latest=false + tags: | + type=ref,prefix="{{ matrix.type }}.",event=pr + type=semver,prefix="{{ matrix.type }}.",pattern={{version}} + type=semver,prefix="{{ matrix.type }}.",pattern={{major}}.{{minor}} + type=raw,value=edge,enable={{is_default_branch}} + type=raw,value=latest,enable={{ matrix.type == 'static' }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build base image + uses: docker/build-push-action@v3 + with: + file: ./Dockerfile.{{ matrix.type }} + push: ${{ github.event_name != 'pull_request' }} + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-to: type=gha,mode=max + cache-from: type=gha