@@ -3,11 +3,17 @@ name: Containerization
33on :
44 release :
55 types : [published]
6+ schedule :
7+ - cron : ' 0 0 * * 0'
68 workflow_dispatch :
79 inputs :
810 tag :
911 description : ' tag to containerize'
10- required : true
12+ required : false
13+
14+ permissions :
15+ contents : read
16+ packages : write
1117
1218concurrency :
1319 group : Containerization
1824 strategy :
1925 matrix :
2026 config :
21- - { name: 'cpu', runner: 'ubuntu-22.04', base_image: 'ubuntu:22.04' }
22- - { name: 'gpu', runner: 'ubuntu-22.04', base_image: 'nvcr.io/nvidia/nvhpc:23.11-devel-cuda_multi-ubuntu22.04' }
23- - { name: 'gpu', runner: 'ubuntu-22.04-arm', base_image: 'nvcr.io/nvidia/nvhpc:23.11-devel-cuda_multi-ubuntu22.04' }
27+ - { name: 'cpu', tag: 'cpu', runner: 'ubuntu-22.04', base_image: 'ubuntu:22.04' }
28+ - { name: 'cpu', tag: 'cpu', runner: 'ubuntu-22.04-arm', base_image: 'ubuntu:22.04' }
29+ - { name: 'gpu', tag: 'gpu-nvidia', runner: 'ubuntu-22.04', base_image: 'nvcr.io/nvidia/nvhpc:24.5-devel-cuda_multi-ubuntu22.04', compiler_arch: 'Linux_x86_64' }
30+ - { name: 'gpu', tag: 'gpu-nvidia', runner: 'ubuntu-22.04-arm', base_image: 'nvcr.io/nvidia/nvhpc:24.5-devel-cuda_multi-ubuntu22.04', compiler_arch: 'Linux_aarch64' }
31+ - { name: 'amd', tag: 'gpu-amd', runner: 'ubuntu-22.04', base_image: 'ubuntu:22.04' }
2432 runs-on : ${{ matrix.config.runner }}
2533 outputs :
2634 tag : ${{ steps.clone.outputs.tag }}
@@ -36,25 +44,37 @@ jobs:
3644 docker-images : true
3745 swap-storage : true
3846
39- - name : Login
47+ - name : Login to Docker Hub
4048 uses : docker/login-action@v3
4149 with :
4250 username : ${{ secrets.DOCKERHUB_USERNAME }}
4351 password : ${{ secrets.DOCKERHUB_PASSWORD }}
4452
53+ - name : Login to GHCR
54+ uses : docker/login-action@v3
55+ with :
56+ registry : ghcr.io
57+ username : ${{ github.actor }}
58+ password : ${{ secrets.GITHUB_TOKEN }}
59+
4560 - name : Setup Buildx
4661 uses : docker/setup-buildx-action@v3
4762
48- - name : Setup QEMU
49- uses : docker/setup-qemu-action@v3
50-
5163 - name : Clone
5264 id : clone
5365 run : |
54- TAG="${{ github.event.inputs.tag || github.ref_name }}"
66+ if [ "${{ github.event_name }}" = "schedule" ]; then
67+ BRANCH="master"
68+ TAG="nightly"
69+ else
70+ BRANCH="${{ github.event.inputs.tag || github.ref_name }}"
71+ TAG=$(echo "$BRANCH" | tr '/' '-')
72+ fi
5573 echo "tag=$TAG" >> $GITHUB_OUTPUT
5674 echo "TAG=$TAG" >> $GITHUB_ENV
57- git clone --branch "$TAG" --depth 1 ${{ github.server_url }}/${{ github.repository }}.git mfc
75+ OWNER="${{ github.repository_owner }}"
76+ echo "GH_REGISTRY=ghcr.io/${OWNER,,}/mfc" >> $GITHUB_ENV
77+ git clone --branch "$BRANCH" --depth 1 ${{ github.server_url }}/${{ github.repository }}.git mfc
5878
5979 - name : Stage
6080 run : |
@@ -71,16 +91,13 @@ jobs:
7191 cp -r mfc/.git /mnt/share/.git
7292 cp mfc/.github/Dockerfile /mnt/share/
7393 cp mfc/.github/.dockerignore /mnt/share/
74- docker buildx create --name mfcbuilder --driver docker-container --use
7594
7695 - name : Build and push image (cpu)
7796 if : ${{ matrix.config.name == 'cpu' }}
7897 uses : docker/build-push-action@v6
7998 with :
80- builder : mfcbuilder
8199 context : /mnt/share
82100 file : /mnt/share/Dockerfile
83- platforms : linux/amd64,linux/arm64
84101 build-args : |
85102 BASE_IMAGE=${{ matrix.config.base_image }}
86103 TARGET=${{ matrix.config.name }}
@@ -89,7 +106,11 @@ jobs:
89106 FC_COMPILER=${{ 'gfortran' }}
90107 COMPILER_PATH=${{ '/usr/bin' }}
91108 COMPILER_LD_LIBRARY_PATH=${{ '/usr/lib' }}
92- tags : ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.name }}
109+ labels : |
110+ org.opencontainers.image.source=https://github.com/${{ github.repository }}
111+ tags : |
112+ ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.tag }}-${{ matrix.config.runner }}
113+ ${{ env.GH_REGISTRY }}:${{ env.TAG }}-${{ matrix.config.tag }}-${{ matrix.config.runner }}
93114 push : true
94115
95116 - name : Build and push image (gpu)
@@ -105,28 +126,95 @@ jobs:
105126 CC_COMPILER=${{ 'nvc' }}
106127 CXX_COMPILER=${{ 'nvc++' }}
107128 FC_COMPILER=${{ 'nvfortran' }}
108- COMPILER_PATH=${{ '/opt/nvidia/hpc_sdk/Linux_x86_64/compilers/bin' }}
109- COMPILER_LD_LIBRARY_PATH=${{ '/opt/nvidia/hpc_sdk/Linux_x86_64/compilers/lib' }}
110- tags : ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.name }}-${{ matrix.config.runner}}
129+ COMPILER_PATH=/opt/nvidia/hpc_sdk/${{ matrix.config.compiler_arch }}/compilers/bin
130+ COMPILER_LD_LIBRARY_PATH=/opt/nvidia/hpc_sdk/${{ matrix.config.compiler_arch }}/compilers/lib
131+ labels : |
132+ org.opencontainers.image.source=https://github.com/${{ github.repository }}
133+ tags : |
134+ ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.tag }}-${{ matrix.config.runner }}
135+ ${{ env.GH_REGISTRY }}:${{ env.TAG }}-${{ matrix.config.tag }}-${{ matrix.config.runner }}
136+ push : true
137+
138+ - name : Set AMD AFAR vars
139+ if : ${{ matrix.config.name == 'amd' }}
140+ run : |
141+ AFAR=rocm-afar-8873-drop-22.2.0
142+ ROOT="/opt/${AFAR}"
143+ echo "AFAR_VERSION=${AFAR}" >> $GITHUB_ENV
144+ echo "AFAR_ROOT=${ROOT}" >> $GITHUB_ENV
145+
146+ - name : Build and push image (amd)
147+ if : ${{ matrix.config.name == 'amd' }}
148+ uses : docker/build-push-action@v6
149+ with :
150+ context : /mnt/share
151+ file : /mnt/share/Dockerfile
152+ build-args : |
153+ BASE_IMAGE=${{ matrix.config.base_image }}
154+ TARGET=amd
155+ AFAR_VERSION=${{ env.AFAR_VERSION }}
156+ OLCF_AFAR_ROOT=${{ env.AFAR_ROOT }}
157+ CC_COMPILER=gcc
158+ CXX_COMPILER=g++
159+ FC_COMPILER=${{ env.AFAR_ROOT }}/bin/amdflang
160+ COMPILER_PATH=${{ env.AFAR_ROOT }}/lib/llvm/bin:${{ env.AFAR_ROOT }}/bin
161+ COMPILER_LD_LIBRARY_PATH=${{ env.AFAR_ROOT }}/lib:${{ env.AFAR_ROOT }}/lib/llvm/lib
162+ labels : |
163+ org.opencontainers.image.source=https://github.com/${{ github.repository }}
164+ tags : |
165+ ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-gpu-amd-ubuntu-22.04
166+ ${{ env.GH_REGISTRY }}:${{ env.TAG }}-gpu-amd-ubuntu-22.04
111167 push : true
112168
113169 manifests :
114170 runs-on : ubuntu-latest
115171 needs : Container
172+ environment :
173+ name : containers
174+ url : https://hub.docker.com/r/sbryngelson/mfc
116175 steps :
117- - name : Login
176+ - name : Login to Docker Hub
118177 uses : docker/login-action@v3
119178 with :
120179 username : ${{ secrets.DOCKERHUB_USERNAME }}
121180 password : ${{ secrets.DOCKERHUB_PASSWORD }}
122181
182+ - name : Login to GHCR
183+ uses : docker/login-action@v3
184+ with :
185+ registry : ghcr.io
186+ username : ${{ github.actor }}
187+ password : ${{ secrets.GITHUB_TOKEN }}
188+
189+ - name : Setup Buildx
190+ uses : docker/setup-buildx-action@v3
191+
192+ - name : Set GHCR registry (lowercase)
193+ run : |
194+ OWNER="${{ github.repository_owner }}"
195+ echo "GH_REGISTRY=ghcr.io/${OWNER,,}/mfc" >> $GITHUB_ENV
196+
123197 - name : Create and Push Manifest Lists
124198 env :
125199 TAG : ${{ needs.Container.outputs.tag }}
126- REGISTRY : ${{ secrets.DOCKERHUB_USERNAME }}/mfc
200+ DH : ${{ secrets.DOCKERHUB_USERNAME }}/mfc
201+ run : |
202+ GH="${{ env.GH_REGISTRY }}"
203+ for R in "$DH" "$GH"; do
204+ docker buildx imagetools create -t $R:$TAG-cpu $R:$TAG-cpu-ubuntu-22.04 $R:$TAG-cpu-ubuntu-22.04-arm
205+ docker buildx imagetools create -t $R:$TAG-gpu-nvidia $R:$TAG-gpu-nvidia-ubuntu-22.04 $R:$TAG-gpu-nvidia-ubuntu-22.04-arm
206+ docker buildx imagetools create -t $R:$TAG-gpu-amd $R:$TAG-gpu-amd-ubuntu-22.04
207+ done
208+
209+ - name : Update latest tags
210+ if : github.event_name == 'release'
211+ env :
212+ TAG : ${{ needs.Container.outputs.tag }}
213+ DH : ${{ secrets.DOCKERHUB_USERNAME }}/mfc
127214 run : |
128- docker buildx imagetools create -t $REGISTRY:latest-cpu $REGISTRY:$TAG-cpu
129- docker manifest create $REGISTRY:$TAG-gpu $REGISTRY:$TAG-gpu-ubuntu-22.04 $REGISTRY:$TAG-gpu-ubuntu-22.04-arm
130- docker manifest create $REGISTRY:latest-gpu $REGISTRY:$TAG-gpu-ubuntu-22.04 $REGISTRY:$TAG-gpu-ubuntu-22.04-arm
131- docker manifest push $REGISTRY:$TAG-gpu
132- docker manifest push $REGISTRY:latest-gpu
215+ GH="${{ env.GH_REGISTRY }}"
216+ for R in "$DH" "$GH"; do
217+ docker buildx imagetools create -t $R:latest-cpu $R:$TAG-cpu-ubuntu-22.04 $R:$TAG-cpu-ubuntu-22.04-arm
218+ docker buildx imagetools create -t $R:latest-gpu-nvidia $R:$TAG-gpu-nvidia-ubuntu-22.04 $R:$TAG-gpu-nvidia-ubuntu-22.04-arm
219+ docker buildx imagetools create -t $R:latest-gpu-amd $R:$TAG-gpu-amd-ubuntu-22.04
220+ done
0 commit comments