forked from ePSIC-DLS/mib2x-crt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
139 lines (116 loc) · 4.1 KB
/
Copy pathDockerfile
File metadata and controls
139 lines (116 loc) · 4.1 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
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
FROM redhat/ubi8:latest as builder
ENV PIP_NO_CACHE_DIR=1 \
HDF5_VERSION='1.14.6' \
NUMPY_VERSION='2.2.5' \
MIB_PROPS_VERSION='1.0.1'
RUN dnf install --disablerepo="*" \
--enablerepo="ubi-8-baseos-rpms" \
--enablerepo="ubi-8-appstream-rpms" \
--enablerepo="ubi-8-codeready-builder-rpms" \
--setopt=install_weak_deps=0 \
--nodocs -y \
gcc \
gcc-c++ \
make \
cmake \
wget \
tar \
zlib-devel \
git-core \
libjpeg-devel \
python3.12 \
python3.12-pip \
python3.12-wheel \
python3.12-setuptools \
python3.12-devel \
python3.12-Cython \
&& dnf clean all
WORKDIR /opt
RUN wget --quiet https://github.com/HDFGroup/hdf5/releases/download/hdf5_${HDF5_VERSION}/hdf5-${HDF5_VERSION}.tar.gz \
&& gzip -cd hdf5-${HDF5_VERSION}.tar.gz | tar xf - \
&& cd hdf5-${HDF5_VERSION} \
&& mkdir -p build \
&& cd build \
&& cmake \
-G "Unix Makefiles" \
-DCMAKE_C_FLAGS:STRING="-mavx2 -O3" \
-DCMAKE_INSTALL_PREFIX:STRING=/usr/local \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DBUILD_STATIC_LIBS:BOOL=OFF \
-DHDF5_BUILD_TOOLS:BOOL=OFF \
-DBUILD_TESTING:BOOL=OFF \
-DHDF5_BUILD_EXAMPLES:BOOL=OFF \
.. \
&& make -j$(nproc) && make install
# numpy without blas
RUN git clone https://github.com/numpy/numpy.git \
&& cd numpy \
&& git switch --detach v"${NUMPY_VERSION}" \
&& git submodule update --init \
&& python3.12 -m pip install . -v \
-Csetup-args="-Dblas=none" \
-Csetup-args="-Dlapack=none" \
-Csetup-args="-Dallow-noblas=true"
# remove other hdf5plugin filter after installation, only need h5blosc
# silent log when fail to initialise other filters
RUN python3.12 -m pip install \
blosc \
&& HDF5_DIR='/usr/local' \
python3.12 -m pip install \
--no-binary=h5py --no-build-isolation \
h5py hdf5plugin \
&& find /usr/local/lib64/python3.12/site-packages/hdf5plugin/plugins/ \
-type f -not -name "libh5blosc.so" -exec rm {} + \
&& sed -i '/Cannot initialize filter/s/^/#/' \
/usr/local/lib64/python3.12/site-packages/hdf5plugin/_utils.py
# PIL with jpeg support
RUN python3.12 -m pip install --no-binary=Pillow Pillow \
-C parallel=$(nproc) \
-C zlib=disable \
-C jpeg=enable \
-C tiff=disable \
-C freetype=disable \
-C raqm=disable \
-C lcms=disable \
-C webp=disable \
-C webpmux=disable \
-C jpeg2000=disable \
-C imagequant=disable \
-C xcb=disable
# build mib_props C extension
RUN git clone https://github.com/ePSIC-DLS/mib_props.git \
&& cd mib_props \
&& git switch --detach v${MIB_PROPS_VERSION} \
&& python3.12 setup.py build_ext --inplace
# build fast_bin C extension
RUN git clone https://github.com/ptim0626/fast_bin_stash.git \
&& cd fast_bin_stash \
&& python3.12 setup.py build_ext --inplace
# install stripped-down HyperSpy/rsciio
COPY hspy_stripped hspy_stripped
RUN python3.12 -m pip install ./hspy_stripped
# add a non-root user
RUN useradd --user-group --create-home ruska
#===============================================================================
FROM redhat/ubi8-minimal:latest
RUN microdnf install --disablerepo="*" \
--enablerepo="ubi-8-baseos-rpms" \
--enablerepo="ubi-8-appstream-rpms" \
--enablerepo="ubi-8-codeready-builder-rpms" \
--setopt=install_weak_deps=0 \
--nodocs -y \
python3.12 \
libgomp \
libstdc++ \
libjpeg \
&& microdnf clean all \
&& rm -rf /usr/share/doc /usr/share/man /usr/share/info
COPY --from=builder /usr/local /usr/local
COPY --from=builder /opt/mib_props/*.so /opt/fast_bin_stash/*.so /usr/local/lib/python3.12/site-packages/
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder /home/ruska /home/ruska
COPY --chown=ruska --chmod=644 mib_convert.py UserExampleJson.json /home/ruska/
ENV PYTHONUNBUFFERED=1
LABEL description='This image converts a .mib file to .hdf5/.hspy alongside other processing such as pixel binning at ePSIC in Diamond Light Source. To build the container, see https://github.com/ePSIC-DLS/mib2x-crt'
WORKDIR /home/ruska