-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Github Actions to build Docker images (#94)
* Add Github Actions to build Docker images * Split into separate workflows * Fix path filters
- Loading branch information
Showing
3 changed files
with
154 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Jupyterhub Docker Build and Deploy | ||
|
||
on: | ||
release: | ||
types: [published] | ||
push: | ||
branches: | ||
- "main" | ||
paths: | ||
- 'docker/jupyterhub/**' | ||
- '.github/workflows/jupyterhub-docker-build-and-deploy.yml' | ||
pull_request: | ||
paths: | ||
- 'docker/jupyterhub/**' | ||
- '.github/workflows/jupyterhub-docker-build-and-deploy.yml' | ||
|
||
env: | ||
REGISTRY: europe-north1-docker.pkg.dev/artifact-registry-5n/dapla-stat-docker/jupyter | ||
TAG: ${{ github.ref_name }}-${{ github.sha }} | ||
IMAGE_PREFIX: on-prem- | ||
NAME: jupyterhub | ||
|
||
jobs: | ||
docker: | ||
permissions: | ||
contents: "read" | ||
id-token: "write" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Check out repo" | ||
uses: actions/checkout@v3 | ||
- name: "Authenticate to Google Cloud" | ||
id: "auth" | ||
uses: "google-github-actions/[email protected]" | ||
with: | ||
workload_identity_provider: "projects/848539402404/locations/global/workloadIdentityPools/gh-actions/providers/gh-actions" | ||
service_account: "gh-actions-dapla-stat@artifact-registry-5n.iam.gserviceaccount.com" | ||
token_format: "access_token" | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Login to registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: "oauth2accesstoken" | ||
password: "${{ steps.auth.outputs.access_token }}" | ||
- name: Docker meta | ||
id: metadata | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}${{ env.NAME }} | ||
# Docker tags based on the following events/attributes | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
type=semver,pattern=v{{version}} | ||
type=semver,pattern=v{{major}}.{{minor}} | ||
type=semver,pattern=v{{major}} | ||
type=raw,value=${{ env.TAG }}, enable=true | ||
- name: Build and push image | ||
id: docker_build | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: docker/${{ env.NAME }} | ||
file: docker/${{ env.NAME }}/Dockerfile | ||
push: true | ||
tags: | | ||
${{ steps.metadata.outputs.tags }} | ||
labels: ${{ steps.metadata.outputs.labels }} | ||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}${{ env.NAME }}:buildcache | ||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}${{ env.NAME }}:buildcache,mode=max | ||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Jupyterlab Docker Build and Deploy | ||
|
||
on: | ||
release: | ||
types: [published] | ||
push: | ||
branches: | ||
- "main" | ||
paths: | ||
- 'docker/jupyterlab/**' | ||
- '.github/workflows/jupyterlab-docker-build-and-deploy.yml' | ||
pull_request: | ||
paths: | ||
- 'docker/jupyterlab/**' | ||
- '.github/workflows/jupyterlab-docker-build-and-deploy.yml' | ||
|
||
env: | ||
REGISTRY: europe-north1-docker.pkg.dev/artifact-registry-5n/dapla-stat-docker/jupyter | ||
TAG: ${{ github.ref_name }}-${{ github.sha }} | ||
IMAGE_PREFIX: on-prem- | ||
BASE_IMAGE: jupyterlab-common:latest | ||
NAME: jupyterlab | ||
|
||
jobs: | ||
docker: | ||
permissions: | ||
contents: "read" | ||
id-token: "write" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Check out repo" | ||
uses: actions/checkout@v3 | ||
- name: "Authenticate to Google Cloud" | ||
id: "auth" | ||
uses: "google-github-actions/[email protected]" | ||
with: | ||
workload_identity_provider: "projects/848539402404/locations/global/workloadIdentityPools/gh-actions/providers/gh-actions" | ||
service_account: "gh-actions-dapla-stat@artifact-registry-5n.iam.gserviceaccount.com" | ||
token_format: "access_token" | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Login to registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: "oauth2accesstoken" | ||
password: "${{ steps.auth.outputs.access_token }}" | ||
- name: Docker meta | ||
id: metadata | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}${{ env.NAME }} | ||
# Docker tags based on the following events/attributes | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
type=semver,pattern=v{{version}} | ||
type=semver,pattern=v{{major}}.{{minor}} | ||
type=semver,pattern=v{{major}} | ||
type=raw,value=${{ env.TAG }}, enable=true | ||
- name: Build and push image | ||
id: docker_build | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: docker/${{ env.NAME }} | ||
file: docker/${{ env.NAME }}/Dockerfile | ||
push: true | ||
build-args: base_image=${{ env.REGISTRY }}/${{ env.BASE_IMAGE }} | ||
tags: | | ||
${{ steps.metadata.outputs.tags }} | ||
labels: ${{ steps.metadata.outputs.labels }} | ||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}${{ env.NAME }}:buildcache | ||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}${{ env.NAME }}:buildcache,mode=max | ||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} |
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