[CI]: Add Dockerfile #489

Merged
synchon merged 5 commits from add/docker_image into main 2026-03-04 16:23:45 +00:00
3 changed files with 152 additions and 0 deletions

69
.github/workflows/docker-publish.yml vendored Normal file
View file

@ -0,0 +1,69 @@
name: Docker
on:
push:
branches: [ "main" ]
paths: [ "Dockerfile" ]
pull_request:
branches: [ "main" ]
paths: [ "Dockerfile" ]
workflow_dispatch: {}
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
id-token: write
steps:
- run: df -h
- name: Clean runner
run: |
sudo rm -rf /usr/share/dotnet \
/usr/local/lib/android \
/opt/ghc \
/opt/hostedtoolcache
sudo docker image prune --all --force
sudo docker builder prune -a
- run: df -h
- name: Checkout repository
uses: actions/checkout@v5
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v4.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.11.1
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3.6.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5.8.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6.18.0
with:
context: .
file: Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

82
Dockerfile Normal file
View file

@ -0,0 +1,82 @@
# syntax=docker/dockerfile:1
FROM python:3.12-slim-bookworm
LABEL org.opencontainers.image.source=https://github.com/juaml/junifer
LABEL org.opencontainers.image.description="Junifer container image"
LABEL org.opencontainers.image.licenses=AGPL-3.0-only
RUN apt-get update && \
apt-get install -y \
pkg-config \
gcc \
git \
git-annex \
make \
curl \
# ANTs runtime stuff
libhdf5-dev \
bc \
# AFNI runtime stuff
libf2c2-dev \
libglew-dev \
libglib2.0-dev \
libglu1-mesa-dev \
libglw1-mesa-dev \
libgsl-dev \
libgts-dev \
libjpeg62-turbo-dev \
libmotif-dev \
libxi-dev \
libxmhtml-dev \
libxmu-dev \
libxpm-dev \
libxt-dev \
netpbm \
libjpeg-progs \
qhull-bin \
r-base \
tcsh \
xvfb \
# FSL runtime stuff
file \
dc \
libquadmath0 \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# Add junifer-data
COPY --from=ghcr.io/juaml/junifer-data:v7 /opt/junifer-data /root/junifer_data/v7
# Add ANTs
COPY --from=antsx/ants:latest /opt/ants /opt/ants
# Set env vars for ANTs
ENV PATH="/opt/ants/bin:$PATH" \
LD_LIBRARY_PATH="/opt/ants/lib"
# Add AFNI
COPY --from=afni/afni_make_build:latest /opt/afni/install /opt/afni/bin
# Set env vars for AFNI
ENV PATH="/opt/afni/bin:$PATH"
# Patch gsl
RUN ln -s /usr/lib/x86_64-linux-gnu/libgsl.so.27 /usr/lib/x86_64-linux-gnu/libgsl.so.23
# Add FSL
RUN curl https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/releases/fslinstaller.py | \
python - -d /opt/fsl/ --skip_registration
# Set env vars for FSL
ENV FSLDIR=/opt/fsl \
FSLOUTPUTTYPE=NIFTI_GZ \
PATH="/opt/fsl/share/fsl/bin:$PATH"
# Clean apt cache
RUN apt-get autoremove --purge && apt-get clean
# Install Python dependencies
RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel
# Checkout latest junifer code and install
RUN git clone --depth 1 --recurse-submodules https://github.com/juaml/junifer.git && \
cd junifer && \
python -m pip install --no-cache-dir ".[all]" && \
cd .. && rm -rf junifer

View file

@ -0,0 +1 @@
Add Dockerfile and a corresponding action for building and publishing the image by `Fede Raimondo`_ and `Synchon Mandal`_