-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (128 loc) · 4.36 KB
/
build_docker.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
# modified from https://docs.docker.com/build/ci/github-actions/push-multi-registries/
name: build_docker
on:
workflow_dispatch:
push:
# todo2: disable again
branches:
- "main"
tags:
- 'v*' # push of any tag
# workflow_run:
# workflows: ["run_tox"]
# branches: [main]
# types:
# - completed
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TEST_TAG: ${{ github.repository }}_test
BUILD_TARGET: dev # prod
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true
jobs:
docker:
permissions:
packages: write
contents: read
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }} # the special secrets.GITHUB_TOKEN only allows access to the current repository, so we added a personal access token with scope "repo" as a secret to this repo
submodules: true
-
# qemu required if building for multiple platforms with Docker (other than the platform the docker build is executed on)
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# -
# name: Login to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
# ${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
-
name: Build and export to Docker (using cache)
uses: docker/build-push-action@v4
timeout-minutes: 20
with:
context: .
target: ${{ env.BUILD_TARGET }}
load: true
tags: ${{ env.TEST_TAG }}
# todo2: disable cache eventually
cache-from: type=gha
cache-to: type=gha,mode=max
-
name: Test docker image in python3.10
uses: addnab/docker-run-action@v3
with:
image: ${{ env.TEST_TAG }}
shell: /bin/bash
run: |
set -ex
source ~/ont_project_all/ont_project_venv/bin/activate || true
export PATH=~/ont_project_all/tools/bin:$PATH && which minimap2
cd /root/ont_project_all/ont_project
sed -i'.backup' -e "s@{root:uri}@file://$(pwd)@g" -e "s@[email protected]+dockerbuild$(date +%YY%mM%dD%HH%MM%SS)@" pyproject.toml
pip install tox
tox run -e py310
-
name: Push docker image
uses: docker/build-push-action@v4
id: Push
with:
context: .
platforms: linux/amd64 #,linux/arm64
target: ${{ env.BUILD_TARGET }}
push: true
tags: ${{ steps.meta.outputs.tags }}_${{ env.BUILD_TARGET }}
labels: ${{ steps.meta.outputs.labels }}
-
name: Run full usecase (in Docker container)
uses: addnab/docker-run-action@v3
with:
image: ${{ env.TEST_TAG }}
shell: /bin/bash
run: |
set -ex
cd ~/ont_project_all/ont_project
curl https://public.bmi.inf.ethz.ch/user/mmordig/ont_project/prepackaged/usecase_data_docker.tar.gz -O
tar -xvzf usecase_data_docker.tar.gz
pwd
ls -lR .
cd runs/enrich_usecase
source ~/ont_project_all/ont_project_venv/bin/activate || true
export PATH=~/ont_project_all/tools/bin:$PATH && which minimap2
mkdir chr202122_run && cd chr202122_run
ln -s ../data .
ln -s ../configs/chr202122_run/sampler_per_window configs
python ~/ont_project_all/ont_project/usecases/enrich_usecase.py
tar -cvzf figures.tar.gz readfish_run/figures
-
name: Archive figures
uses: actions/upload-artifact@v3
with:
name: usecase-figures
path: figures.tar.gz