diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b00a816ae9..2e85498dd0 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -39,23 +39,14 @@ jobs: matrix: name: - depends - - web - - dbsync include: - name: depends + CONTEXT: docker/depends + DOCKERFILE: Dockerfile # no arm images for tidyverse, see # https://github.com/rocker-org/rocker-versioned2/issues/830 PLATFORM: "linux/amd64" - DOCKERFILE: docker/web/Dockerfile IMAGE: depends - - name: web - PLATFORM: "linux/amd64,linux/arm64" - DOCKERFILE: docker/web/Dockerfile - IMAGE: web - - name: dbsync - PLATFORM: "linux/amd64,linux/arm64" - DOCKERFILE: docker/web/Dockerfile - IMAGE: shiny-dbsync steps: - uses: actions/checkout@v4 @@ -112,7 +103,8 @@ jobs: - name: Build and push depends uses: docker/build-push-action@v6 with: - context: docker/depends + context: ${{ matrix.CONTEXT }} + file: ${{ matrix.DOCKERFILE }} #push: ${{ github.event_name != 'pull_request' }} #push: true platforms: ${{ matrix.PLATFORM }} @@ -127,12 +119,101 @@ jobs: # upload depends image to be used in other steps - name: Upload artifact - if: ${{ matrix.IMAGE == 'depends' }} uses: actions/upload-artifact@v4 with: name: ${{ matrix.IMAGE }} path: /tmp/${{ matrix.IMAGE }}.tar + web: + runs-on: ubuntu-latest + permissions: + packages: write + strategy: + fail-fast: false + matrix: + name: + - web + - dbsync + include: + - name: web + CONTEXT: . + DOCKERFILE: docker/web/Dockerfile + PLATFORM: "linux/amd64,linux/arm64" + IMAGE: web + - name: dbsync + CONTEXT: . + DOCKERFILE: shiny/dbsync/Dockerfile + PLATFORM: "linux/amd64,linux/arm64" + IMAGE: shiny-dbsync + + steps: + - uses: actions/checkout@v4 + + # create metadata for image + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + pecan/${{ matrix.IMAGE }} + ghcr.io/${{ github.repository_owner }}/${{ matrix.IMAGE }} + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + # setup docker build + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Inspect Builder + run: | + echo "Name: ${{ steps.buildx.outputs.name }}" + echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" + echo "Status: ${{ steps.buildx.outputs.status }}" + echo "Flags: ${{ steps.buildx.outputs.flags }}" + echo "Platforms: ${{ steps.buildx.outputs.platforms }}" + + # login to registries + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # build the docker images + - name: Build and push depends + uses: docker/build-push-action@v6 + with: + context: ${{ matrix.CONTEXT }} + file: ${{ matrix.DOCKERFILE }} + #push: ${{ github.event_name != 'pull_request' }} + #push: true + platforms: ${{ matrix.PLATFORM }} + cache-from: type=registry,ref=pecan/${{ matrix.IMAGE }}:buildcache + cache-to: type=registry,ref=pecan/${{ matrix.IMAGE }}:buildcache,mode=max + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ steps.meta.outputs.version }} + R_VERSION=${{ env.R_VERSION }} + # depends: # name: Docker