Skip to content

Commit dbf6aa9

Browse files
committed
[RF] build native arm64 docker images
1 parent 264d92e commit dbf6aa9

1 file changed

Lines changed: 84 additions & 32 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 84 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,31 @@ on:
77
type: [published]
88

99
env:
10-
TEST_TAG: dessimozlab/fastoma:test
10+
REGISTRY_IMAGE: dessimozlab/fastoma
1111

1212
jobs:
1313

1414
build:
1515

16-
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- platform: linux/amd64
21+
runner: ubuntu-latest
22+
- platform: linux/arm64
23+
runner: ubuntu-24.04-arm
24+
25+
runs-on: ${{ matrix.runner }}
1726

1827
steps:
28+
- name: Prepare
29+
run: |
30+
platform=${{ matrix.platform }}
31+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
32+
1933
- name: Checkout
20-
uses: actions/checkout@v6.0.1
34+
uses: actions/checkout@v6
2135
with:
2236
submodules: recursive
2337

@@ -26,8 +40,7 @@ jobs:
2640
uses: docker/metadata-action@v5
2741
with:
2842
# list of Docker images to use as base name for tags
29-
images: |
30-
dessimozlab/fastoma
43+
images: ${{ env.REGISTRY_IMAGE }}
3144
# generate Docker tags based on the following events/attributes
3245
tags: |
3346
type=schedule
@@ -47,40 +60,79 @@ jobs:
4760
- name: Set up Docker Buildx
4861
uses: docker/setup-buildx-action@v3
4962

50-
- name: Build and export to docker for testing
51-
uses: docker/build-push-action@v6
52-
with:
53-
context: .
54-
load: true
55-
tags: ${{ env.TEST_TAG }}
56-
57-
#- name: Test
58-
# run: |
59-
# docker run --rm -i -v $PWD/tests:/input -v $PWD/tests/:/reads -v $PWD/output:/out -v $PWD/run:/run ${{ env.TEST_TAG }} --tree --standalone_path /input/marker_genes --dna_reference /input/cds-marker_genes.fasta.gz --reads /reads/sample_1.fastq --output_path /out
60-
# if [ ! -f output/tree_sample_1.nwk ] ; then exit 1; fi
61-
6263
- name: Login to DockerHub
6364
uses: docker/login-action@v3
6465
with:
6566
username: ${{ secrets.DOCKER_HUB_USERNAME }}
6667
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
6768

68-
- name: Set platforms
69-
id: set_platforms
70-
run: |
71-
echo "github ref: ${GITHUB_REF}"
72-
if [[ "${GITHUB_REF##*/}" == "main" || "${GITHUB_REF##*/}" == "dev" || "${GITHUB_REF}" == "refs/tags/"* ]]; then
73-
echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
74-
else
75-
echo "platforms=linux/amd64" >> $GITHUB_OUTPUT
76-
fi
77-
78-
- name: Build and push
69+
- name: Build and push by digest only
70+
id: build
7971
uses: docker/build-push-action@v6
8072
with:
8173
context: .
82-
platforms: ${{ steps.set_platforms.outputs.platforms }}
83-
push: true
84-
#${{ github.event_name != 'push' && github.event_name != 'pull_request' }}
85-
tags: ${{ steps.meta.outputs.tags }}
74+
platforms: ${{ matrix.platform }}
75+
tags: ${{ env.REGISTRY_IMAGE }}
8676
labels: ${{ steps.meta.outputs.labels }}
77+
78+
- name: Export digest
79+
run: |
80+
mkdir -p ${{ runner.temp }}/digests
81+
digest="${{ steps.build.outputs.digest }}"
82+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
83+
84+
- name: Upload digest
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: digests-${{ env.PLATFORM_PAIR }}
88+
path: ${{ runner.temp }}/digests/*
89+
if-no-files-found: error
90+
retention-days: 1
91+
92+
merge:
93+
runs-on: ubuntu-latest
94+
needs:
95+
- build
96+
steps:
97+
- name: Download digests
98+
uses: actions/download-artifact@v4
99+
with:
100+
path: ${{ runner.temp }}/digests
101+
pattern: digests-*
102+
merge-multiple: true
103+
104+
- name: Login to Docker Hub
105+
uses: docker/login-action@v3
106+
with:
107+
username: ${{ vars.DOCKERHUB_USERNAME }}
108+
password: ${{ secrets.DOCKERHUB_TOKEN }}
109+
110+
- name: Set up Docker Buildx
111+
uses: docker/setup-buildx-action@v3
112+
113+
- name: Docker meta
114+
id: meta
115+
uses: docker/metadata-action@v5
116+
with:
117+
images: ${{ env.REGISTRY_IMAGE }}
118+
tags: |
119+
type=schedule
120+
type=ref,event=branch
121+
type=ref,event=pr
122+
type=semver,pattern={{version}}
123+
type=semver,pattern={{major}}.{{minor}}
124+
type=semver,pattern={{major}}
125+
type=sha
126+
labels: |
127+
org.opencontainers.image.source=${{ github.repository }}
128+
org.opencontainers.image.revision=${{ github.sha }}
129+
130+
- name: Create manifest list and push
131+
working-directory: ${{ runner.temp }}/digests
132+
run: |
133+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
134+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
135+
136+
- name: Inspect image
137+
run: |
138+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)