Skip to content

Commit

Permalink
seperate depend and web
Browse files Browse the repository at this point in the history
  • Loading branch information
robkooper committed Aug 31, 2024
1 parent 54cd193 commit b6146de
Showing 1 changed file with 94 additions and 13 deletions.
107 changes: 94 additions & 13 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -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

Expand Down

0 comments on commit b6146de

Please sign in to comment.