-
Notifications
You must be signed in to change notification settings - Fork 21
70 lines (61 loc) · 1.97 KB
/
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
name: Create and publish Docker images
on:
push: { branches: [ 3.3.x ] }
pull_request:
branches: [ 3.3.x ]
paths: ['Docker/**']
workflow_call:
workflow_dispatch:
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- name: github_ci
- name: openmpi
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}_${{ matrix.name }}
- name: Build and cache base Docker image
uses: docker/build-push-action@v5
with:
context: ./Docker
file: ./Docker/${{ matrix.name }}_dockerfile
build-args: |
NCORES=2
target: base
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ github.ref_name }}-${{ matrix.name }}
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-${{ matrix.name }}
- name: Build and push final Docker image
uses: docker/build-push-action@v5
with:
context: ./Docker
file: ./Docker/${{ matrix.name }}_dockerfile
build-args: |
NCORES=2
# cache pkgs layer in dockerfile
no-cache-filters: pkgs
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}