Skip to content

Commit 2403718

Browse files
committed
docker: local cache, devel build with full build env
1 parent f42467f commit 2403718

5 files changed

Lines changed: 41 additions & 26 deletions

File tree

Dockerfile

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ USER root
77
# suppress warnings
88
ENV DEBIAN_FRONTEND=noninteractive
99
COPY docker/raw-ubuntu.sh /opt/scripts/
10-
RUN bash /opt/scripts/raw-ubuntu.sh
10+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked bash /opt/scripts/raw-ubuntu.sh
1111
#ENV LC_ALL=en_GB.UTF-8
1212
ENV LANG=en_GB.UTF-8
1313
ENV LANGUAGE=en_GB:en
1414

1515
COPY docker/build_gadgetron-ubuntu.sh /opt/scripts/
16-
RUN bash /opt/scripts/build_gadgetron-ubuntu.sh
16+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked bash /opt/scripts/build_gadgetron-ubuntu.sh
1717

1818
# SIRF external deps
1919
COPY docker/build_system-ubuntu.sh /opt/scripts/
20-
RUN bash /opt/scripts/build_system-ubuntu.sh
20+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked bash /opt/scripts/build_system-ubuntu.sh
2121

2222
# SIRF python deps
2323
ARG BUILD_GPU=0
@@ -35,13 +35,12 @@ RUN if test "$BUILD_GPU" != 0; then \
3535
FROM base AS build
3636

3737
COPY docker/update_nvidia_keys.sh /opt/scripts/
38-
RUN bash /opt/scripts/update_nvidia_keys.sh
38+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked bash /opt/scripts/update_nvidia_keys.sh
3939

4040
COPY docker/build_essential-ubuntu.sh /opt/scripts/
41-
RUN bash /opt/scripts/build_essential-ubuntu.sh
41+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked bash /opt/scripts/build_essential-ubuntu.sh
4242

4343
# ccache
44-
COPY --link docker/devel/.ccache/ /opt/ccache/
4544
RUN ccache -o cache_dir=/opt/ccache
4645
ENV PATH="/usr/lib/ccache:${PATH}"
4746

@@ -72,7 +71,7 @@ ARG EXTRA_BUILD_FLAGS=""
7271

7372
# build, install in /opt/SIRF-SuperBuild/{INSTALL,sources/SIRF}, test (if RUN_CTEST)
7473
COPY docker/user_sirf-ubuntu.sh /opt/scripts/
75-
RUN BUILD_FLAGS="-G Ninja\
74+
RUN --mount=type=cache,target=/opt/ccache BUILD_FLAGS="-G Ninja\
7675
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}\
7776
-DSTIR_ENABLE_OPENMP=${STIR_ENABLE_OPENMP}\
7877
-DSTIR_DISABLE_HDF5=${STIR_DISABLE_HDF5}\
@@ -97,12 +96,10 @@ RUN RUN_BUILD=0 \
9796
bash /opt/scripts/user_sirf-ubuntu.sh \
9897
&& fix-permissions /opt/SIRF-SuperBuild /opt/ccache
9998

100-
FROM base AS sirf
101-
10299
# X11 forwarding
103-
RUN apt update -qq && apt install -yq --no-install-recommends \
100+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked apt update -qq && apt install -yq --no-install-recommends \
104101
libx11-xcb1 \
105-
&& apt clean \
102+
&& rm -rf /var/lib/apt/lists \
106103
&& mkdir -p /usr/share/X11/xkb \
107104
&& test -e /usr/bin/X || ln -s /usr/bin/Xorg /usr/bin/X
108105

@@ -111,6 +108,34 @@ RUN echo 'test -z "$OMP_NUM_THREADS" && export OMP_NUM_THREADS=$(python -c "impo
111108
COPY --chown=${NB_USER} --chmod=644 --link docker/.bashrc /home/${NB_USER}/
112109
# RUN sed -i s:PYTHON_INSTALL_DIR:${CONDA_DIR}:g /home/${NB_USER}/.bashrc
113110

