1+ # syntax=docker/dockerfile:1.7
2+
13# "tensorflow" or "tensorflow-gpu"
24ARG TENSORFLOW_TARGET="tensorflow"
35
@@ -23,7 +25,9 @@ FROM --platform=linux/amd64 tensorflow/tensorflow:${TENSORFLOW_VERSION} AS tenso
2325
2426ARG TENSORFLOW_VERSION
2527
26- ENV DEBIAN_FRONTEND="noninteractive" PYTHONDONTWRITEBYTECODE="1" PYTHONUNBUFFERED="1"
28+ ENV DEBIAN_FRONTEND="noninteractive" \
29+ PYTHONDONTWRITEBYTECODE="1" \
30+ PYTHONUNBUFFERED="1"
2731
2832RUN apt-get update && \
2933 apt-get install -yqq python3 python3-pip && \
@@ -35,11 +39,13 @@ RUN apt-get update && \
3539
3640# ######### TENSORFLOW-GPU ##########
3741
38- FROM --platform=linux/amd64 tensorflow/tensorflow:${TENSORFLOW_VERSION}-gpu as tensorflow-gpu
42+ FROM --platform=linux/amd64 tensorflow/tensorflow:${TENSORFLOW_VERSION}-gpu AS tensorflow-gpu
3943
4044ARG TENSORFLOW_VERSION
4145
42- ENV DEBIAN_FRONTEND="noninteractive" PYTHONDONTWRITEBYTECODE="1" PYTHONUNBUFFERED="1"
46+ ENV DEBIAN_FRONTEND="noninteractive" \
47+ PYTHONDONTWRITEBYTECODE="1" \
48+ PYTHONUNBUFFERED="1"
4349
4450RUN apt-get update && \
4551 apt-get install -yqq python3 python3-pip && \
@@ -68,10 +74,92 @@ RUN apt-get update && \
6874# are for arm64-based Mac OS only (no Linux wheels available).
6975
7076
77+ # ######### COMMON BASE FOR NON-TENSORFLOW MULTI-ARCH BUILDS ##########
78+
79+ FROM python:3.10-slim AS steinbock-base
80+
81+ ARG TARGETARCH
82+ ARG STEINBOCK_VERSION
83+ ARG FIXUID_VERSION
84+ ARG TZ="Europe/Zurich"
85+
86+ ENV DEBIAN_FRONTEND="noninteractive" \
87+ PYTHONDONTWRITEBYTECODE="1" \
88+ PYTHONUNBUFFERED="1" \
89+ XDG_RUNTIME_DIR="/tmp"
90+
91+ RUN apt-get update && \
92+ apt-get install -yqq --no-install-recommends \
93+ build-essential \
94+ curl \
95+ git \
96+ locales \
97+ python3-dev \
98+ python3-venv \
99+ mesa-utils \
100+ libgl1 \
101+ libglib2.0-0 \
102+ libfontconfig1 \
103+ libxrender1 \
104+ libdbus-1-3 \
105+ libxkbcommon-x11-0 \
106+ libxi6 \
107+ libxcb-icccm4 \
108+ libxcb-image0 \
109+ libxcb-keysyms1 \
110+ libxcb-randr0 \
111+ libxcb-render-util0 \
112+ libxcb-xinerama0 \
113+ libxcb-xinput0 \
114+ libxcb-xfixes0 \
115+ libxcb-shape0 \
116+ tzdata && \
117+ rm -rf /var/lib/apt/lists/* && \
118+ python -m pip install --upgrade pip setuptools wheel
119+
120+ RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen
121+ ENV LANG="en_US.UTF-8" LANGUAGE="en_US:en" LC_ALL="en_US.UTF-8"
122+ RUN ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime && echo "${TZ}" > /etc/timezone
123+
124+ RUN addgroup --gid 1000 steinbock && \
125+ adduser --uid 1000 --ingroup steinbock --disabled-password --gecos "" steinbock
126+
127+ RUN mkdir /data && chown steinbock:steinbock /data
128+
129+ ENV RUN_FIXUID=1
130+ RUN case "${TARGETARCH}" in \
131+ amd64) FIXUID_ARCH="amd64" ;; \
132+ arm64) FIXUID_ARCH="arm64" ;; \
133+ *) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
134+ esac && \
135+ curl -SsL "https://github.com/boxboat/fixuid/releases/download/v${FIXUID_VERSION}/fixuid-${FIXUID_VERSION}-linux-${FIXUID_ARCH}.tar.gz" | tar -C /usr/local/bin -xzf - && \
136+ chmod 4755 /usr/local/bin/fixuid && \
137+ mkdir -p /etc/fixuid
138+ COPY --chown=root:root fixuid.yml /etc/fixuid/config.yml
139+
140+ RUN python3 -m venv --system-site-packages /opt/steinbock-venv
141+ ENV ROOT_VENV_PATH="${PATH}" \
142+ STEINBOCK_VENV_PATH="/opt/steinbock-venv/bin:${PATH}" \
143+ PATH="/opt/steinbock-venv/bin:${PATH}" \
144+ TF_CPP_MIN_LOG_LEVEL="2" \
145+ NO_AT_BRIDGE="1"
146+
147+ COPY --chown=root:root steinbock /app/steinbock/steinbock/
148+ COPY --chown=root:root requirements.txt requirements_test.txt conftest.py MANIFEST.in pyproject.toml setup.cfg /app/steinbock/
149+
150+ RUN python -m pip install -r /app/steinbock/requirements.txt && \
151+ python -m pip install -r /app/steinbock/requirements_test.txt && \
152+ python -m pip install jupyter jupyterlab
153+
154+ COPY --chown=root:root entrypoint.sh /app/entrypoint.sh
155+
156+
157+
71158# ######### STEINBOCK ##########
72159
73160FROM ${TENSORFLOW_TARGET} AS steinbock
74161
162+ ARG TARGETARCH
75163ARG STEINBOCK_VERSION
76164ARG FIXUID_VERSION
77165ARG ILASTIK_BINARY
@@ -80,7 +168,10 @@ ARG CELLPROFILER_PLUGINS_VERSION
80168ARG CELLPOSE_VERSION
81169ARG TZ="Europe/Zurich"
82170
83- ENV DEBIAN_FRONTEND="noninteractive" PYTHONDONTWRITEBYTECODE="1" PYTHONUNBUFFERED="1" XDG_RUNTIME_DIR="/tmp"
171+ ENV DEBIAN_FRONTEND="noninteractive" \
172+ PYTHONDONTWRITEBYTECODE="1" \
173+ PYTHONUNBUFFERED="1" \
174+ XDG_RUNTIME_DIR="/tmp"
84175
85176# install system packages
86177
@@ -108,9 +199,14 @@ RUN mkdir /data && \
108199# install fixuid
109200
110201ENV RUN_FIXUID=1
111- RUN USER=steinbock && \
202+ RUN case "${TARGETARCH}" in \
203+ amd64) FIXUID_ARCH="amd64" ;; \
204+ arm64) FIXUID_ARCH="arm64" ;; \
205+ *) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
206+ esac && \
207+ USER=steinbock && \
112208 GROUP=steinbock && \
113- curl -SsL "https://github.com/boxboat/fixuid/releases/download/v${FIXUID_VERSION}/fixuid-${FIXUID_VERSION}-linux-amd64 .tar.gz" | tar -C /usr/local/bin -xzf - && \
209+ curl -SsL "https://github.com/boxboat/fixuid/releases/download/v${FIXUID_VERSION}/fixuid-${FIXUID_VERSION}-linux-${FIXUID_ARCH} .tar.gz" | tar -C /usr/local/bin -xzf - && \
114210 chmod 4755 /usr/local/bin/fixuid && \
115211 mkdir -p /etc/fixuid
116212COPY --chown=root:root fixuid.yml /etc/fixuid/config.yml
@@ -121,6 +217,7 @@ RUN mkdir /opt/ilastik && \
121217 curl -SsL "https://files.ilastik.org/${ILASTIK_BINARY}" | tar -C /opt/ilastik -xjf - --strip-components=1
122218
123219# install cellprofiler in cellprofiler-venv
220+ # kept amd64-only because this whole image is tensorflow/amd64-based anyway
124221
125222RUN python3 -m venv --system-site-packages /opt/cellprofiler-venv
126223ENV ROOT_VENV_PATH="${PATH}" CELLPROFILER_VENV_PATH="/opt/cellprofiler-venv/bin:${PATH}"
@@ -161,7 +258,9 @@ RUN python -m pip install -r /app/steinbock/requirements.txt && \
161258 python -m pip install jupyter jupyterlab
162259ENV TF_CPP_MIN_LOG_LEVEL="2" NO_AT_BRIDGE="1"
163260
164- RUN --mount=source=.git,target=/app/steinbock/.git SETUPTOOLS_SCM_PRETEND_VERSION="${STEINBOCK_VERSION#v}" python -m pip install -e "/app/steinbock[imc,deepcell,napari]"
261+ RUN --mount=source=.git,target=/app/steinbock/.git \
262+ SETUPTOOLS_SCM_PRETEND_VERSION="${STEINBOCK_VERSION#v}" \
263+ python -m pip install -e "/app/steinbock[imc,deepcell,napari]"
165264
166265RUN mkdir -p /opt/keras/models && \
167266 curl -SsL https://deepcell-data.s3-us-west-1.amazonaws.com/saved-models/MultiplexSegmentation-9.tar.gz | tar -C /opt/keras/models -xzf -
@@ -178,17 +277,31 @@ EXPOSE 8888
178277
179278# ######### STEINBOCK-CELLPOSE ##########
180279
181- FROM steinbock AS steinbock-cellpose
280+ FROM steinbock-base AS steinbock-cellpose
182281
282+ ARG STEINBOCK_VERSION
183283ARG CELLPOSE_VERSION
184284
185- USER root:root
285+ ENV PATH="/opt/steinbock-venv/bin:${PATH}"
286+
287+ # install steinbock without tensorflow/deepcell extras
288+ RUN --mount=source=.git,target=/app/steinbock/.git \
289+ SETUPTOOLS_SCM_PRETEND_VERSION="${STEINBOCK_VERSION#v}" \
290+ python -m pip install -e "/app/steinbock[imc,napari]"
291+
292+ # install cellpose natively per architecture
186293RUN python -m pip install "cellpose==${CELLPOSE_VERSION}"
187- USER steinbock:steinbock
188294
295+ USER root:root
189296RUN mkdir -p /home/steinbock/.cellpose/models && \
190297 curl -L -sS -o /home/steinbock/.cellpose/models/cpsam \
191- https://huggingface.co/mouseland/cellpose-sam/resolve/main/cpsam
298+ https://huggingface.co/mouseland/cellpose-sam/resolve/main/cpsam && \
299+ chown -R steinbock:steinbock /home/steinbock/.cellpose
300+
301+ WORKDIR /data
302+ USER steinbock:steinbock
303+ ENTRYPOINT ["/app/entrypoint.sh" ]
304+ EXPOSE 8888
192305
193306
194307
@@ -223,4 +336,4 @@ CMD test ${RUN_FIXUID} && eval $( fixuid -q ); \
223336 echo "Launching steinbock on Xpra; connect via http://localhost:${XPRA_PORT}" ; \
224337 xpra start --daemon=no --uid=$(id -u) --gid=$(id -g) --bind-tcp="0.0.0.0:${XPRA_PORT}" --start-child="${XPRA_START}" --exit-with-children=yes --exit-with-client=yes --xvfb="/usr/bin/Xvfb +extension Composite -screen 0 ${XPRA_XVFB_SCREEN} -nolisten tcp -noreset" --html=on --notifications=no --bell=no --webcam=no --pulseaudio=no ${DISPLAY}
225338ENTRYPOINT []
226- EXPOSE 8888 ${XPRA_PORT}
339+ EXPOSE 8888 ${XPRA_PORT}
0 commit comments