-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathDockerfile
More file actions
131 lines (111 loc) · 3.42 KB
/
Dockerfile
File metadata and controls
131 lines (111 loc) · 3.42 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Ubuntu 22.04 LTS - Jammy
ARG BASE_IMAGE=ubuntu:jammy-20250730
#
# Build wheel
#
FROM ghcr.io/astral-sh/uv:python3.13-alpine AS src
RUN apk add git
COPY . /src
RUN uv build --wheel /src
#
# Download stages
#
# Utilities for downloading packages
FROM ${BASE_IMAGE} AS downloader
# Bump the date to current to refresh curl/certificates/etc
RUN echo "2025.09.25"
RUN apt-get update && \
apt-get install -y --no-install-recommends \
binutils \
bzip2 \
ca-certificates \
curl \
unzip && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN update-ca-certificates -f
# Micromamba
FROM downloader AS micromamba
WORKDIR /
# Bump the date to current to force update micromamba
RUN echo "2025.09.05"
RUN curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
ENV MAMBA_ROOT_PREFIX="/opt/conda"
COPY env.yml /tmp/env.yml
WORKDIR /tmp
RUN micromamba create -y -f /tmp/env.yml && \
micromamba clean -y -a
#
# Main stage
#
FROM ${BASE_IMAGE} AS nitransforms
# Configure apt
ENV DEBIAN_FRONTEND="noninteractive" \
LANG="en_US.UTF-8" \
LC_ALL="en_US.UTF-8"
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libexpat1 \
libgomp1 \
&& \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install FreeSurfer and AFNI bins from images
COPY --from=freesurfer/freesurfer:7.4.1 \
/usr/local/freesurfer/bin/mri_vol2vol \
/usr/local/freesurfer/bin/
COPY --from=afni/afni_make_build:AFNI_25.2.09 \
/opt/afni/install/libf2c.so \
/opt/afni/install/libmri.so \
/usr/local/lib/
COPY --from=afni/afni_make_build:AFNI_25.2.09 \
/opt/afni/install/3dAllineate \
/opt/afni/install/3dNwarpApply \
/opt/afni/install/3dWarp \
/opt/afni/install/3drefit \
/opt/afni/install/3dvolreg \
/usr/local/bin/
# Simulate SetUpFreeSurfer.sh
ENV OS="Linux" \
FS_OVERRIDE=0 \
FIX_VERTEX_AREA="" \
FSF_OUTPUT_FORMAT="nii.gz" \
FREESURFER_HOME="/usr/local/freesurfer"
ENV SUBJECTS_DIR="$FREESURFER_HOME/subjects" \
FUNCTIONALS_DIR="$FREESURFER_HOME/sessions" \
LOCAL_DIR="$FREESURFER_HOME/local" \
PATH="$FREESURFER_HOME/bin:$PATH"
# AFNI config
ENV AFNI_IMSAVE_WARNINGS="NO"
# Create a shared $HOME directory
RUN useradd -m -s /bin/bash -G users neuro
WORKDIR /home/neuro
ENV HOME="/home/neuro"
COPY --from=micromamba /bin/micromamba /bin/micromamba
COPY --from=micromamba /opt/conda/envs/nitransforms /opt/conda/envs/nitransforms
ENV MAMBA_ROOT_PREFIX="/opt/conda"
RUN micromamba shell init -s bash && \
echo "micromamba activate nitransforms" >> $HOME/.bashrc
ENV PATH="/opt/conda/envs/nitransforms/bin:$PATH"
# FSL environment
ENV LANG="C.UTF-8" \
LC_ALL="C.UTF-8" \
PYTHONNOUSERSITE=1 \
FSLDIR="/opt/conda/envs/nitransforms" \
FSLOUTPUTTYPE="NIFTI_GZ" \
FSLMULTIFILEQUIT="TRUE" \
FSLLOCKDIR="" \
FSLMACHINELIST="" \
FSLREMOTECALL="" \
FSLGECUDAQ="cuda.q"
# Install package
COPY --from=src /src/dist/*.whl .
RUN python -m pip install --no-cache-dir $( ls *.whl )[all]
RUN ldconfig
WORKDIR /tmp/
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="nitransforms" \
org.label-schema.vcs-url="https://github.com/nipy/nitransforms" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0"