111+
# docker-stacks notebook
112+
#ENV DOCKER_STACKS_JUPYTER_CMD="notebook"
113+
ENV RESTARTABLE="yes"
114+
#ENV USE_HTTPS="yes"
115+
# gadgetron
116+
EXPOSE 9002
117+
ENV GADGETRON_RELAY_HOST="0.0.0.0"
118+
COPY --link docker/15source-sirf.sh docker/25clone-work.sh docker/35gadgetron.sh /usr/local/bin/before-notebook.d/
119+
ENV NOTEBOOK_ARGS=--PasswordIdentityProvider.hashed_password='sha1:cbf03843d2bb:8729d2fbec60cacf6485758752789cd9989e756c'
120+
121+
# copy ccache from cache mount
122+
RUN --mount=type=cache,target=/opt/ccache cp -a /opt/ccache /opt/tmp-ccache
123+
RUN rm -rf /opt/ccache && mv /opt/tmp-ccache /opt/ccache && fix-permissions /opt/ccache
124+
125+
FROM build AS sirf-dev
126+
127+
# install {SIRF-Exercises,CIL-Demos}
128+
COPY docker/user_demos.sh /opt/scripts/
129+
ARG BUILD_GPU
130+
RUN BUILD_GPU=${BUILD_GPU} bash /opt/scripts/user_demos.sh \
131+
&& fix-permissions /opt/SIRF-Exercises /opt/CIL-Demos "${CONDA_DIR}" /home/${NB_USER}
132+
133+
# docker-stacks notebook
134+
USER ${NB_UID}
135+
ENV DEBIAN_FRONTEND=''
136+
137+
FROM base AS sirf
138+
114139
# install from build
115140
COPY --from=build --link --chown=${NB_USER} /opt/SIRF-SuperBuild/INSTALL/ /opt/SIRF-SuperBuild/INSTALL/
116141
#COPY --from=build --link --chown=${NB_USER} /opt/SIRF-SuperBuild/sources/SIRF/ /opt/SIRF-SuperBuild/sources/SIRF/
@@ -126,13 +151,3 @@ RUN BUILD_GPU=${BUILD_GPU} bash /opt/scripts/user_demos.sh \
126151
# docker-stacks notebook
127152
USER ${NB_UID}
128153
ENV DEBIAN_FRONTEND=''
129-
#ENV DOCKER_STACKS_JUPYTER_CMD="notebook"
130-
ENV RESTARTABLE="yes"
131-
#ENV USE_HTTPS="yes"
132-
# gadgetron
133-
EXPOSE 9002
134-
ENV GADGETRON_RELAY_HOST="0.0.0.0"
135-
136-
# COPY --from=build --link --chown=${NB_USER} /opt/SIRF-SuperBuild/INSTALL/lib /opt/conda/lib
137-
COPY --link docker/15source-sirf.sh docker/25clone-work.sh docker/35gadgetron.sh /usr/local/bin/before-notebook.d/
138-
ENV NOTEBOOK_ARGS=--PasswordIdentityProvider.hashed_password='sha1:cbf03843d2bb:8729d2fbec60cacf6485758752789cd9989e756c'

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ services:
2929
# convenience volume & command to copy image::/opt/ccache to localhost::./docker/devel/.ccache
3030
# (executed in ./docker/compose.sh by `docker compose up sirf-build`)
3131
volumes: [./docker/devel/.ccache:/ccache]
32-
command: "bash -c 'cp -r /opt/ccache/* /ccache/'"
32+
entrypoint: "/bin/bash -c"
33+
command: ["cp -r /opt/ccache/* /ccache/"]
3334
image: synerbi/jupyter:sirf-build-cpu
3435
build:
3536
context: .
@@ -43,6 +44,7 @@ services:
4344
image: synerbi/sirf:latest
4445
build:
4546
context: .
47+
target: sirf
4648
args:
4749
BASE_IMAGE: synerbi/jupyter:scipy-cpu
4850
Gadgetron_USE_CUDA: "OFF"

docker/docker-compose.devel-gpu.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ services:
55
image: synerbi/sirf:devel-gpu
66
build:
77
cache_from: [synerbi/jupyter:sirf-build-devel-gpu]
8+
target: sirf-dev

docker/docker-compose.devel.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ services:
33
image: synerbi/jupyter:sirf-build-devel-cpu
44
build:
55
args:
6-
BUILD_CIL: "ON"
76
EXTRA_BUILD_FLAGS: >
87
-DDEVEL_BUILD=ON
98
sirf:
109
container_name: sirf # for scaling, comment this out https://github.com/docker/compose/issues/3729
1110
image: synerbi/sirf:devel
1211
build:
1312
context: .
13+
target: sirf-dev
1414
args:
15-
BUILD_CIL: "ON"
1615
EXTRA_BUILD_FLAGS: >
1716
-DDEVEL_BUILD=ON
1817
cache_from: [synerbi/jupyter:sirf-build-devel-cpu]

docker/docker-compose.gpu.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ services:
2525
BASE_IMAGE: synerbi/jupyter:scipy-gpu
2626
BUILD_GPU: 1
2727
Gadgetron_USE_CUDA: "ON"
28-
BUILD_CIL: "ON"
2928
sirf:
3029
deploy: {resources: {reservations: {devices: [{driver: nvidia, count: all, capabilities: [gpu]}]}}}
3130
image: synerbi/sirf:latest-gpu
@@ -34,5 +33,4 @@ services:
3433
BASE_IMAGE: synerbi/jupyter:scipy-gpu
3534
BUILD_GPU: 1
3635
Gadgetron_USE_CUDA: "ON"
37-
BUILD_CIL: "ON"
3836
cache_from: [synerbi/jupyter:sirf-build-gpu]

0 commit comments

Comments
 (0)