From 4cbde0207d1fee551579620cd9fd8ad73898ea26 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Thu, 29 Feb 2024 13:46:06 +0000 Subject: [PATCH] Add env var to change org name --- compose/web.yml | 6 ++--- envs/.env.web.example | 3 +++ images/db/Dockerfile | 28 ++-------------------- images/web/config/settings.yml | 2 +- images/web/start.sh | 25 ++++++++++--------- osm-seed/templates/web/web-deployment.yaml | 2 ++ osm-seed/values.yaml | 1 + 7 files changed, 24 insertions(+), 43 deletions(-) diff --git a/compose/web.yml b/compose/web.yml index 66a54086..cc6bbf10 100644 --- a/compose/web.yml +++ b/compose/web.yml @@ -9,10 +9,10 @@ services: build: context: ../images/db dockerfile: Dockerfile - ports: - - '5432:5432' + # ports: + # - '5432:5432' volumes: - - ../data/db-data:/var/lib/postgresql/data + - ../data/db-data-pg14:/var/lib/postgresql/data env_file: - ../envs/.env.db restart: always diff --git a/envs/.env.web.example b/envs/.env.web.example index e5f6b57f..81e62ab7 100644 --- a/envs/.env.web.example +++ b/envs/.env.web.example @@ -41,3 +41,6 @@ OAUTH_KEY="efg..." # TODO: Needs to be implemented the New Relic functions in order to make running in the web container NEW_RELIC_LICENSE_KEY="..." NEW_RELIC_APP_NAME="..." + +### Set organization name, by default : OpenStreetMap +ORGANIZATION_NAME=OSMSeed diff --git a/images/db/Dockerfile b/images/db/Dockerfile index f89a9b75..9df94425 100644 --- a/images/db/Dockerfile +++ b/images/db/Dockerfile @@ -1,26 +1,2 @@ -FROM postgres:11 -# ADD openstreetmap-postgres-init.sh /docker-entrypoint-initdb.d/ -RUN rm /etc/apt/sources.list.d/pgdg.list -RUN sed -i s/deb.debian.org/archive.debian.org/g /etc/apt/sources.list -RUN sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list -RUN sed -i '/stretch-updates/d' /etc/apt/sources.list -RUN apt-get update && apt-get -y install apt-transport-https -RUN echo "deb [ signed-by=/usr/local/share/keyrings/postgres.gpg.asc ] https://apt-archive.postgresql.org/pub/repos/apt/ stretch-pgdg main 11" >/etc/apt/sources.list.d/pgdg.list -RUN apt-get update \ - && apt-get install -y \ - postgresql-server-dev-11 \ - make \ - build-essential \ - postgresql-11-postgis-2.5 \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -ADD functions/functions.sql /usr/local/share/osm-db-functions.sql -ADD docker_postgres.sh /docker-entrypoint-initdb.d/ -RUN mkdir -p db -RUN mkdir -p lib -ADD functions/ db/functions/ -ADD lib/quad_tile/ lib/quad_tile/ - -RUN make -C db/functions/ -RUN chown -R postgres lib/ -RUN chown -R postgres db/ +FROM postgres:14 +ADD openstreetmap-postgres-init.sh /docker-entrypoint-initdb.d/ diff --git a/images/web/config/settings.yml b/images/web/config/settings.yml index bf895a85..ce42d9e5 100644 --- a/images/web/config/settings.yml +++ b/images/web/config/settings.yml @@ -106,7 +106,7 @@ nominatim_url: "https://nominatim.openstreetmap.org/" default_editor: "id" # OAuth application for the web site oauth_application: "OAUTH_CLIENT_ID" -# oauth_key: "OAUTH_KEY" +oauth_key: "OAUTH_KEY" # OAuth application for iD id_application: "" # Imagery to return in capabilities as blacklisted diff --git a/images/web/start.sh b/images/web/start.sh index 12c28f4f..d8df746a 100755 --- a/images/web/start.sh +++ b/images/web/start.sh @@ -26,30 +26,30 @@ sed -i -e 's/smtp_password: null/smtp_password: "'$MAILER_PASSWORD'"/g' $workdir sed -i -e 's/openstreetmap@example.com/'$MAILER_FROM'/g' $workdir/config/settings.yml sed -i -e 's/smtp_port: 25/smtp_port: '$MAILER_PORT'/g' $workdir/config/settings.yml -### SET UP ID KEY +### SETTING UP UP OAUTH-2 ID KEY FOR iD sed -i -e 's/id_application: ""/id_application: "'$OPENSTREETMAP_id_key'"/g' $workdir/config/settings.yml -## SET UP OAUTH ID AND KEY +### SETTING UP OAUTH-2 ID KEY WEBSITE sed -i -e 's/OAUTH_CLIENT_ID/'$OAUTH_CLIENT_ID'/g' $workdir/config/settings.yml -# sed -i -e 's/OAUTH_KEY/'$OAUTH_KEY'/g' $workdir/config/settings.yml +sed -i -e 's/OAUTH_KEY/'$OAUTH_KEY'/g' $workdir/config/settings.yml -#### Setup env vars for memcached server +#### SETTING UP ENV VARS FOR MEMCACHED SERVER sed -i -e 's/#memcache_servers: \[\]/memcache_servers: "'$OPENSTREETMAP_memcache_servers'"/g' $workdir/config/settings.yml -## SET NOMINATIM URL +### SETTING UP NOMINATIM URL sed -i -e 's/nominatim.openstreetmap.org/'$NOMINATIM_URL'/g' $workdir/config/settings.yml -# SET OVERPASS URL +#### SETTING UP OVERPASS URL sed -i -e 's/overpass-api.de/'$OVERPASS_URL'/g' $workdir/config/settings.yml sed -i -e 's/overpass-api.de/'$OVERPASS_URL'/g' $workdir/app/views/site/export.html.erb sed -i -e 's/overpass-api.de/'$OVERPASS_URL'/g' $workdir/app/assets/javascripts/index/export.js -## Set Permissions -chmod 0775 /var/www/log -touch /var/www/log/production.log -chmod 0664 /var/www/log/production.log +### SETTING UP ORGANIZATION +sed -i -e 's/OpenStreetMap/'$ORGANIZATION_NAME'/g' $workdir/config/settings.yml +ORGANIZATION_NAME_LOWER=$(echo "$ORGANIZATION_NAME" | tr '[:upper:]' '[:lower:]') +sed -i -e 's/openstreetmap/'"$ORGANIZATION_NAME_LOWER"'/g' "$workdir/config/settings.yml" -# Add DOORKEEPER_SIGNING_KEY +# ADDING DOORKEEPER_SIGNING_KEY openssl genpkey -algorithm RSA -out private.pem chmod 400 /var/www/private.pem export DOORKEEPER_SIGNING_KEY=$(cat /var/www/private.pem | sed -e '1d;$d' | tr -d '\n') @@ -70,9 +70,8 @@ while "$flag" = true; do fi sleep 2 done & - + # time rails i18n:js:export assets:precompile bundle exec rails db:migrate - /usr/local/bin/openstreetmap-cgimap \ --port=8000 \ --daemon \ diff --git a/osm-seed/templates/web/web-deployment.yaml b/osm-seed/templates/web/web-deployment.yaml index f154c5cb..fc44928a 100644 --- a/osm-seed/templates/web/web-deployment.yaml +++ b/osm-seed/templates/web/web-deployment.yaml @@ -119,6 +119,8 @@ spec: value: {{ .Values.web.env.NEW_RELIC_LICENSE_KEY | default ""}} - name: NEW_RELIC_APP_NAME value: {{ .Values.web.env.NEW_RELIC_APP_NAME | default ""}} + - name: ORGANIZATION_NAME + value: {{ .Values.web.env.ORGANIZATION_NAME | default "OpenStreetMap"}} volumeMounts: - mountPath: /dev/shm name: shared-memory diff --git a/osm-seed/values.yaml b/osm-seed/values.yaml index 122c95e3..a645df16 100644 --- a/osm-seed/values.yaml +++ b/osm-seed/values.yaml @@ -132,6 +132,7 @@ web: OVERPASS_URL: "overpassApi" OAUTH_CLIENT_ID: "abcd" # Create client ID and key as OAuth2 Application OAUTH_KEY: "xyz" + ORGANIZATION_NAME: "OSMSeed" resources: enabled: false requests: