Skip to content

Commit 69aa5fa

Browse files
authored
Merge pull request #63 from nipreps/maint/gha-docker
MNT: Add GHA for Docker build
2 parents 3dcd964 + 93a1991 commit 69aa5fa

File tree

2 files changed

+69
-5
lines changed

2 files changed

+69
-5
lines changed

.github/workflows/docker.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Docker build
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ "master", "main", "maint/*", "gha-docker-build" ]
7+
tags: "*"
8+
pull_request:
9+
branches: [ "master", "main", "maint/*" ]
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
env:
16+
REGISTRY: ghcr.io
17+
IMAGE_NAME: ${{ github.repository }}
18+
FORCE_COLOR: true
19+
20+
jobs:
21+
build-container:
22+
runs-on: docker
23+
permissions:
24+
contents: read
25+
packages: write
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v5
29+
with:
30+
fetch-depth: 200
31+
fetch-tags: true
32+
33+
- name: Setup Docker buildx
34+
uses: docker/setup-buildx-action@v3
35+
36+
- name: Log into registry ${{ env.REGISTRY }}
37+
if: github.event_name != 'pull_request'
38+
uses: docker/login-action@v3
39+
with:
40+
registry: ${{ env.REGISTRY }}
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Extract Docker metadata
45+
id: meta
46+
uses: docker/metadata-action@v5
47+
with:
48+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
49+
50+
- name: Build and push Docker image
51+
uses: docker/build-push-action@v6
52+
with:
53+
context: .
54+
push: ${{ github.event_name != 'pull_request' }}
55+
tags: ${{ steps.meta.outputs.tags }}
56+
labels: ${{ steps.meta.outputs.labels }}
57+
platforms: linux/amd64
58+
cache-from: |
59+
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:master
60+
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TARGET_BRANCH }}
61+
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags[0] }}
62+
cache-to: type=inline
63+
env:
64+
TARGET_BRANCH: ${{ github.base_ref || github.ref_name }}

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ RUN apt-get update && \
5151
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
5252

5353
# FreeSurfer 7.4.1
54-
FROM downloader AS freesurfer
55-
COPY docker/files/freesurfer7.4.1-exclude.txt /usr/local/etc/freesurfer7.4.1-exclude.txt
56-
RUN curl -sSL https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer-linux-ubuntu22_amd64-7.4.1.tar.gz \
57-
| tar zxv --no-same-owner -C /opt --exclude-from=/usr/local/etc/freesurfer7.4.1-exclude.txt
54+
# FROM downloader AS freesurfer
55+
# COPY docker/files/freesurfer7.4.1-exclude.txt /usr/local/etc/freesurfer7.4.1-exclude.txt
56+
# RUN curl -sSL https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer-linux-ubuntu22_amd64-7.4.1.tar.gz \
57+
# | tar zxv --no-same-owner -C /opt --exclude-from=/usr/local/etc/freesurfer7.4.1-exclude.txt
5858

5959
# AFNI
6060
FROM downloader AS afni
@@ -173,7 +173,7 @@ RUN apt-get update -qq \
173173
&& ldconfig
174174

175175
# Install files from stages
176-
COPY --from=freesurfer /opt/freesurfer /opt/freesurfer
176+
COPY --from=freesurfer/freesurfer:7.4.1 /usr/local/freesurfer /opt/freesurfer
177177
COPY --from=afni /opt/afni-latest /opt/afni-latest
178178
COPY --from=petpvc /usr/local /usr/local
179179

0 commit comments

Comments
 (0)