From 29f11642e15f314fc72c915dcd66cf6c00db1d9a Mon Sep 17 00:00:00 2001 From: Rub21 Date: Fri, 1 Sep 2023 14:20:02 -0500 Subject: [PATCH 1/8] Add cgmap container --- chartpress.yaml | 4 ++- compose/cgmap.yml | 19 +++++++++++ images/cgmap/Dockerfile | 47 +++++++++++++++++++++++++ images/cgmap/README.md | 22 ++++++++++++ images/cgmap/lighttpd.conf | 70 ++++++++++++++++++++++++++++++++++++++ images/cgmap/start.sh | 13 +++++++ osm-seed/values.yaml | 19 +++++++++++ 7 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 compose/cgmap.yml create mode 100644 images/cgmap/Dockerfile create mode 100644 images/cgmap/README.md create mode 100644 images/cgmap/lighttpd.conf create mode 100755 images/cgmap/start.sh diff --git a/chartpress.yaml b/chartpress.yaml index 98f0f471..fcbbac9f 100644 --- a/chartpress.yaml +++ b/chartpress.yaml @@ -41,4 +41,6 @@ charts: osm-simple-metrics: valuesPath: osmSimpleMetrics.image changeset-replication-job: - valuesPath: changesetReplicationJob.image \ No newline at end of file + valuesPath: changesetReplicationJob.image + cgmap: + valuesPath: cgmap.image \ No newline at end of file diff --git a/compose/cgmap.yml b/compose/cgmap.yml new file mode 100644 index 00000000..6ac51c90 --- /dev/null +++ b/compose/cgmap.yml @@ -0,0 +1,19 @@ +version: '3' +services: + # ##################################################### + # ## cgmap section + # ##################################################### + cgmap: + image: osmseed-cgmap:v1 + build: + context: ../images/cgmap + dockerfile: Dockerfile + ports: + # - '8000:8000' + - '80:80' + volumes: + - ../data/cgmap-data:/apps/data/ + # command: > + # /bin/bash -c " ./start.sh" + env_file: + - ../envs/.env.db diff --git a/images/cgmap/Dockerfile b/images/cgmap/Dockerfile new file mode 100644 index 00000000..bf78d66f --- /dev/null +++ b/images/cgmap/Dockerfile @@ -0,0 +1,47 @@ +FROM ubuntu:20.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 clean && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +RUN git clone https://github.com/zerebubuth/openstreetmap-cgimap.git ./ +RUN git checkout v0.8.8 + +# Compile, install and remove source +RUN ./autogen.sh && \ + ./configure --enable-static --disable-shared --enable-yajl && \ + make -j3 && \ + make check && \ + strip openstreetmap-cgimap + +FROM ubuntu:20.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 && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +COPY --from=builder /app/openstreetmap-cgimap /usr/local/bin + +RUN groupadd -g 61000 cgimap && \ + useradd -g 61000 -l -M -s /bin/false -u 61000 cgimap + +USER cgimap +COPY start.sh / +COPY lighttpd.conf / +CMD /start.sh \ No newline at end of file diff --git a/images/cgmap/README.md b/images/cgmap/README.md new file mode 100644 index 00000000..22968868 --- /dev/null +++ b/images/cgmap/README.md @@ -0,0 +1,22 @@ +# openstreetmap-cgimap + +This container is built using the configuration from Zerebubuth's OpenStreetMap CGImap GitHub repository, with minor modifications. + + +# Build and up + +```sh +docker compose -f compose/cgmap.yml build +docker compose -f compose/cgmap.yml up +``` + +Note: Ensure that you are running PostgreSQL on your local machine. For example: + + +```sh +kubectl port-forward staging-db-0 5432:5432 +``` + +Check results: + +http://localhost/api/0.6/map?bbox=-77.09529161453248,-12.071898885565846,-77.077374458313,-12.066474684936727 diff --git a/images/cgmap/lighttpd.conf b/images/cgmap/lighttpd.conf new file mode 100644 index 00000000..7e42430e --- /dev/null +++ b/images/cgmap/lighttpd.conf @@ -0,0 +1,70 @@ +# default document-root +server.document-root = "/openstreetmap/cgimap/" + +# TCP port +server.port = 80 + +server.reject-expect-100-with-417 = "disable" + +# selecting modules +server.modules = ( "mod_access", "mod_rewrite", "mod_fastcgi", "mod_proxy", "mod_alias" ) + +# handling unknown routes +server.error-handler-404 = "/dispatch.map" + +# include, relative to dirname of main config file +#include "mime.types.conf" + +# read configuration from output of a command +#include_shell "/usr/local/bin/confmimetype /etc/mime.types" +mimetype.assign = ( + ".html" => "text/html", + ".txt" => "text/plain", + ".jpg" => "image/jpeg", + ".png" => "image/png" +) + +#debug.log-request-handling = "enable" + +$HTTP["request-method"] == "GET" { + url.rewrite-once = ( + "^/api/0\.6/map(\.(json|xml))?(\?(.*))?$" => "/dispatch.map", + "^/api/0\.6/(node|way|relation)/[[:digit:]]+(\.(json|xml))?$" => "/dispatch.map", + "^/api/0\.6/(node|way|relation)/[[:digit:]]+/history.*$" => "/dispatch.map", + "^/api/0\.6/(node|way|relation)/[[:digit:]]+/[[:digit:]]+.*$" => "/dispatch.map", + "^/api/0\.6/(node|way|relation)/[[:digit:]]+/relations$" => "/dispatch.map", + "^/api/0\.6/node/[[:digit:]]+/ways$" => "/dispatch.map", + "^/api/0\.6/(way|relation)/[[:digit:]]+/full$" => "/dispatch.map", + "^/api/0\.6/changeset/[[:digit:]]+.*$" => "/dispatch.map", + "^/api/0\.6/(nodes|ways|relations)(\?(.*))?$" => "/dispatch.map", + "^/api/0\.6/changeset/[[:digit:]]+/download$" => "/dispatch.map", + ) +} + +$HTTP["request-method"] == "POST" { + url.rewrite-once = ( + "^/api/0\.6/changeset/[[:digit:]]+/upload.*$" => "/dispatch.map", + ) +} + +$HTTP["request-method"] == "PUT" { + url.rewrite-once = ( + "^/api/0\.6/changeset/[[:digit:]]+/close.*$" => "/dispatch.map", + "^/api/0\.6/changeset/[[:digit:]]+$" => "/dispatch.map", + "^/api/0\.6/changeset/create.*$" => "/dispatch.map", + ) +} + +$HTTP["url"] =~ "^/(?!(dispatch\.map))" { + proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "3000" ) ) ) +} + +fastcgi.debug = 1 + +fastcgi.server = ( ".map" => + (( "host" => "127.0.0.1", + "port" => 8000, + "check-local" => "disable", + )) +) + diff --git a/images/cgmap/start.sh b/images/cgmap/start.sh new file mode 100755 index 00000000..cabca133 --- /dev/null +++ b/images/cgmap/start.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -ex + +/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 + diff --git a/osm-seed/values.yaml b/osm-seed/values.yaml index b9f45f6c..89e428ac 100644 --- a/osm-seed/values.yaml +++ b/osm-seed/values.yaml @@ -716,3 +716,22 @@ changesetReplicationJob: cpu: '10' nodeSelector: enabled: false + +# ==================================================================================================== +# Variables for cgmap config +# ==================================================================================================== +cgmap: + enabled: false + image: + name: '' + tag: '' + resources: + enabled: false + requests: + memory: '20Gi' + cpu: '8' + limits: + memory: '24Gi' + cpu: '10' + nodeSelector: + enabled: false From e0f2388616d1abb2bf985b38ad0f09fd87c22c9d Mon Sep 17 00:00:00 2001 From: Rub21 Date: Fri, 1 Sep 2023 14:26:10 -0500 Subject: [PATCH 2/8] Correct the misspelled name --- compose/{cgmap.yml => cgimap.yml} | 8 ++++---- images/{cgmap => cgimap}/Dockerfile | 0 images/{cgmap => cgimap}/README.md | 4 ++-- images/{cgmap => cgimap}/lighttpd.conf | 0 images/{cgmap => cgimap}/start.sh | 0 osm-seed/values.yaml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) rename compose/{cgmap.yml => cgimap.yml} (76%) rename images/{cgmap => cgimap}/Dockerfile (100%) rename images/{cgmap => cgimap}/README.md (84%) rename images/{cgmap => cgimap}/lighttpd.conf (100%) rename images/{cgmap => cgimap}/start.sh (100%) diff --git a/compose/cgmap.yml b/compose/cgimap.yml similarity index 76% rename from compose/cgmap.yml rename to compose/cgimap.yml index 6ac51c90..099cbd26 100644 --- a/compose/cgmap.yml +++ b/compose/cgimap.yml @@ -3,16 +3,16 @@ services: # ##################################################### # ## cgmap section # ##################################################### - cgmap: - image: osmseed-cgmap:v1 + cgimap: + image: osmseed-cgimap:v1 build: - context: ../images/cgmap + context: ../images/cgimap dockerfile: Dockerfile ports: # - '8000:8000' - '80:80' volumes: - - ../data/cgmap-data:/apps/data/ + - ../data/cgimap-data:/apps/data/ # command: > # /bin/bash -c " ./start.sh" env_file: diff --git a/images/cgmap/Dockerfile b/images/cgimap/Dockerfile similarity index 100% rename from images/cgmap/Dockerfile rename to images/cgimap/Dockerfile diff --git a/images/cgmap/README.md b/images/cgimap/README.md similarity index 84% rename from images/cgmap/README.md rename to images/cgimap/README.md index 22968868..92972a25 100644 --- a/images/cgmap/README.md +++ b/images/cgimap/README.md @@ -6,8 +6,8 @@ This container is built using the configuration from Zerebubuth's OpenStreetMap # Build and up ```sh -docker compose -f compose/cgmap.yml build -docker compose -f compose/cgmap.yml up +docker compose -f compose/cgimap.yml build +docker compose -f compose/cgimap.yml up ``` Note: Ensure that you are running PostgreSQL on your local machine. For example: diff --git a/images/cgmap/lighttpd.conf b/images/cgimap/lighttpd.conf similarity index 100% rename from images/cgmap/lighttpd.conf rename to images/cgimap/lighttpd.conf diff --git a/images/cgmap/start.sh b/images/cgimap/start.sh similarity index 100% rename from images/cgmap/start.sh rename to images/cgimap/start.sh diff --git a/osm-seed/values.yaml b/osm-seed/values.yaml index 89e428ac..41196f1c 100644 --- a/osm-seed/values.yaml +++ b/osm-seed/values.yaml @@ -720,7 +720,7 @@ changesetReplicationJob: # ==================================================================================================== # Variables for cgmap config # ==================================================================================================== -cgmap: +cgimap: enabled: false image: name: '' From a798afdbc193eb0efe334db31ed43a8c403cabe1 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Fri, 1 Sep 2023 14:54:32 -0500 Subject: [PATCH 3/8] Add helm template for cgimap --- chartpress.yaml | 4 +- compose/cgimap.yml | 1 - images/cgimap/Dockerfile | 4 +- .../{lighttpd.conf => lighttpd.conf.template} | 2 +- images/cgimap/start.sh | 4 ++ .../templates/cgimap/cgimap-deployment.yaml | 64 +++++++++++++++++++ osm-seed/templates/cgimap/cgimap-ingress.yaml | 26 ++++++++ osm-seed/templates/cgimap/cgimap-service.yaml | 43 +++++++++++++ 8 files changed, 142 insertions(+), 6 deletions(-) rename images/cgimap/{lighttpd.conf => lighttpd.conf.template} (95%) create mode 100644 osm-seed/templates/cgimap/cgimap-deployment.yaml create mode 100644 osm-seed/templates/cgimap/cgimap-ingress.yaml create mode 100644 osm-seed/templates/cgimap/cgimap-service.yaml diff --git a/chartpress.yaml b/chartpress.yaml index fcbbac9f..79aeab27 100644 --- a/chartpress.yaml +++ b/chartpress.yaml @@ -42,5 +42,5 @@ charts: valuesPath: osmSimpleMetrics.image changeset-replication-job: valuesPath: changesetReplicationJob.image - cgmap: - valuesPath: cgmap.image \ No newline at end of file + cgimap: + valuesPath: cgimap.image \ No newline at end of file diff --git a/compose/cgimap.yml b/compose/cgimap.yml index 099cbd26..97c0cf42 100644 --- a/compose/cgimap.yml +++ b/compose/cgimap.yml @@ -9,7 +9,6 @@ services: context: ../images/cgimap dockerfile: Dockerfile ports: - # - '8000:8000' - '80:80' volumes: - ../data/cgimap-data:/apps/data/ diff --git a/images/cgimap/Dockerfile b/images/cgimap/Dockerfile index bf78d66f..916fdb35 100644 --- a/images/cgimap/Dockerfile +++ b/images/cgimap/Dockerfile @@ -32,7 +32,7 @@ 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 && \ + --no-install-recommends lighttpd gettext-base && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* @@ -43,5 +43,5 @@ RUN groupadd -g 61000 cgimap && \ USER cgimap COPY start.sh / -COPY lighttpd.conf / +COPY lighttpd.conf.template / CMD /start.sh \ No newline at end of file diff --git a/images/cgimap/lighttpd.conf b/images/cgimap/lighttpd.conf.template similarity index 95% rename from images/cgimap/lighttpd.conf rename to images/cgimap/lighttpd.conf.template index 7e42430e..b2724f73 100644 --- a/images/cgimap/lighttpd.conf +++ b/images/cgimap/lighttpd.conf.template @@ -56,7 +56,7 @@ $HTTP["request-method"] == "PUT" { } $HTTP["url"] =~ "^/(?!(dispatch\.map))" { - proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "3000" ) ) ) + proxy.server = ( "" => ( ( "host" => "${API_WEB_HOST}", "port" => "${API_WEB_PORT}" ) ) ) } fastcgi.debug = 1 diff --git a/images/cgimap/start.sh b/images/cgimap/start.sh index cabca133..c10a7566 100755 --- a/images/cgimap/start.sh +++ b/images/cgimap/start.sh @@ -1,6 +1,10 @@ #!/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 \ diff --git a/osm-seed/templates/cgimap/cgimap-deployment.yaml b/osm-seed/templates/cgimap/cgimap-deployment.yaml new file mode 100644 index 00000000..91dd7b31 --- /dev/null +++ b/osm-seed/templates/cgimap/cgimap-deployment.yaml @@ -0,0 +1,64 @@ +{{- if .Values.cgimap.enabled -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "osm-seed.fullname" . }}-cgimap + labels: + app: {{ template "osm-seed.name" . }} + component: cgimap-deployment + environment: {{ .Values.environment }} + release: {{ .Release.Name }} +spec: + replicas: {{ .Values.cgimap.replicaCount }} + selector: + matchLabels: + app: {{ template "osm-seed.name" . }} + release: {{ .Release.Name }} + run: {{ .Release.Name }}-cgimap + template: + metadata: + labels: + app: {{ template "osm-seed.name" . }} + release: {{ .Release.Name }} + run: {{ .Release.Name }}-cgimap + spec: + containers: + - name: {{ .Chart.Name }}-cgimap + image: "{{ .Values.cgimap.image.name }}:{{ .Values.cgimap.image.tag }}" + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 600 # 10 min, because the compile process takes time. + timeoutSeconds: 30 + {{- if .Values.cgimap.resources.enabled }} + resources: + requests: + memory: {{ .Values.cgimap.resources.requests.memory }} + cpu: {{ .Values.cgimap.resources.requests.cpu }} + limits: + memory: {{ .Values.cgimap.resources.limits.memory }} + cpu: {{ .Values.cgimap.resources.limits.cpu }} + {{- end }} + env: + - name: POSTGRES_HOST + value: {{ .Release.Name }}-db + - name: POSTGRES_DB + value: {{ .Values.db.env.POSTGRES_DB }} + - name: POSTGRES_PASSWORD + value: {{ quote .Values.db.env.POSTGRES_PASSWORD }} + - name: POSTGRES_USER + value: {{ .Values.db.env.POSTGRES_USER }} + - name: API_WEB_HOST + value: {{ .Release.Name }}-web + - name: API_WEB_PORT + value: 80 + {{- if .Values.cgimap.nodeSelector.enabled }} + nodeSelector: + {{ .Values.cgimap.nodeSelector.label_key }} : {{ .Values.cgimap.nodeSelector.label_value }} + {{- end }} +{{- end }} diff --git a/osm-seed/templates/cgimap/cgimap-ingress.yaml b/osm-seed/templates/cgimap/cgimap-ingress.yaml new file mode 100644 index 00000000..7c158b60 --- /dev/null +++ b/osm-seed/templates/cgimap/cgimap-ingress.yaml @@ -0,0 +1,26 @@ +{{- if and .Values.cgimap.enabled (eq .Values.serviceType "ClusterIP") }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ template "osm-seed.fullname" . }}-ingress-cgimap-api + annotations: + kubernetes.io/ingress.class: nginx + cert-manager.io/cluster-issuer: letsencrypt-prod-issuer +spec: + tls: + - hosts: + - cgimap.{{ .Values.domain }} + secretName: {{ template "osm-seed.fullname" . }}-secret-cgimap + + rules: + - host: cgimap.{{ .Values.domain }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ template "osm-seed.fullname" . }}-cgimap + port: + number: 80 +{{- end }} \ No newline at end of file diff --git a/osm-seed/templates/cgimap/cgimap-service.yaml b/osm-seed/templates/cgimap/cgimap-service.yaml new file mode 100644 index 00000000..a7449407 --- /dev/null +++ b/osm-seed/templates/cgimap/cgimap-service.yaml @@ -0,0 +1,43 @@ +{{- if .Values.cgimap.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ template "osm-seed.fullname" . }}-cgimap + labels: + app: {{ template "osm-seed.name" . }} + component: cgimap-service + environment: {{ .Values.environment }} + release: {{ .Release.Name }} + annotations: + {{- if and (eq .Values.serviceType "LoadBalancer") .Values.AWS_SSL_ARN }} + service.beta.kubernetes.io/aws-load-balancer-ssl-cert: {{ .Values.AWS_SSL_ARN }} + service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http + service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https + {{- end }} + {{- if eq .Values.serviceType "ClusterIP" }} + kubernetes.io/ingress.class: nginx + cert-manager.io/cluster-issuer: letsencrypt-prod-issuer + {{- else }} + fake.annotation: fake + {{- end }} + {{- with .Values.cgimap.serviceAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: {{ .Values.serviceType }} + ports: + - port: 80 + targetPort: http + protocol: TCP + name: http + {{- if and (eq .Values.serviceType "LoadBalancer") .Values.AWS_SSL_ARN }} + - port: 443 + targetPort: http + protocol: TCP + name: https + {{- end }} + selector: + app: {{ template "osm-seed.name" . }} + release: {{ .Release.Name }} + run: {{ .Release.Name }}-cgimap +{{- end }} \ No newline at end of file From 9a90c8a188ac1e4371272103441127f9d39a9971 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Thu, 20 Jun 2024 13:17:43 -0500 Subject: [PATCH 4/8] 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 From 951463da13defb14bd393264fb0a12e43276b2a0 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Thu, 20 Jun 2024 13:28:01 -0500 Subject: [PATCH 5/8] Update tiler-imposm dockerfile --- images/tiler-imposm/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/images/tiler-imposm/Dockerfile b/images/tiler-imposm/Dockerfile index e99ccc28..a996721d 100644 --- a/images/tiler-imposm/Dockerfile +++ b/images/tiler-imposm/Dockerfile @@ -23,7 +23,9 @@ RUN apt-get install -y \ rm -rf /var/lib/apt/lists/* # # Install python -RUN add-apt-repository ppa:deadsnakes/ppa && \ +RUN apt-get update && \ + apt-get install -y software-properties-common && \ + add-apt-repository ppa:deadsnakes/ppa && \ apt-get update && \ apt-get install -y build-essential python3.6 python3.6-dev python3-pip && \ rm -rf /var/lib/apt/lists/* && \ From 36a3ae6c73f3be9c10de50c53094911f40018281 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Thu, 20 Jun 2024 14:50:41 -0500 Subject: [PATCH 6/8] Update python --- images/tiler-imposm/Dockerfile | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/images/tiler-imposm/Dockerfile b/images/tiler-imposm/Dockerfile index a996721d..19a44cfd 100644 --- a/images/tiler-imposm/Dockerfile +++ b/images/tiler-imposm/Dockerfile @@ -22,15 +22,26 @@ RUN apt-get install -y \ software-properties-common && \ rm -rf /var/lib/apt/lists/* -# # Install python +# Install Python 3.6 RUN apt-get update && \ apt-get install -y software-properties-common && \ - add-apt-repository ppa:deadsnakes/ppa && \ + add-apt-repository -y ppa:ubuntu-toolchain-r/test && \ apt-get update && \ - apt-get install -y build-essential python3.6 python3.6-dev python3-pip && \ - rm -rf /var/lib/apt/lists/* && \ - python3 -m pip install pip --upgrade && \ - python3 -m pip install wheel + apt-get install -y gcc-8 g++-8 && \ + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 100 && \ + update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 100 && \ + apt-get install -y build-essential wget libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev && \ + wget https://www.python.org/ftp/python/3.6.15/Python-3.6.15.tgz && \ + tar xzf Python-3.6.15.tgz && \ + cd Python-3.6.15 && \ + ./configure --enable-optimizations && \ + make altinstall && \ + cd .. && \ + rm -rf Python-3.6.15 Python-3.6.15.tgz && \ + apt-get install -y python3-pip && \ + python3.6 -m pip install pip --upgrade && \ + python3.6 -m pip install wheel && \ + rm -rf /var/lib/apt/lists/* # Install postgresql-client RUN apt-get update && apt-get install -y postgresql-client && \ From 057b8a206663e4c9de5b60799b8dd96ce9265327 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Thu, 20 Jun 2024 15:34:41 -0500 Subject: [PATCH 7/8] Update cgimap container --- images/cgimap/Dockerfile | 43 ++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/images/cgimap/Dockerfile b/images/cgimap/Dockerfile index 85ae3231..a1e72c5d 100644 --- a/images/cgimap/Dockerfile +++ b/images/cgimap/Dockerfile @@ -9,37 +9,34 @@ RUN apt-get update -qq && \ libpqxx-dev zlib1g-dev libfmt-dev git \ ca-certificates \ postgresql-16 postgresql-server-dev-all \ + wget \ --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 +# 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 + tar -xzf 20190702.tar.gz && \ + cd phc-winner-argon2-20190702 && \ + make && \ + make install && \ + ldconfig WORKDIR /app # Copy the main application. - ENV CGIMAP_GITSHA=26cd7fa10affe5dbd13dbe16de34421059f53f18 -RUN git clone https://github.com/zerebubuth/openstreetmap-cgimap.git /app -RUN git checkout $CGIMAP_GITSHA - +RUN git clone https://github.com/zerebubuth/openstreetmap-cgimap.git /app && \ + cd /app && \ + git checkout $CGIMAP_GITSHA # Compile, install and remove source 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} && \ + make -j$(nproc) && \ ctest --output-on-failure && \ strip openstreetmap-cgimap && \ - cp openstreetmap-cgimap ../ + cp openstreetmap-cgimap /usr/local/bin FROM ubuntu:24.04 @@ -47,20 +44,28 @@ RUN apt-get update -qq && \ apt-get install -y \ libfcgi-bin libmemcached11 libboost-program-options1.83.0 \ libxml2 libcrypto++8 libyajl2 libpqxx-7.8t64 zlib1g libbrotli1 libfmt9 \ + wget \ --no-install-recommends && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -COPY --from=builder /app/openstreetmap-cgimap /usr/local/bin +# Install Argon2 runtime library +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 && \ + ldconfig + +COPY --from=builder /usr/local/bin/openstreetmap-cgimap /usr/local/bin RUN groupadd -g 61000 cgimap && \ useradd -g 61000 -l -M -s /bin/false -u 61000 cgimap USER cgimap -COPY start.sh / +COPY start.sh / EXPOSE 8000 -# ENTRYPOINT -CMD [ "/start.sh" ] \ No newline at end of file +CMD ["/start.sh"] \ No newline at end of file From 26c3a8059c87bcccdef9fc2f32c46fa90035ab57 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Thu, 20 Jun 2024 15:38:46 -0500 Subject: [PATCH 8/8] Update cgimap container --- images/cgimap/Dockerfile | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/images/cgimap/Dockerfile b/images/cgimap/Dockerfile index a1e72c5d..0a26d642 100644 --- a/images/cgimap/Dockerfile +++ b/images/cgimap/Dockerfile @@ -37,32 +37,8 @@ RUN mkdir build && cd build && \ ctest --output-on-failure && \ strip openstreetmap-cgimap && \ cp openstreetmap-cgimap /usr/local/bin - -FROM ubuntu:24.04 - -RUN apt-get update -qq && \ - apt-get install -y \ - libfcgi-bin libmemcached11 libboost-program-options1.83.0 \ - libxml2 libcrypto++8 libyajl2 libpqxx-7.8t64 zlib1g libbrotli1 libfmt9 \ - wget \ - --no-install-recommends && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# Install Argon2 runtime library -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 && \ - ldconfig - -COPY --from=builder /usr/local/bin/openstreetmap-cgimap /usr/local/bin - -RUN groupadd -g 61000 cgimap && \ - useradd -g 61000 -l -M -s /bin/false -u 61000 cgimap - -USER cgimap + +RUN rm -rf /app/.git COPY start.sh /