-
Notifications
You must be signed in to change notification settings - Fork 3
executable file
·77 lines (59 loc) · 2.55 KB
/
publish-docker-gpu.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
name: Publish GPU Docker image
# To MaastrichtU-IDS GitHub Container Registry
# https://github.com/orgs/MaastrichtU-IDS/packages
on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- 'Dockerfile.gpu'
- '.github/workflows/publish-docker-gpu.yml'
# schedule:
# - cron: '0 3 * * 1'
# Monday at 3:00 GMT+1
env:
TENSORFLOW_IMAGE: nvcr.io/nvidia/tensorflow:21.05-tf2-py3
PYTORCH_IMAGE: nvcr.io/nvidia/pytorch:21.05-py3
IMAGE_NAME: code-server-gpu
jobs:
# Build and push image to ghcr.io
publish-tensorflow:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build image
run: docker build . --build-arg NVIDIA_IMAGE=$TENSORFLOW_IMAGE --file Dockerfile.gpu --tag $IMAGE_NAME
- name: Log into GitHub Container Registry
# TODO: Create a token with `read:packages` and `write:packages` scopes
# And save it as an Actions secret CONTAINER_REGISTRY_GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image to GitHub Container Registry
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=tensorflow-$(echo $TENSORFLOW_IMAGE | rev | cut -d ":" -f1 | rev)
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
publish-pytorch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build image
run: docker build . --build-arg NVIDIA_IMAGE=$PYTORCH_IMAGE --file Dockerfile.gpu --tag $IMAGE_NAME
- name: Log into GitHub Container Registry
# TODO: Create a token with `read:packages` and `write:packages` scopes
# And save it as an Actions secret CONTAINER_REGISTRY_GITHUB_TOKEN
run: echo "${{ secrets.CONTAINER_REGISTRY_GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image to GitHub Container Registry
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=pytorch-$(echo $PYTORCH_IMAGE | rev | cut -d ":" -f1 | rev)
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION