-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (62 loc) · 2.35 KB
/
Dockerfile
File metadata and controls
73 lines (62 loc) · 2.35 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
FROM ubuntu:22.04
ARG USER_UID=1001
ARG USER_GID=1001
ENV PYTHONUNBUFFERED=1
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Amsterdam
ENV PATH="/home/user/.local/bin:${PATH}"
# Create user and I/O dirs
RUN groupadd --gid ${USER_GID} user \
&& useradd -m --no-log-init --uid ${USER_UID} --gid ${USER_GID} user \
&& mkdir /input /output \
&& chown user:user /input /output
WORKDIR /opt/app
RUN apt-get update && apt-get install -y --no-install-recommends \
libtiff-dev \
zlib1g-dev \
curl \
cmake \
vim screen \
zip unzip \
git \
openssh-server \
build-essential \
ninja-build \
python3-pip python3-dev python-is-python3 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# libjpeg-turbo 3.x (required by PyTurboJPEG>=2)
ARG LIBJPEG_TURBO_VERSION=3.1.0
RUN curl -fsSL https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/${LIBJPEG_TURBO_VERSION}/libjpeg-turbo-${LIBJPEG_TURBO_VERSION}.tar.gz \
| tar xz -C /tmp \
&& cd /tmp/libjpeg-turbo-${LIBJPEG_TURBO_VERSION} \
&& cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr/local . \
&& make -j"$(nproc)" && make install \
&& ldconfig \
&& rm -rf /tmp/libjpeg-turbo-${LIBJPEG_TURBO_VERSION}
# ASAP
ARG ASAP_URL=https://github.com/computationalpathologygroup/ASAP/releases/download/ASAP-2.2-(Nightly)/ASAP-2.2-Ubuntu2204.deb
RUN set -eux; \
apt-get update; \
curl -L "${ASAP_URL}" -o /tmp/ASAP.deb; \
apt-get install -y --no-install-recommends /tmp/ASAP.deb; \
SITE_PACKAGES=$(python3 -c "import sysconfig; print(sysconfig.get_paths()['purelib'])"); \
printf "/opt/ASAP/bin/\n" > "${SITE_PACKAGES}/asap.pth"; \
rm -f /tmp/ASAP.deb; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*
# Python deps & pyproject-based package install
RUN python -m pip install --upgrade pip "setuptools>=61" wheel pip-tools \
&& rm -rf /root/.cache/pip
ARG PYTORCH_CUDA_INDEX_URL=https://download.pytorch.org/whl/cu128
ARG GIT_MODEL_DEPENDENCIES="git+https://github.com/facebookresearch/sam2.git"
COPY --chown=user:user pyproject.toml README.md LICENSE /opt/app/
COPY --chown=user:user hs2p /opt/app/hs2p
RUN python -m pip install \
--no-cache-dir \
--no-color \
--extra-index-url "${PYTORCH_CUDA_INDEX_URL}" \
"/opt/app[all,sam2]" \
${GIT_MODEL_DEPENDENCIES} \
&& rm -rf /root/.cache/pip
USER user