Skip to content

Commit

Permalink
Add env var to change org name
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Feb 29, 2024
1 parent 43f742c commit 4cbde02
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 43 deletions.
6 changes: 3 additions & 3 deletions compose/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions envs/.env.web.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 2 additions & 26 deletions images/db/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
2 changes: 1 addition & 1 deletion images/web/config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 12 additions & 13 deletions images/web/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,30 @@ sed -i -e 's/smtp_password: null/smtp_password: "'$MAILER_PASSWORD'"/g' $workdir
sed -i -e 's/[email protected]/'$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')
Expand All @@ -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 \
Expand Down
2 changes: 2 additions & 0 deletions osm-seed/templates/web/web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions osm-seed/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4cbde02

Please sign in to comment.