-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (61 loc) · 2.24 KB
/
docker.yml
File metadata and controls
66 lines (61 loc) · 2.24 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
name: Build and Push Docker Images
on:
workflow_call:
inputs:
repo-name:
required: true
type: string
extra-tag:
required: true
type: string
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true
jobs:
build-images:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm]
include:
- os: ubuntu-24.04
system: x86_64-linux
- os: ubuntu-24.04-arm
system: aarch64-linux
steps:
- uses: actions/checkout@v5
- uses: DeterminateSystems/nix-installer-action@main
- name: Build Docker Image for ${{ matrix.system }}
run: nix build .#dockerImage.${{ matrix.system }}
- name: Upload intermediate Docker Image for ${{ Matrix.system }}
uses: actions/upload-artifact@v4
with:
path: result
name: ${{ matrix.system }}.archive.tar.gz
publish-images:
runs-on: ubuntu-24.04-arm # ARM runners are slightly faster
needs: [build-images]
steps:
- uses: actions/download-artifact@v5
with:
pattern: "*.archive.tar.gz"
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Merge intermediate Docker Images and upload.
env:
EXTRA_TAG: ${{ inputs.extra-tag }}
REPO_PATH: ${{ secrets.DOCKERHUB_USERNAME }}/${{inputs.repo-name}}
run: |
AMD_PATH=docker-archive:x86_64-linux.archive.tar.gz/result
skopeo copy --preserve-digests $AMD_PATH docker://$REPO_PATH@@unknown-digest@@
AMD_DIGEST=$(skopeo inspect $AMD_PATH | jq .Digest -r)
ARM_PATH=docker-archive:aarch64-linux.archive.tar.gz/result
skopeo copy --preserve-digests $ARM_PATH docker://$REPO_PATH@@unknown-digest@@
ARM_DIGEST=$(skopeo inspect $ARM_PATH | jq .Digest -r)
docker buildx imagetools create --tag $REPO_PATH:latest $REPO_PATH@$AMD_DIGEST $REPO_PATH@$ARM_DIGEST
docker buildx imagetools create --tag $REPO_PATH:$EXTRA_TAG $REPO_PATH@$AMD_DIGEST $REPO_PATH@$ARM_DIGEST