-
Notifications
You must be signed in to change notification settings - Fork 133
132 lines (120 loc) · 4.57 KB
/
docker.yml
File metadata and controls
132 lines (120 loc) · 4.57 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
128
129
130
131
132
name: Containerization
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'tag to containerize'
required: true
concurrency:
group: Containerization
cancel-in-progress: false
jobs:
Container:
strategy:
matrix:
config:
- { name: 'cpu', runner: 'ubuntu-22.04', base_image: 'ubuntu:22.04' }
- { name: 'gpu', runner: 'ubuntu-22.04', base_image: 'nvcr.io/nvidia/nvhpc:23.11-devel-cuda_multi-ubuntu22.04' }
- { name: 'gpu', runner: 'ubuntu-22.04-arm', base_image: 'nvcr.io/nvidia/nvhpc:23.11-devel-cuda_multi-ubuntu22.04' }
runs-on: ${{ matrix.config.runner }}
outputs:
tag: ${{ steps.clone.outputs.tag }}
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Setup Buildx
uses: docker/setup-buildx-action@v3
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Clone
id: clone
run: |
TAG="${{ github.event.inputs.tag || github.ref_name }}"
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "TAG=$TAG" >> $GITHUB_ENV
git clone --branch "$TAG" --depth 1 ${{ github.server_url }}/${{ github.repository }}.git mfc
- name: Stage
run: |
sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo mkdir -p /home/runner/tmp
export TMPDIR=/home/runner/tmp
free -h
sudo mkdir -p /mnt/share
sudo chmod 777 /mnt/share
cp -r mfc/* /mnt/share/
cp -r mfc/.git /mnt/share/.git
cp mfc/.github/Dockerfile /mnt/share/
cp mfc/.github/.dockerignore /mnt/share/
docker buildx create --name mfcbuilder --driver docker-container --use
- name: Build and push image (cpu)
if: ${{ matrix.config.name == 'cpu' }}
uses: docker/build-push-action@v6
with:
builder: mfcbuilder
context: /mnt/share
file: /mnt/share/Dockerfile
platforms: linux/amd64,linux/arm64
build-args: |
BASE_IMAGE=${{ matrix.config.base_image }}
TARGET=${{ matrix.config.name }}
CC_COMPILER=${{ 'gcc' }}
CXX_COMPILER=${{ 'g++' }}
FC_COMPILER=${{ 'gfortran' }}
COMPILER_PATH=${{ '/usr/bin' }}
COMPILER_LD_LIBRARY_PATH=${{ '/usr/lib' }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.name }}
push: true
- name: Build and push image (gpu)
if: ${{ matrix.config.name == 'gpu' }}
uses: docker/build-push-action@v5
with:
builder: default
context: /mnt/share
file: /mnt/share/Dockerfile
build-args: |
BASE_IMAGE=${{ matrix.config.base_image }}
TARGET=${{ matrix.config.name }}
CC_COMPILER=${{ 'nvc' }}
CXX_COMPILER=${{ 'nvc++' }}
FC_COMPILER=${{ 'nvfortran' }}
COMPILER_PATH=${{ '/opt/nvidia/hpc_sdk/Linux_x86_64/compilers/bin' }}
COMPILER_LD_LIBRARY_PATH=${{ '/opt/nvidia/hpc_sdk/Linux_x86_64/compilers/lib' }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.name }}-${{ matrix.config.runner}}
push: true
manifests:
runs-on: ubuntu-latest
needs: Container
steps:
- name: Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Create and Push Manifest Lists
env:
TAG: ${{ needs.Container.outputs.tag }}
REGISTRY: ${{ secrets.DOCKERHUB_USERNAME }}/mfc
run: |
docker buildx imagetools create -t $REGISTRY:latest-cpu $REGISTRY:$TAG-cpu
docker manifest create $REGISTRY:$TAG-gpu $REGISTRY:$TAG-gpu-ubuntu-22.04 $REGISTRY:$TAG-gpu-ubuntu-22.04-arm
docker manifest create $REGISTRY:latest-gpu $REGISTRY:$TAG-gpu-ubuntu-22.04 $REGISTRY:$TAG-gpu-ubuntu-22.04-arm
docker manifest push $REGISTRY:$TAG-gpu
docker manifest push $REGISTRY:latest-gpu