-
Notifications
You must be signed in to change notification settings - Fork 15
139 lines (131 loc) · 4.55 KB
/
d4science-images.yml
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
---
name: Build and push d4science containers
on:
push:
# only pushes on master so we don't push intermediate results to dockerhub
branches:
- master
pull_request:
jobs:
detect-changes:
uses: ./.github/workflows/build-list.yml
with:
base: d4science-base/Dockerfile
images: |
"single-user-d4science/Dockerfile"
"single-user-sobigdata/Dockerfile"
"single-user-3d-d4science/Dockerfile"
"single-user-r-d4science/Dockerfile"
"single-user-scientometrics-d4science/Dockerfile"
"single-user-sobigdata-lipari23/Dockerfile"
"single-user-sobigdata-aaai24/Dockerfile"
"single-user-criticalzone/Dockerfile"
"single-user-ecologicalrestorationlab/Dockerfile"
"single-user-pluto-d4science/Dockerfile"
"single-user-sobigdata-itineris/Dockerfile"
base-image:
name: Build base image
needs: detect-changes
if: needs.detect-changes.outputs.build-base == 1
runs-on: ubuntu-latest
outputs:
base: ${{ steps.docker_meta_base.outputs.tags }}
steps:
- name: try to make free space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: docker_meta_base
uses: docker/metadata-action@v5
with:
images: ${{ github.repository_owner }}/notebooks-d4science-base
tags: |
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build base
uses: docker/build-push-action@v6
with:
context: d4science-base
tags: ${{ steps.docker_meta_base.outputs.tags }}
labels: ${{ steps.docker_meta_base.outputs.labels }}
outputs: type=docker,dest=/tmp/base.tar
- name: Upload docker image as artifact
uses: actions/upload-artifact@v4
with:
name: images
path: /tmp/base.tar
user-images:
name: Build and push images
if: fromJson(needs.detect-changes.outputs.matrix).image
needs: [base-image, detect-changes]
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
steps:
- name: try to make free space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: eginotebooks/${{ matrix.image }}
tags: |
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Get previous build base
uses: actions/download-artifact@v4
with:
name: images
path: /tmp
- name: Load Docker images
run: |
docker load --input /tmp/base.tar
# we are so scarce on storage that this needs to be cleared
rm -rf /tmp/base.tar
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
if: github.event_name != 'pull_request'
# Unfortunately I haven't been able to load an prebuilt image here
# so not using the build-push-action from docker
# it's missing the labels and assumes tags is just one
- name: Build full image
run: |
docker build \
--build-arg BASE_IMAGE=${{ needs.base-image.outputs.base }} \
--tag ${{ steps.docker_meta.outputs.tags }} \
--tag eginotebooks/${{ matrix.image }}:latest \
${{ matrix.image }}
- name: Push full image
run: |
docker push ${{ steps.docker_meta.outputs.tags }}
docker push eginotebooks/${{ matrix.image }}:latest
if: ${{ github.event_name != 'pull_request' }}
- uses: addnab/docker-run-action@v3
with:
image: ${{ steps.docker_meta.outputs.tags }}
options: -v ${{ github.workspace }}/${{ matrix.image }}:/image-data
run: |
for f in /image-data/tests/*.ipynb; do
if [ -e "$f" ]; then
jupyter nbconvert --ExecutePreprocessor.timeout=600 --to rst \
--execute --stdout $f || exit 1
else
true
fi
done