-
Notifications
You must be signed in to change notification settings - Fork 42
211 lines (192 loc) · 7.8 KB
/
docker.yml
File metadata and controls
211 lines (192 loc) · 7.8 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# This workflow will build two Docker image and push then to GitHub Packages Container registry:
# - a base image with the dependencies
# - a main image with the application code
name: Docker
on:
workflow_dispatch:
issue_comment:
types: [created]
push:
branches: [main]
paths:
- 'docker/**'
- '.github/workflows/docker.yml'
- 'conda/*.yml'
- 'pyproject.toml'
pull_request:
branches: [main]
paths:
- 'docker/**'
- '.github/workflows/docker.yml'
- 'conda/*.yml'
- 'pyproject.toml'
release:
types: [published]
jobs:
check:
name: Check trigger
runs-on: ubuntu-latest
# Skip issue_comment unless it's /test-docker on a PR
if: >-
github.event_name != 'issue_comment' ||
(github.event.issue.pull_request && startsWith(github.event.comment.body, '/test-docker'))
outputs:
head-sha: ${{ steps.get-sha.outputs.sha }}
permissions:
pull-requests: write
statuses: write
steps:
- name: Check permissions
if: github.event_name == 'issue_comment' || github.event_name == 'workflow_dispatch'
run: |
PERMISSION=$(gh api repos/${{ github.repository }}/collaborators/${{ github.actor }}/permission --jq '.permission')
if [[ "$PERMISSION" != "admin" && "$PERMISSION" != "maintain" ]]; then
echo "::error::Only maintainers or admins can trigger this workflow. Your permission: $PERMISSION"
exit 1
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: React to comment
if: github.event_name == 'issue_comment'
run: |
gh api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions -f content=rocket
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get PR head SHA
id: get-sha
if: github.event_name == 'issue_comment'
run: |
SHA=$(gh pr view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json headRefOid -q .headRefOid)
echo "sha=$SHA" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build_docker_images:
needs: check
strategy:
matrix:
RAPIDS_VER:
- "26.02"
CUDA_SUFFIX:
- { ver: "12.8.0", label: "cuda12", pkg: "cu12" }
- { ver: "13.0.2", label: "cuda13", pkg: "cu13" }
name: Build Docker images (${{ matrix.CUDA_SUFFIX.label }})
runs-on: ubuntu-latest
permissions:
id-token: write
packages: write
contents: read
attestations: write
statuses: write
steps:
- name: Free disk space
run: |
echo "=== Disk space before cleanup ==="
df -h /
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache
sudo rm -rf /usr/local/share/boost /usr/share/swift /usr/local/.ghcup
sudo rm -rf /usr/local/lib/node_modules /usr/share/miniconda
sudo docker image prune --all --force
sudo apt-get clean
echo "=== Disk space after cleanup ==="
df -h /
shell: bash
- name: Check out the repo
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || '' }}
- name: Set pending status on PR
if: github.event_name == 'issue_comment'
run: |
gh api repos/${{ github.repository }}/statuses/${{ needs.check.outputs.head-sha }} \
-f state=pending \
-f context="Docker Build (${{ matrix.CUDA_SUFFIX.label }})" \
-f description="Docker build running..." \
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker base image
id: meta-base
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/scverse/rapids-singlecell-deps-${{ matrix.CUDA_SUFFIX.pkg }}
- name: create yaml file for conda environment
run: |
grep -v -- '- rapids-singlecell' conda/rsc_rapids_${{ matrix.RAPIDS_VER }}_${{ matrix.CUDA_SUFFIX.label }}.yml > docker/rsc_rapids.yml
shell: bash
- name: Build and push Docker base images
id: push-base
uses: docker/build-push-action@v5
with:
context: ./docker/
file: ./docker/Dockerfile.deps
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.meta-base.outputs.tags }}
labels: ${{ steps.meta-base.outputs.labels }}
build-args: |
CUDA_VER=${{ matrix.CUDA_SUFFIX.ver }}
#cache-from: type=registry,ref=ghcr.io/${{ github.repository }}-deps
- name: Generate artifact attestation for base image
if: github.event_name == 'release'
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/scverse/rapids-singlecell-deps-${{ matrix.CUDA_SUFFIX.pkg }}
subject-digest: ${{ steps.push-base.outputs.digest }}
push-to-registry: true
- name: Extract metadata (tags, labels) for main Docker image
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/scverse/rapids-singlecell-${{ matrix.CUDA_SUFFIX.pkg }}
- name: Build and push main Docker images
id: push
uses: docker/build-push-action@v5
with:
context: ./docker/
file: ./docker/Dockerfile
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
CUDA_ARCHS=${{ matrix.CUDA_SUFFIX.label == 'cuda12' && '75-real;80-real;86-real;89-real;90' || '75-real;80-real;86-real;89-real;90-real;100-real;120' }}
#cache-from: type=registry,ref=ghcr.io/${{ github.repository }}
build-contexts: |
rapids-singlecell-deps=docker-image://${{ fromJSON(steps.meta-base.outputs.json).tags[0] }}
- name: Generate artifact attestation for main image
if: github.event_name == 'release'
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/scverse/rapids-singlecell-${{ matrix.CUDA_SUFFIX.pkg }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
- name: list docker images
run: |
docker image ls -a
shell: bash
- name: Set success status on PR
if: success() && github.event_name == 'issue_comment'
run: |
gh api repos/${{ github.repository }}/statuses/${{ needs.check.outputs.head-sha }} \
-f state=success \
-f context="Docker Build (${{ matrix.CUDA_SUFFIX.label }})" \
-f description="Docker build passed" \
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set failure status on PR
if: failure() && github.event_name == 'issue_comment'
run: |
gh api repos/${{ github.repository }}/statuses/${{ needs.check.outputs.head-sha }} \
-f state=failure \
-f context="Docker Build (${{ matrix.CUDA_SUFFIX.label }})" \
-f description="Docker build failed" \
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}