forked from opain/GenoPred
-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (107 loc) · 4.3 KB
/
build_deploy_container.yaml
File metadata and controls
127 lines (107 loc) · 4.3 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
name: Build and Push Docker and Singularity Images
on:
release:
types: [created]
workflow_dispatch:
inputs:
tag:
description: 'Tag for the release'
required: false
default: ''
jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
SINGULARITY_LIBRARY_TOKEN: ${{ secrets.SINGULARITY_LIBRARY_TOKEN }}
SIGNING_PRIVATE_KEY_BASE64: ${{ secrets.SIGNING_PRIVATE_KEY_BASE64 }}
SIGNING_PUBLIC_KEY_BASE64: ${{ secrets.SIGNING_PUBLIC_KEY_BASE64 }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
DOCKER_IMAGE_NAME: opaino/genopred_pipeline
SINGULARITY_IMAGE_NAME: library://opain/genopred/genopred_pipeline
IMAGE_TAG: ${{ github.ref_name }}
DOCKERFILE_PATH: pipeline/misc/docker/Dockerfile
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Export Secrets to Environment
run: |
echo "SINGULARITY_LIBRARY_TOKEN=${{ secrets.SINGULARITY_LIBRARY_TOKEN }}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin
- name: Set Tag
id: set_tag
run: |
if [ "${{ github.event_name }}" == "release" ]; then
echo "::set-output name=tag::${{ github.event.release.tag_name }}"
else
echo "::set-output name=tag::${{ github.event.inputs.tag || github.sha }}"
fi
- name: Build docker container
run: |
docker buildx build --platform linux/amd64 -f $DOCKERFILE_PATH -t $DOCKER_IMAGE_NAME:latest -t $DOCKER_IMAGE_NAME:${{ steps.set_tag.outputs.tag }} --push .
- name: Maximize build disk space
uses: easimon/maximize-build-space@v10
with:
root-reserve-mb: 512
swap-size-mb: 1024
remove-dotnet: 'true'
- name: Setup Apptainer
uses: eWaterCycle/setup-apptainer@v2.0.0
- name: Configure Singularity temp directories
run: |
mkdir -p "$GITHUB_WORKSPACE/.singularity/cache"
echo "APPTAINER_TMPDIR=$GITHUB_WORKSPACE/.singularity" >> $GITHUB_ENV
echo "APPTAINER_CACHEDIR=$GITHUB_WORKSPACE/.singularity/cache" >> $GITHUB_ENV
- name: Convert Docker Image to Singularity SIF
run: |
apptainer pull --disable-cache \
--tmpdir "$GITHUB_WORKSPACE/.singularity" \
"$GITHUB_WORKSPACE/genopred_image.sif" \
docker://${DOCKER_IMAGE_NAME}:latest
- name: Install expect
run: |
sudo apt-get update
sudo apt-get install -y expect
- name: Decode and Import Signing Keys
run: |
echo "${{ secrets.SIGNING_PRIVATE_KEY_BASE64 }}" | base64 --decode > private.key
echo "${{ secrets.SIGNING_PUBLIC_KEY_BASE64 }}" | base64 --decode > public.key
expect -c '
spawn apptainer key import private.key
expect "Enter your key passphrase : "
send -- "${{ secrets.SIGNING_KEY_PASSWORD }}\r"
expect eof
'
expect -c '
spawn apptainer key import public.key
expect "Enter your key passphrase : "
send -- "${{ secrets.SIGNING_KEY_PASSWORD }}\r"
expect eof
'
- name: Sign the Singularity Image
run: |
SIF_PATH="$GITHUB_WORKSPACE/genopred_image.sif"
expect -c "
spawn apptainer sign \"$SIF_PATH\"
expect \"Enter your key passphrase : \"
send -- \"${{ secrets.SIGNING_KEY_PASSWORD }}\r\"
expect eof
"
- name: Create Token File
run: echo "${{ secrets.SINGULARITY_LIBRARY_TOKEN }}" > tokenfile
- name: Login to Singularity Library
run: |
apptainer remote add --no-login SylabsCloud cloud.sycloud.io
apptainer remote use SylabsCloud
apptainer remote login --tokenfile tokenfile
- name: Push Singularity Image to Singularity Library
run: |
apptainer push "$GITHUB_WORKSPACE/genopred_image.sif" "$SINGULARITY_IMAGE_NAME:latest"
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 60