-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile_deb12_pyjeo
176 lines (150 loc) · 4.74 KB
/
Dockerfile_deb12_pyjeo
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#This dockerfile will create a docker image with a user and python environment
#with pyjeo installed
#user and group settings can be set from host by setting --build-arg, e.g.,
#docker build --build-arg user=$(id -u -n) \
# --build-arg group=$(id -g -n) \
# --build-arg uid=$(id -u) \
# --build-arg gid=$(id -g) \
# --build-arg http_proxy=${http_proxy} \
# --build-arg https_proxy=${https_proxy} \
# -t deb12_pyjeo_public -f Dockerfile_deb12_pyjeo_public .
FROM debian:bookworm as pyjeo-base
LABEL project="pyjeo" \
author="Pieter Kempeneers" \
image_name="deb12_pyjeo_base" \
version="1.1.8" \
released="2024-04-15" \
software_versions="Debian:12 Python:3.11.2 gdal:3.7.1 miallib:1.1.6 jiplib:1.1.5 pyjeo:1.1.11"\
description="multi-stage build for pyjeo"
#
# Environment variables for proxy, user, paths
#
#optional: add proxy settings here
ARG http_proxy=${http_proxy}
ARG https_proxy=${https_proxy}
ENV http_proxy=${http_proxy}
ENV https_proxy=${https_proxy}
#
ARG user=${user}
ARG group=${group}
ARG uid=${uid}
ARG gid=${gid}
ENV user=${user}
ENV group=${group}
ENV uid=${uid}
ENV gid=${gid}
ARG INSTALL_HOME=/home/${user}
ARG VIRTUAL_ENV=/home/${user}/venv
ENV INSTALL_HOME=${INSTALL_HOME}
ENV VIRTUAL_ENV=${VIRTUAL_ENV}
#
# Create user
#
RUN groupadd -g ${gid} ${group} \
&& useradd -u ${uid} -g ${group} -s /bin/bash -m ${user}
#
#Install dependences from the Debian repository
#
RUN apt-get update \
&& apt-get upgrade -y \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
apt-utils \
python3 \
python3-numpy \
python3-wheel \
python3-pip \
sqlite3 \
zlib1g \
python3-virtualenv \
python3-dev \
libjsoncpp-dev \
libgdal-dev \
zlib1g-dev \
libopenblas-dev \
libgeotiff-dev \
libgsl0-dev \
libfann-dev \
libfftw3-dev \
libshp-dev \
uthash-dev \
libboost-serialization-dev \
libboost-filesystem-dev \
&& rm -rf /var/lib/apt/lists/*
FROM pyjeo-base AS pyjeo-build
#
#Install dependences from the Debian repository
#
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
cmake \
pkg-config \
make \
python3-setuptools \
swig \
libtool \
curl \
git \
gzip \
tar \
unzip \
&& rm -rf /var/lib/apt/lists/*
USER ${uid}:${gid}
#
# Compile and build miallib dependency library
#
RUN curl -L --output $INSTALL_HOME/miallib.tar.gz https://github.com/ec-jrc/jeolib-miallib/archive/refs/tags/v1.1.6.tar.gz --verbose
#RUN curl -L --output $INSTALL_HOME/miallib.tar.gz https://github.com/ec-jrc/jeolib-miallib/archive/refs/heads/master.tar.gz --verbose
RUN set -xe \
&& cd $INSTALL_HOME \
&& mkdir ${INSTALL_HOME}/miallib \
&& tar xzvf miallib.tar.gz \
&& cd $INSTALL_HOME/jeolib-miallib* \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_HOME}/miallib .. \
&& cmake --build . \
&& cmake --install . \
&& cd $INSTALL_HOME \
&& rm miallib.tar.gz \
&& rm -rf $INSTALL_HOME/jeolib-miallib*
#
# Compile and build jiplib dependency library
#
RUN curl -L --output $INSTALL_HOME/jiplib.tar.gz https://github.com/ec-jrc/jeolib-jiplib/archive/refs/tags/v1.1.5.tar.gz --verbose
#RUN curl -L --output $INSTALL_HOME/jiplib.tar.gz https://github.com/ec-jrc/jeolib-jiplib/archive/refs/heads/master.tar.gz --verbose
RUN set -xe \
&& cd $INSTALL_HOME \
&& tar xzvf jiplib.tar.gz \
&& cd $INSTALL_HOME/jeolib-jiplib* \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_PREFIX_PATH=${INSTALL_HOME}/miallib .. \
&& cmake --build . \
&& cp jiplib-*.whl $INSTALL_HOME \
&& cd $INSTALL_HOME \
&& rm -rf ${INSTALL_HOME}/miallib \
&& rm jiplib.tar.gz \
&& rm -rf $INSTALL_HOME/jeolib-jiplib*
RUN curl -L --output $INSTALL_HOME/pyjeo.tar.gz https://github.com/ec-jrc/jeolib-pyjeo/archive/refs/tags/v1.1.11.tar.gz --verbose
#RUN curl -L --output $INSTALL_HOME/pyjeo.tar.gz https://github.com/ec-jrc/jeolib-pyjeo/archive/refs/heads/master.tar.gz --verbose
RUN cd $INSTALL_HOME \
&& tar xzvf pyjeo.tar.gz \
&& cd jeolib-pyjeo* \
&& pip3 wheel . \
&& cp pyjeo-*.whl $INSTALL_HOME \
&& cd $INSTALL_HOME \
&& rm -rf jeolib-pyjeo* \
&& rm pyjeo.tar.gz
FROM pyjeo-base AS pyjeo
USER ${uid}:${gid}
COPY --from=pyjeo-build ${INSTALL_HOME} ${INSTALL_HOME}
#
# Install python libraries in virtual environment as user
#
RUN mkdir ${VIRTUAL_ENV} \
&& virtualenv ${VIRTUAL_ENV}/pyjeo \
&& . ${VIRTUAL_ENV}/pyjeo/bin/activate \
&& pip install ${INSTALL_HOME}/jiplib-*.whl \
&& pip install ${INSTALL_HOME}/pyjeo-*.whl
ENV PATH="$VIRTUAL_ENV/pyjeo/bin:$PATH"