-
Notifications
You must be signed in to change notification settings - Fork 13
122 lines (107 loc) · 3.51 KB
/
build-push-docker.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Build and push images to:
# GitHub Container Registry (ghcr.io)
# Red Hat Container Registry (quay.io)
name: "Build Docker Images"
on:
workflow_dispatch: null
push:
branches:
- "*"
paths:
- "Dockerfile.*"
- "dask-worker/*"
- "jupyterhub/*"
- "jupyterlab/*"
- "nebari-workflow-controller/*"
- "scripts/*"
- ".github/workflows/build-push-docker.yaml"
tags:
- "*"
env:
DOCKER_ORG: nebari
GPU_BASE_IMAGE: nvidia/cuda:12.2.2-base-ubuntu20.04
GPU_IMAGE_SUFFIX: gpu
BASE_IMAGE: ubuntu:20.04
permissions:
contents: read
packages: write
id-token: write
security-events: write
# https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
# only cancel in-progress jobs or runs for the current workflow - matches against branch & tags
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-images:
name: "Build Docker Images"
runs-on: ubuntu-latest
strategy:
matrix:
dockerfile:
- jupyterlab
- jupyterhub
- dask-worker
- workflow-controller
platform:
- gpu
- cpu
exclude:
# excludes JupyterHub/GPU, Workflow Controller/GPU
- dockerfile: jupyterhub
platform: gpu
- dockerfile: workflow-controller
platform: gpu
steps:
- name: "Checkout Repository 🛎️"
uses: actions/checkout@v3
- name: "Set up Docker Buildx 🛠️"
uses: docker/setup-buildx-action@v2
- name: "Login to GitHub Container Registry 🔐"
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.BOT_GHCR_TOKEN }}
- name: "Login to Quay Container Registry 🔐"
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- name: "Set BASE_IMAGE and Image Suffix 📷"
if: ${{ matrix.platform == 'gpu' }}
run: |
echo "GPU Platform Matrix"
echo "BASE_IMAGE=$GPU_BASE_IMAGE" >> $GITHUB_ENV
echo "IMAGE_SUFFIX=-$GPU_IMAGE_SUFFIX" >> $GITHUB_ENV
- name: "Generate Docker images tags 🏷️"
id: meta
uses: docker/metadata-action@v4
with:
images: |
"quay.io/${{ env.DOCKER_ORG }}/nebari-${{ matrix.dockerfile }}${{ env.IMAGE_SUFFIX }}"
"ghcr.io/${{ github.repository_owner }}/nebari-${{ matrix.dockerfile }}${{ env.IMAGE_SUFFIX }}"
tags: |
# branch event -> e.g. `main-f0f6994-20221001`
type=ref, event=branch, suffix=-{{sha}}-{{date 'YYYYMMDD'}}
# needed for integration tests
type=ref, event=branch
# on tag push -> e.g. `2022.10.1`
type=ref, event=tag
- name: "Inspect image dir tree 🔍"
run: |
sudo apt-get install tree
tree .
- name: "Build docker images 🐳"
uses: docker/build-push-action@v3
with:
context: .
file: "Dockerfile.${{ matrix.dockerfile }}"
tags: ${{ steps.meta.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: BASE_IMAGE=${{ env.BASE_IMAGE }}
platforms: linux/amd64,linux/arm64