1 | # |
---|
2 | # Base: Ubuntu 18.04 with updates and external packages |
---|
3 | # |
---|
4 | FROM ubuntu:bionic-20201119 AS base |
---|
5 | ARG DEBIAN_FRONTEND=noninteractive |
---|
6 | ARG BUILD_DEPS=" \ |
---|
7 | dirmngr \ |
---|
8 | gpg-agent \ |
---|
9 | software-properties-common \ |
---|
10 | " |
---|
11 | ARG RUN_DEPS=" \ |
---|
12 | libcurl3-gnutls \ |
---|
13 | libfcgi \ |
---|
14 | libmapserver-dev \ |
---|
15 | libmozjs185-dev \ |
---|
16 | libpq5 \ |
---|
17 | libpython3.6 \ |
---|
18 | libxslt1.1 \ |
---|
19 | gdal-bin \ |
---|
20 | libcgal13 \ |
---|
21 | python3 \ |
---|
22 | r-base \ |
---|
23 | python3-pip\ |
---|
24 | " |
---|
25 | RUN set -ex \ |
---|
26 | && apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \ |
---|
27 | \ |
---|
28 | && add-apt-repository ppa:osgeolive/nightly \ |
---|
29 | && add-apt-repository ppa:ubuntugis/ppa \ |
---|
30 | && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 \ |
---|
31 | && add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/' \ |
---|
32 | \ |
---|
33 | && apt-get install -y $RUN_DEPS \ |
---|
34 | \ |
---|
35 | && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \ |
---|
36 | && rm -rf /var/lib/apt/lists/* |
---|
37 | |
---|
38 | # |
---|
39 | # builder1: base image with zoo-kernel |
---|
40 | # |
---|
41 | FROM base AS builder1 |
---|
42 | ARG DEBIAN_FRONTEND=noninteractive |
---|
43 | ARG BUILD_DEPS=" \ |
---|
44 | bison \ |
---|
45 | flex \ |
---|
46 | make \ |
---|
47 | autoconf \ |
---|
48 | gcc \ |
---|
49 | gettext-base \ |
---|
50 | \ |
---|
51 | libfcgi-dev \ |
---|
52 | libgdal-dev \ |
---|
53 | libjson-c-dev \ |
---|
54 | libssh2-1-dev \ |
---|
55 | libssl-dev \ |
---|
56 | libxml2-dev \ |
---|
57 | libxslt1-dev \ |
---|
58 | python3-dev \ |
---|
59 | uuid-dev \ |
---|
60 | r-base-dev \ |
---|
61 | " |
---|
62 | WORKDIR /zoo-project |
---|
63 | COPY . . |
---|
64 | |
---|
65 | RUN set -ex \ |
---|
66 | && apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \ |
---|
67 | \ |
---|
68 | && make -C ./thirds/cgic206 libcgic.a \ |
---|
69 | \ |
---|
70 | && cd ./zoo-project/zoo-kernel \ |
---|
71 | && autoconf \ |
---|
72 | && ./configure --with-python=/usr --with-pyvers=3.6 --with-js=/usr --with-mapserver=/usr --with-ms-version=7 --with-json=/usr --with-db-backend --prefix=/usr \ |
---|
73 | && make \ |
---|
74 | && make install \ |
---|
75 | \ |
---|
76 | # TODO: why not copied by 'make'? |
---|
77 | && cp zoo_loader.cgi main.cfg /usr/lib/cgi-bin/ \ |
---|
78 | && cp ../zoo-services/hello-py/cgi-env/* /usr/lib/cgi-bin/ \ |
---|
79 | && cp ../zoo-services/hello-js/cgi-env/* /usr/lib/cgi-bin/ \ |
---|
80 | && cp ../zoo-api/js/* /usr/lib/cgi-bin/ \ |
---|
81 | && cp ../zoo-services/utils/open-api/cgi-env/* /usr/lib/cgi-bin/ \ |
---|
82 | && cp ../zoo-services/hello-py/cgi-env/* /usr/lib/cgi-bin/ \ |
---|
83 | && cp ../zoo-services/hello-js/cgi-env/* /usr/lib/cgi-bin/ \ |
---|
84 | && cp ../zoo-api/js/* /usr/lib/cgi-bin/ \ |
---|
85 | \ |
---|
86 | && cp oas.cfg /usr/lib/cgi-bin/ \ |
---|
87 | \ |
---|
88 | # TODO: main.cfg is not processed \ |
---|
89 | && prefix=/usr envsubst < main.cfg > /usr/lib/cgi-bin/main.cfg \ |
---|
90 | \ |
---|
91 | && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \ |
---|
92 | && rm -rf /var/lib/apt/lists/* |
---|
93 | |
---|
94 | # |
---|
95 | # Optional zoo modules build. |
---|
96 | # |
---|
97 | FROM base AS builder2 |
---|
98 | ARG DEBIAN_FRONTEND=noninteractive |
---|
99 | ARG BUILD_DEPS=" \ |
---|
100 | bison \ |
---|
101 | flex \ |
---|
102 | make \ |
---|
103 | autoconf \ |
---|
104 | g++ \ |
---|
105 | gcc \ |
---|
106 | libc-dev \ |
---|
107 | libfcgi-dev \ |
---|
108 | libgdal-dev \ |
---|
109 | libxml2-dev \ |
---|
110 | libxslt1-dev \ |
---|
111 | libcgal-dev \ |
---|
112 | " |
---|
113 | WORKDIR /zoo-project |
---|
114 | COPY ./zoo-project/zoo-services ./zoo-project/zoo-services |
---|
115 | |
---|
116 | # From zoo-kernel |
---|
117 | COPY --from=builder1 /usr/lib/cgi-bin/ /usr/lib/cgi-bin/ |
---|
118 | COPY --from=builder1 /usr/lib/libzoo_service.so.1.8 /usr/lib/libzoo_service.so.1.8 |
---|
119 | COPY --from=builder1 /usr/lib/libzoo_service.so /usr/lib/libzoo_service.so |
---|
120 | COPY --from=builder1 /usr/com/zoo-project/ /usr/com/zoo-project/ |
---|
121 | COPY --from=builder1 /usr/include/zoo/ /usr/include/zoo/ |
---|
122 | |
---|
123 | # Additional files from bulder2 |
---|
124 | COPY --from=builder1 /zoo-project/zoo-project/zoo-kernel/ZOOMakefile.opts /zoo-project/zoo-project/zoo-kernel/ZOOMakefile.opts |
---|
125 | COPY --from=builder1 /zoo-project/zoo-project/zoo-kernel/sqlapi.h /zoo-project/zoo-project/zoo-kernel/sqlapi.h |
---|
126 | COPY --from=builder1 /zoo-project/zoo-project/zoo-kernel/service.h /zoo-project/zoo-project/zoo-kernel/service.h |
---|
127 | COPY --from=builder1 /zoo-project/zoo-project/zoo-kernel/service_internal.h /zoo-project/zoo-project/zoo-kernel/service_internal.h |
---|
128 | COPY --from=builder1 /zoo-project/zoo-project/zoo-kernel/version.h /zoo-project/zoo-project/zoo-kernel/version.h |
---|
129 | |
---|
130 | RUN set -ex \ |
---|
131 | && apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \ |
---|
132 | \ |
---|
133 | && cd ./zoo-project/zoo-services/utils/status \ |
---|
134 | && make \ |
---|
135 | && make install \ |
---|
136 | \ |
---|
137 | && cd ../../cgal \ |
---|
138 | && make \ |
---|
139 | && cp cgi-env/* /usr/lib/cgi-bin/ \ |
---|
140 | \ |
---|
141 | && cd .. \ |
---|
142 | && cd ../zoo-services/ogr/base-vect-ops \ |
---|
143 | && make \ |
---|
144 | && cp cgi-env/* /usr/lib/cgi-bin/ \ |
---|
145 | && cd ../.. \ |
---|
146 | \ |
---|
147 | && cd ../zoo-services/gdal/ \ |
---|
148 | && for i in contour dem grid profile translate warp ; do cd $i ; make && cp cgi-env/* /usr/lib/cgi-bin/ ; cd .. ; done \ |
---|
149 | \ |
---|
150 | && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \ |
---|
151 | && rm -rf /var/lib/apt/lists/* |
---|
152 | |
---|
153 | # |
---|
154 | # Optional zoo demos download. |
---|
155 | # |
---|
156 | FROM base AS demos |
---|
157 | ARG DEBIAN_FRONTEND=noninteractive |
---|
158 | ARG BUILD_DEPS=" \ |
---|
159 | git \ |
---|
160 | " |
---|
161 | WORKDIR /zoo-project |
---|
162 | |
---|
163 | RUN set -ex \ |
---|
164 | && apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \ |
---|
165 | \ |
---|
166 | && git clone https://github.com/ZOO-Project/examples.git |
---|
167 | |
---|
168 | # |
---|
169 | # Runtime image with apache2. |
---|
170 | # |
---|
171 | FROM base AS runtime |
---|
172 | ARG DEBIAN_FRONTEND=noninteractive |
---|
173 | ARG RUN_DEPS=" \ |
---|
174 | apache2 \ |
---|
175 | curl \ |
---|
176 | " |
---|
177 | |
---|
178 | # From zoo-kernel |
---|
179 | COPY --from=builder1 /usr/lib/cgi-bin/ /usr/lib/cgi-bin/ |
---|
180 | COPY --from=builder1 /usr/lib/libzoo_service.so.1.8 /usr/lib/libzoo_service.so.1.8 |
---|
181 | COPY --from=builder1 /usr/lib/libzoo_service.so /usr/lib/libzoo_service.so |
---|
182 | COPY --from=builder1 /usr/com/zoo-project/ /usr/com/zoo-project/ |
---|
183 | COPY --from=builder1 /usr/include/zoo/ /usr/include/zoo/ |
---|
184 | |
---|
185 | # From optional zoo modules |
---|
186 | COPY --from=builder2 /usr/lib/cgi-bin/ /usr/lib/cgi-bin/ |
---|
187 | COPY --from=builder2 /usr/com/zoo-project/ /usr/com/zoo-project/ |
---|
188 | |
---|
189 | # From optional zoo demos |
---|
190 | COPY --from=demos /zoo-project/examples/data/ /usr/com/zoo-project/ |
---|
191 | COPY --from=demos /zoo-project/examples/ /var/www/html/ |
---|
192 | |
---|
193 | |
---|
194 | RUN set -ex \ |
---|
195 | && apt-get update && apt-get install -y --no-install-recommends $RUN_DEPS \ |
---|
196 | \ |
---|
197 | && rm -rf /var/lib/apt/lists/* \ |
---|
198 | && pip3 install Cheetah3 redis\ |
---|
199 | && sed "s:AllowOverride None:AllowOverride All:g" -i /etc/apache2/apache2.conf \ |
---|
200 | && mkdir -p /tmp/statusInfos \ |
---|
201 | && chown www-data:www-data -R /tmp/statusInfos \ |
---|
202 | && a2enmod cgi rewrite |
---|
203 | |
---|
204 | EXPOSE 80 |
---|
205 | CMD /usr/sbin/apache2ctl -D FOREGROUND |
---|