-
Notifications
You must be signed in to change notification settings - Fork 50
/
Dockerfile
153 lines (133 loc) · 5.7 KB
/
Dockerfile
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
FROM girder/tox-and-node
LABEL maintainer="Kitware, Inc. <[email protected]>"
ENV LANG=en_US.UTF-8
# Install some additional packages
RUN apt-get update && \
apt-get install -y --no-install-recommends \
# For ease of running tox tests inside containers \
iptables \
dnsutils \
# Install some additional packages for convenience when testing \
bsdmainutils \
iputils-ping \
telnet-ssl \
tmux \
# For developer convenience \
nano \
jq \
# Needed for su command
# sudo \
&& \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
find / -xdev -name '*.py[oc]' -type f -exec rm {} \+ && \
find / -xdev -name __pycache__ -type d -exec rm -r {} \+
# Install docker command line tools. If docker is unavailable, this will do no
# harm. If the host system isn't ubuntu, this should still allow debug.
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list >/dev/null && \
ls -al /etc/apt/sources.list.d && \
cat /etc/apt/sources.list.d/docker.list && \
apt-get update && \
apt-get install -y --no-install-recommends \
docker-ce-cli \
&& \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
find / -xdev -name '*.py[oc]' -type f -exec rm {} \+ && \
find / -xdev -name __pycache__ -type d -exec rm -r {} \+
RUN curl -LJ https://github.com/krallin/tini/releases/download/v0.19.0/tini -o /usr/bin/tini && \
chmod +x /usr/bin/tini
# Make a virtualenv with our preferred python
RUN virtualenv --python 3.11 /opt/venv && \
find / -xdev -name __pycache__ -type d -exec rm -r {} \+
ENV PATH="/opt/venv/bin:$PATH"
# Make sure core packages are up to date
RUN python --version && \
pip install --no-cache-dir -U pip && \
pip install --no-cache-dir -U tox wheel && \
find / -xdev -name __pycache__ -type d -exec rm -r {} \+
# Clone packages and pip install what we want to be local
RUN cd /opt && \
git clone https://github.com/girder/girder && \
cd /opt/girder && \
pip install --no-cache-dir -e .[mount] && \
pip install --no-cache-dir -e clients/python && \
\
cd /opt && \
git clone https://github.com/girder/girder_worker_utils && \
cd /opt/girder_worker_utils && \
pip install --no-cache-dir -e . && \
\
cd /opt && \
git clone https://github.com/girder/girder_worker && \
cd /opt/girder_worker && \
pip install --no-cache-dir -e .[girder,worker] && \
\
cd /opt && \
git clone https://github.com/DigitalSlideArchive/import-tracker.git && \
cd /opt/import-tracker && \
pip install --no-cache-dir -e . && \
\
cd /opt && \
git clone https://github.com/girder/slicer_cli_web && \
cd /opt/slicer_cli_web && \
pip install --no-cache-dir -e . && \
\
cd /opt && \
git clone https://github.com/girder/large_image && \
cd /opt/large_image && \
pip install --no-cache-dir --find-links https://girder.github.io/large_image_wheels -e .[memcached] -rrequirements-dev.txt && \
# Reduce docker size by de-duplicating some libraries that get installed \
rdfind -minsize 32768 -makehardlinks true -makeresultsfile false /opt/venv && \
\
cd /opt && \
git clone https://github.com/DigitalSlideArchive/HistomicsUI && \
cd /opt/HistomicsUI && \
pip install --no-cache-dir -e .[analysis] && \
\
find /opt/venv \( -name '*.so' -o -name '*.a' -o -name '*.so.*' \) -exec bash -c "strip -p -D --strip-unneeded {} -o /tmp/striped; if ! cmp {} /tmp/striped; then cp /tmp/striped {}; fi; rm -f /tmp/striped" \; && \
rdfind -minsize 32768 -makehardlinks true -makeresultsfile false /opt/venv && \
find / -xdev -type d -name __pycache__ -exec rm -r {} \+
# Install additional girder plugins
RUN pip install --no-cache-dir \
girder-hashsum-download \
girder-homepage \
girder-ldap \
girder-resource-path-tools \
girder-user-quota \
girder-virtual-folders \
&& \
\
find / -xdev -type d -name __pycache__ -exec rm -r {} \+
# Build the girder web client
RUN NPM_CONFIG_FUND=false NPM_CONFIG_AUDIT=false NPM_CONFIG_AUDIT_LEVEL=high NPM_CONFIG_LOGLEVEL=warn NPM_CONFIG_PROGRESS=false NPM_CONFIG_PREFER_OFFLINE=true \
girder build && \
# Get rid of unnecessary files to keep the docker image smaller \
find /opt -xdev -name node_modules -exec rm -rf {} \+ && \
find /opt -name package-lock.json -exec rm -f {} \+ && \
rm -rf /tmp/* ~/.npm && \
find / -xdev -type d -name __pycache__ -exec rm -r {} \+
# Install phantomjs for testing
RUN npm install -g phantomjs-prebuilt --unsafe-perm && \
rm -rf /tmp/* ~/.npm
# When running the worker, adjust some settings
RUN echo 'task_reject_on_worker_lost = True' >> /opt/girder_worker/girder_worker/celeryconfig.py
RUN echo 'task_acks_late = True' >> /opt/girder_worker/girder_worker/celeryconfig.py
COPY . /opt/digital_slide_archive
ENV PATH="/opt/digital_slide_archive/devops/dsa/utils:$PATH"
WORKDIR /opt/HistomicsUI
# add a variety of directories
RUN mkdir -p /fuse --mode=a+rwx && \
mkdir /logs && \
mkdir /assetstore && \
mkdir /mounts --mode=a+rwx
RUN cp /opt/digital_slide_archive/devops/dsa/utils/.vimrc ~/.vimrc && \
cp /opt/digital_slide_archive/devops/dsa/girder.cfg /etc/girder.cfg && \
cp /opt/digital_slide_archive/devops/dsa/worker.local.cfg /opt/girder_worker/girder_worker/.
ARG DSA_VERSIONS
ENV DSA_VERSIONS="$DSA_VERSIONS"
# Better shutdown signalling
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["bash"]