[959] | 1 | # |
---|
| 2 | # Base: Ubuntu 18.04 with updates and external packages |
---|
| 3 | # |
---|
[968] | 4 | FROM ubuntu:bionic-20201119 AS base |
---|
[959] | 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 \ |
---|
[968] | 17 | libpython3.6 \ |
---|
[959] | 18 | libxslt1.1 \ |
---|
| 19 | gdal-bin \ |
---|
[968] | 20 | python3 \ |
---|
[959] | 21 | r-base \ |
---|
[968] | 22 | python3-pip\ |
---|
[959] | 23 | " |
---|
| 24 | RUN set -ex \ |
---|
| 25 | && apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \ |
---|
| 26 | \ |
---|
| 27 | && add-apt-repository ppa:osgeolive/nightly \ |
---|
| 28 | && add-apt-repository ppa:ubuntugis/ppa \ |
---|
| 29 | && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 \ |
---|
| 30 | && add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/' \ |
---|
| 31 | \ |
---|
| 32 | && apt-get install -y $RUN_DEPS \ |
---|
| 33 | \ |
---|
| 34 | && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \ |
---|
| 35 | && rm -rf /var/lib/apt/lists/* |
---|
| 36 | |
---|
| 37 | # |
---|
| 38 | # builder1: base image with zoo-kernel |
---|
| 39 | # |
---|
| 40 | FROM base AS builder1 |
---|
| 41 | ARG DEBIAN_FRONTEND=noninteractive |
---|
| 42 | ARG BUILD_DEPS=" \ |
---|
| 43 | bison \ |
---|
| 44 | flex \ |
---|
| 45 | make \ |
---|
| 46 | autoconf \ |
---|
| 47 | gcc \ |
---|
| 48 | gettext-base \ |
---|
| 49 | \ |
---|
| 50 | libfcgi-dev \ |
---|
| 51 | libgdal-dev \ |
---|
| 52 | libjson-c-dev \ |
---|
| 53 | libssh2-1-dev \ |
---|
| 54 | libssl-dev \ |
---|
| 55 | libxml2-dev \ |
---|
| 56 | libxslt1-dev \ |
---|
[968] | 57 | python3-dev \ |
---|
[959] | 58 | uuid-dev \ |
---|
| 59 | r-base-dev \ |
---|
| 60 | " |
---|
| 61 | WORKDIR /zoo-project |
---|
| 62 | COPY . . |
---|
| 63 | |
---|
| 64 | RUN set -ex \ |
---|
| 65 | && apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \ |
---|
| 66 | \ |
---|
| 67 | && make -C ./thirds/cgic206 libcgic.a \ |
---|
| 68 | \ |
---|
| 69 | && cd ./zoo-project/zoo-kernel \ |
---|
| 70 | && autoconf \ |
---|
[968] | 71 | && ./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 \ |
---|
[959] | 72 | && make \ |
---|
| 73 | && make install \ |
---|
| 74 | \ |
---|
| 75 | # TODO: why not copied by 'make'? |
---|
| 76 | && cp zoo_loader.cgi main.cfg /usr/lib/cgi-bin/ \ |
---|
| 77 | && cp ../zoo-services/hello-py/cgi-env/* /usr/lib/cgi-bin/ \ |
---|
| 78 | && cp ../zoo-services/hello-js/cgi-env/* /usr/lib/cgi-bin/ \ |
---|
| 79 | && cp ../zoo-api/js/* /usr/lib/cgi-bin/ \ |
---|
[968] | 80 | && cp ../zoo-services/utils/open-api/cgi-env/* /usr/lib/cgi-bin/ \ |
---|
[959] | 81 | && cp ../zoo-services/hello-py/cgi-env/* /usr/lib/cgi-bin/ \ |
---|
| 82 | && cp ../zoo-services/hello-js/cgi-env/* /usr/lib/cgi-bin/ \ |
---|
| 83 | && cp ../zoo-api/js/* /usr/lib/cgi-bin/ \ |
---|
| 84 | \ |
---|
| 85 | && cp oas.cfg /usr/lib/cgi-bin/ \ |
---|
| 86 | \ |
---|
| 87 | # TODO: main.cfg is not processed \ |
---|
| 88 | && prefix=/usr envsubst < main.cfg > /usr/lib/cgi-bin/main.cfg \ |
---|
| 89 | \ |
---|
| 90 | && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \ |
---|
| 91 | && rm -rf /var/lib/apt/lists/* |
---|
| 92 | |
---|
| 93 | # |
---|
| 94 | # Optional zoo modules build. |
---|
| 95 | # |
---|
| 96 | FROM base AS builder2 |
---|
| 97 | ARG DEBIAN_FRONTEND=noninteractive |
---|
| 98 | ARG BUILD_DEPS=" \ |
---|
| 99 | bison \ |
---|
| 100 | flex \ |
---|
| 101 | make \ |
---|
| 102 | autoconf \ |
---|
| 103 | g++ \ |
---|
| 104 | gcc \ |
---|
| 105 | libc-dev \ |
---|
| 106 | libfcgi-dev \ |
---|
| 107 | libgdal-dev \ |
---|
| 108 | libxml2-dev \ |
---|
| 109 | libxslt1-dev \ |
---|
| 110 | " |
---|
| 111 | WORKDIR /zoo-project |
---|
| 112 | COPY ./zoo-project/zoo-services/utils/status ./zoo-project/zoo-services/utils/status |
---|
| 113 | |
---|
| 114 | # From zoo-kernel |
---|
| 115 | COPY --from=builder1 /usr/lib/cgi-bin/ /usr/lib/cgi-bin/ |
---|
[968] | 116 | COPY --from=builder1 /usr/lib/libzoo_service.so.1.8 /usr/lib/libzoo_service.so.1.8 |
---|
[959] | 117 | COPY --from=builder1 /usr/lib/libzoo_service.so /usr/lib/libzoo_service.so |
---|
| 118 | COPY --from=builder1 /usr/com/zoo-project/ /usr/com/zoo-project/ |
---|
| 119 | COPY --from=builder1 /usr/include/zoo/ /usr/include/zoo/ |
---|
| 120 | |
---|
| 121 | # Additional files from bulder2 |
---|
| 122 | COPY --from=builder1 /zoo-project/zoo-project/zoo-kernel/ZOOMakefile.opts /zoo-project/zoo-project/zoo-kernel/ZOOMakefile.opts |
---|
| 123 | COPY --from=builder1 /zoo-project/zoo-project/zoo-kernel/sqlapi.h /zoo-project/zoo-project/zoo-kernel/sqlapi.h |
---|
| 124 | COPY --from=builder1 /zoo-project/zoo-project/zoo-kernel/service.h /zoo-project/zoo-project/zoo-kernel/service.h |
---|
| 125 | COPY --from=builder1 /zoo-project/zoo-project/zoo-kernel/service_internal.h /zoo-project/zoo-project/zoo-kernel/service_internal.h |
---|
| 126 | COPY --from=builder1 /zoo-project/zoo-project/zoo-kernel/version.h /zoo-project/zoo-project/zoo-kernel/version.h |
---|
| 127 | |
---|
| 128 | RUN set -ex \ |
---|
| 129 | && apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \ |
---|
| 130 | \ |
---|
| 131 | && cd ./zoo-project/zoo-services/utils/status \ |
---|
| 132 | && make \ |
---|
| 133 | && make install \ |
---|
| 134 | \ |
---|
| 135 | && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \ |
---|
| 136 | && rm -rf /var/lib/apt/lists/* |
---|
| 137 | |
---|
| 138 | # |
---|
| 139 | # Runtime image with apache2. |
---|
| 140 | # |
---|
| 141 | FROM base AS runtime |
---|
| 142 | ARG DEBIAN_FRONTEND=noninteractive |
---|
| 143 | ARG RUN_DEPS=" \ |
---|
| 144 | apache2 \ |
---|
| 145 | curl \ |
---|
| 146 | " |
---|
| 147 | |
---|
| 148 | # From zoo-kernel |
---|
| 149 | COPY --from=builder1 /usr/lib/cgi-bin/ /usr/lib/cgi-bin/ |
---|
[968] | 150 | COPY --from=builder1 /usr/lib/libzoo_service.so.1.8 /usr/lib/libzoo_service.so.1.8 |
---|
[959] | 151 | COPY --from=builder1 /usr/lib/libzoo_service.so /usr/lib/libzoo_service.so |
---|
| 152 | COPY --from=builder1 /usr/com/zoo-project/ /usr/com/zoo-project/ |
---|
| 153 | COPY --from=builder1 /usr/include/zoo/ /usr/include/zoo/ |
---|
| 154 | |
---|
| 155 | # From optional zoo modules |
---|
| 156 | COPY --from=builder2 /usr/lib/cgi-bin/ /usr/lib/cgi-bin/ |
---|
| 157 | COPY --from=builder2 /usr/com/zoo-project/ /usr/com/zoo-project/ |
---|
| 158 | |
---|
| 159 | RUN set -ex \ |
---|
| 160 | && apt-get update && apt-get install -y --no-install-recommends $RUN_DEPS \ |
---|
| 161 | \ |
---|
| 162 | && rm -rf /var/lib/apt/lists/* \ |
---|
[968] | 163 | && pip3 install Cheetah3 redis\ |
---|
| 164 | && sed "s:AllowOverride None:AllowOverride All:g" -i /etc/apache2/apache2.conf \ |
---|
[969] | 165 | && mkdir -p /tmp/statusInfos \ |
---|
| 166 | && chown www-data:www-data -R /tmp/statusInfos \ |
---|
[968] | 167 | && a2enmod cgi rewrite |
---|
[959] | 168 | |
---|
| 169 | EXPOSE 80 |
---|
| 170 | CMD /usr/sbin/apache2ctl -D FOREGROUND |
---|