From 9a90c8a188ac1e4371272103441127f9d39a9971 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Thu, 20 Jun 2024 13:17:43 -0500 Subject: [PATCH] Update cgimap dockerfile --- images/cgimap/Dockerfile | 65 ++++++++++++++++++++++++++-------------- images/cgimap/start.sh | 43 ++++++++++++++++---------- 2 files changed, 70 insertions(+), 38 deletions(-) diff --git a/images/cgimap/Dockerfile b/images/cgimap/Dockerfile index 916fdb35..85ae3231 100644 --- a/images/cgimap/Dockerfile +++ b/images/cgimap/Dockerfile @@ -1,38 +1,53 @@ -FROM ubuntu:20.04 AS builder +FROM ubuntu:24.04 AS builder ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -qq && \ - apt-get install -y gcc g++ make autoconf automake libtool \ - libfcgi-dev libxml2-dev libmemcached-dev \ - libboost-program-options-dev \ - libcrypto++-dev libyajl-dev \ - libpqxx-dev zlib1g-dev libargon2-dev libfmt-dev \ - postgresql-12 postgresql-server-dev-all \ - git ca-certificates \ - --no-install-recommends && \ + apt-get install -y gcc g++ make cmake \ + libfcgi-dev libxml2-dev libmemcached-dev libbrotli-dev \ + libboost-program-options-dev libcrypto++-dev libyajl-dev \ + libpqxx-dev zlib1g-dev libfmt-dev git \ + ca-certificates \ + postgresql-16 postgresql-server-dev-all \ + --no-install-recommends && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* + + RUN apt-get update -qq && \ + apt-get install -y wget + + # Install Argon2 from source +RUN wget https://github.com/P-H-C/phc-winner-argon2/archive/refs/tags/20190702.tar.gz && \ +tar -xzf 20190702.tar.gz && \ +cd phc-winner-argon2-20190702 && \ +make && \ +make install + WORKDIR /app -RUN git clone https://github.com/zerebubuth/openstreetmap-cgimap.git ./ -RUN git checkout v0.8.8 +# Copy the main application. + +ENV CGIMAP_GITSHA=26cd7fa10affe5dbd13dbe16de34421059f53f18 +RUN git clone https://github.com/zerebubuth/openstreetmap-cgimap.git /app +RUN git checkout $CGIMAP_GITSHA + # Compile, install and remove source -RUN ./autogen.sh && \ - ./configure --enable-static --disable-shared --enable-yajl && \ - make -j3 && \ - make check && \ - strip openstreetmap-cgimap +RUN mkdir build && cd build && \ + CXXFLAGS="-Wall -Wextra -Wpedantic -Wno-unused-parameter" cmake .. -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release && \ + make -j${nproc} && \ + ctest --output-on-failure && \ + strip openstreetmap-cgimap && \ + cp openstreetmap-cgimap ../ -FROM ubuntu:20.04 +FROM ubuntu:24.04 RUN apt-get update -qq && \ apt-get install -y \ - libfcgi-bin libmemcached11 libboost-locale1.71.0 libboost-program-options1.71.0 \ - libxml2 libcrypto++6 libyajl2 libpqxx-6.4 zlib1g libargon2-1 \ - --no-install-recommends lighttpd gettext-base && \ + libfcgi-bin libmemcached11 libboost-program-options1.83.0 \ + libxml2 libcrypto++8 libyajl2 libpqxx-7.8t64 zlib1g libbrotli1 libfmt9 \ + --no-install-recommends && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* @@ -42,6 +57,10 @@ RUN groupadd -g 61000 cgimap && \ useradd -g 61000 -l -M -s /bin/false -u 61000 cgimap USER cgimap -COPY start.sh / -COPY lighttpd.conf.template / -CMD /start.sh \ No newline at end of file + +COPY start.sh / + +EXPOSE 8000 + +# ENTRYPOINT +CMD [ "/start.sh" ] \ No newline at end of file diff --git a/images/cgimap/start.sh b/images/cgimap/start.sh index c10a7566..7db92bbe 100755 --- a/images/cgimap/start.sh +++ b/images/cgimap/start.sh @@ -1,17 +1,30 @@ #!/usr/bin/env bash -set -ex - -# Make sure that the follow env vars has been declare -# API_WEB_HOST -# API_WEB_PORT -envsubst < lighttpd.conf.template > lighttpd.conf -/usr/sbin/lighttpd -f lighttpd.conf - -/usr/local/bin/openstreetmap-cgimap \ - --port=8000 \ - --instances=30 \ - --dbname=$POSTGRES_DB \ - --host=$POSTGRES_HOST \ - --username=$POSTGRES_USER \ - --password=$POSTGRES_PASSWORD +export CGIMAP_HOST=$POSTGRES_HOST +export CGIMAP_DBNAME=$POSTGRES_DB +export CGIMAP_USERNAME=$POSTGRES_USER +export CGIMAP_PASSWORD=$POSTGRES_PASSWORD +export CGIMAP_OAUTH_HOST=$POSTGRES_HOST +export CGIMAP_UPDATE_HOST=$POSTGRES_HOST +export CGIMAP_LOGFILE="/var/www/log/cgimap.log" +export CGIMAP_MEMCACHE=$OPENSTREETMAP_memcache_servers +export CGIMAP_RATELIMIT="204800" +export CGIMAP_MAXDEBT="250" +export CGIMAP_MAP_AREA="0.25" +export CGIMAP_MAP_NODES="100000" +export CGIMAP_MAX_WAY_NODES="2000" +export CGIMAP_MAX_RELATION_MEMBERS="32000" +# export CGIMAP_RATELIMIT_UPLOAD="true" +# export CGIMAP_MODERATOR_RATELIMIT="1048576" +# export CGIMAP_MODERATOR_MAXDEBT="1280" +# export CGIMAP_PIDFILE="/var/www/cgimap.pid" +# Check for web site status +if [[ "$WEBSITE_STATUS" == "database_readonly" || "$WEBSITE_STATUS" == "api_readonly" ]]; then + export CGIMAP_DISABLE_API_WRITE="true" +fi +if [[ "$WEBSITE_STATUS" == "database_offline" || "$WEBSITE_STATUS" == "api_offline" ]]; then + echo "Website is $WEBSITE_STATUS. No action required for cgimap service." +else + /usr/local/bin/openstreetmap-cgimap --port=8000 --daemon --instances=10 && \ + tail --pid=$(cat /tmp/cgimap.pid) -f /dev/null +fi