forked from camicroscope/SlideLoader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
108 lines (83 loc) · 3.61 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
#FROM cgd30/openslide:v8main
FROM cgd30/decoders:jvmv16
WORKDIR /var/www
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ="America/New_York"
RUN apt-get update
RUN apt-get autoclean
RUn apt-get clean
RUN apt-get -q update --fix-missing
RUN apt-get -q install -y python3-pip vim
RUN apt-get -q install -y openssl libcurl4-openssl-dev libssl-dev
# Tony has a future use case where we may adapt caMic to GIS visualization
# install libvips-dev for pyvips. No need for libvips.
RUN apt-get -q install -y libvips-dev
# But, build libvips instead of using libvips-dev from apt
# Build without OpenSlide to open images with rather ImageMagick to handle
# images without pyramids. Otherwise opens e.g. DICOM with OpenSlide so conversion
# of files OpenSlide cannot open does not help at all.
# So, we'll have two copies on openslide on the system.
# By changing LD_LIBRARY_PATH before we launch python
# we can choose which openslide to run
RUN apt-get -q install -y libjpeg-turbo8-dev libexif-dev libgsf-1-dev libtiff-dev libfftw3-dev liblcms2-dev libpng-dev libmagickcore-dev libmagickwand-dev liborc-0.4-dev libopenjp2-7 libgirepository1.0-dev
WORKDIR /root/src
RUN git clone https://github.com/cgdogan/libvips.git --depth=1 --branch=patch-1
RUN mkdir /root/src/libvips/build
WORKDIR /root/src/libvips
RUN mkdir /usr/local/vips-no-openslide/
# normally --prefix=/usr/local/ --libdir=lib build
RUN meson setup -Dopenjpeg=enabled -Dopenslide=disabled --buildtype=release --prefix=/usr/local/vips-no-openslide/ --libdir=lib build
RUN meson compile -C build
RUN meson test -C build
RUN meson install -C build
WORKDIR /root/src
RUN pip install pyvips --break-system-packages
RUN pip install flask --break-system-packages
RUN pip install gunicorn --break-system-packages
RUN pip install greenlet --break-system-packages
RUN pip install gunicorn[eventlet] --break-system-packages
# verify pyvips can call libvips
RUN python3 -c "import pyvips"
# verify that the apt libvips has openslide
ADD test_imgs/CMU-1-Small-Region.svs .
RUN python3 -c "import pyvips; pyvips.Image.openslideload(('CMU-1-Small-Region.svs'))"
# back up previous ld_library_path
ENV LD_LIBRARY_PATH_ORIG="${LD_LIBRARY_PATH}"
# now, prioritize openslideless libvips
# the path shown in output lines of "meson install" where .so.42 are installed
# normally /usr/local/lib/:
ENV LD_LIBRARY_PATH="/usr/local/vips-no-openslide/lib/:${LD_LIBRARY_PATH}"
# verify that this libvips has no openslide
RUN ! python3 -c "import pyvips; pyvips.Image.openslideload(('CMU-1-Small-Region.svs'))"
# ok, so to recap,
# there are two libvips are installed and which one pyvips connects to
# is chosen when "import pyvips" is run.
# at this point in this dockerfile,
# ld_library_path is set so that no-openslide version is run
# but if you do LD_LIBRARY_PATH="${LD_LIBRARY_PATH_ORIG}" python a.py
# or likewise using docker ENV command or os.environ in python before
# importing, this will remove the no-openslide libvips from path.
run openssl version -a
ENV FLASK_ENV development
RUN mkdir -p /images/uploading
COPY requirements.txt .
RUN pip3 install -r requirements.txt --break-system-packages
COPY ./ ./
RUN cp test_imgs/* /images/
RUN cd bfbridge && python3 setup_test_bfbridge.py
ENV BFBRIDGE_CACHEDIR=/tmp/
EXPOSE 4000
EXPOSE 4001
#debug/dev only
ENV FLASK_APP SlideServer.py
CMD python3 -m flask run --host=0.0.0.0 --port=4000
# The Below BROKE the ability for users to upload images.
# # non-root user
# RUN chgrp -R 0 /var && \
# chmod -R g+rwX /var && \
# chgrp -R 0 /images/uploading && \
# chmod -R g+rwX /images/uploading
#
# USER 1001
#prod only
#CMD gunicorn -w 4 -b 0.0.0.0:4000 SlideServer:app --timeout 400