-
Notifications
You must be signed in to change notification settings - Fork 31
203 lines (181 loc) · 7.12 KB
/
full-rstudio-build.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
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
# This is a basic workflow to help you get started with Actions
name: Full rocker & bioc build
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
workflow_dispatch:
inputs:
rver:
default: "devel"
biocver:
default: "3.21"
outname:
default: "bioconductor_docker"
schedule:
- cron: '0 18 * * 5'
jobs:
bump:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Push patch bump
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 50
shell: bash
command: |
set -x
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config user.name github-actions
git config user.email [email protected]
git pull origin main || git reset --hard origin/main
sed -r -i 's/(^ARG BIOCONDUCTOR_PATCH=)([0-9]+)$/echo "\1$((\2+1))"/ge' Dockerfile
git add Dockerfile
git commit -m "Bump BIOCONDUCTOR_PATCH"
git push
build:
outputs:
registryuser: ${{ steps.defs.outputs.registryuser }}
outname: ${{ steps.defs.outputs.outname }}
rver: ${{ steps.defs.outputs.rver }}
strategy:
matrix:
arch: [amd64, arm64]
runs-on: ubuntu-latest
needs: bump
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Free root space
uses: almahmoud/free-root-space@main
with:
verbose: true
- name: Set defaults for schedule
id: defs
run: |
echo outname=$(echo ${{ github.event.inputs.outname || 'bioconductor_docker' }}) >> $GITHUB_OUTPUT
echo rver=$(echo ${{ github.event.inputs.rver || 'devel' }}) >> $GITHUB_OUTPUT
echo biocver=$(echo ${{ github.event.inputs.biocver || '3.21' }}) >> $GITHUB_OUTPUT
echo registryuser=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}') >> $GITHUB_OUTPUT
echo rockerintermediateprefix=$(echo "ghcr.io/${{ github.repository_owner }}/rocker" | awk '{print tolower($0)}') >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
if: matrix.arch == 'arm64'
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata for container image
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ steps.defs.outputs.registryuser }}/${{ steps.defs.outputs.outname }}
tags: |
type=raw,value=${{ steps.defs.outputs.rver }}-${{ matrix.arch }}
- name: Set comma-separated list with all repository names
id: images
run: |
IMG=${{ steps.meta.outputs.tags }}
REPOLIST="docker.io/$IMG,ghcr.io/$IMG"
echo ghcr=$(echo "ghcr.io/$IMG") >> $GITHUB_OUTPUT
SUB="_docker"
# Also add alternative without _docker when in name
echo list=$(if [[ $REPOLIST == *$SUB* ]]; then echo "$REPOLIST,$(echo $REPOLIST | sed 's/_docker//g')"; else echo $REPOLIST; fi) >> $GITHUB_OUTPUT
bash .github/scripts/rocker_prep.sh "${{ steps.defs.outputs.rver }}" "${{ steps.defs.outputs.biocver }}" "${{ steps.defs.outputs.rockerintermediateprefix }}" "${{ matrix.arch }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/${{ matrix.arch }}
- name: Build and load r-ver
uses: docker/build-push-action@v3
with:
file: rocker-versioned2/dockerfiles/r-ver_${{ steps.defs.outputs.rver }}.Dockerfile
context: rocker-versioned2
push: true
tags: ${{ steps.defs.outputs.rockerintermediateprefix }}-r-ver:${{ steps.defs.outputs.rver }}-${{ matrix.arch }}
platforms: linux/${{ matrix.arch }}
- name: Build and load rstudio
uses: docker/build-push-action@v3
with:
file: rocker-versioned2/dockerfiles/rstudio_${{ steps.defs.outputs.rver }}.Dockerfile
context: rocker-versioned2
push: true
tags: ${{ steps.defs.outputs.rockerintermediateprefix }}-rstudio:${{ steps.defs.outputs.rver }}-${{ matrix.arch }}
platforms: linux/${{ matrix.arch }}
- name: Build and push container image to all repos both arm64 and amd64
uses: docker/build-push-action@v3
with:
build-args: |
BASE_IMAGE=${{ steps.defs.outputs.rockerintermediateprefix }}-rstudio
arm64_tag=${{ steps.defs.outputs.rver }}-${{ matrix.arch }}
amd64_tag=${{ steps.defs.outputs.rver }}-${{ matrix.arch }}
BIOCONDUCTOR_VERSION=${{ steps.defs.outputs.biocver }}
file: Dockerfile
context: .
push: true
tags: ${{ steps.images.outputs.list }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/${{ matrix.arch }}
test-built-containers:
strategy:
matrix:
arch: [arm64, amd64]
# The type of runner that the job will run on
runs-on: ubuntu-latest
needs: build
steps:
- name: Get image name
id: image
run: |
IMG=$(echo "${{needs.build.outputs.registryuser}}/${{ needs.build.outputs.outname }}:${{ needs.build.outputs.rver }}-${{ matrix.arch }}")
echo name=$IMG >> $GITHUB_OUTPUT
cat << EOF > test.Dockerfile
FROM $IMG as test
USER root
RUN mkdir -p /tmp/bioc_test && \
apt list --installed | tee /tmp/bioc_test/aptlist && \
Rscript -e "BiocManager::install(c('SummarizedExperiment','usethis','data.table','igraph','GEOquery'))" 2>&1 | tee /tmp/bioc_test/packages_install && \
Rscript -e "BiocManager::install('gert'); require('gert')" 2>&1 | tee /tmp/bioc_test/gert_install
FROM scratch as export
COPY --from=test /tmp/bioc_test /tmp
EOF
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
if: matrix.arch == 'arm64'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/${{ matrix.arch }}
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Test via build
id: dockerbuild
uses: docker/build-push-action@v4
with:
file: test.Dockerfile
context: .
push: false
load: false
outputs: type=tar,dest=/tmp/image.tar
tags: ${{ steps.image.outputs.name }}
- run: |
mkdir -p /tmp/contents
cd /tmp/contents
tar -xvf /tmp/image.tar
sudo ls tmp/* | xargs -i bash -c "echo 'cat {}' && cat {}"