Skip to content

Commit

Permalink
Merge pull request #292 from OpenHistoricalMap/settings/web
Browse files Browse the repository at this point in the history
Set up settings-local.yml
  • Loading branch information
Rub21 authored Apr 19, 2024
2 parents 5433db0 + 31b56d4 commit 8f8f718
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 170 deletions.
2 changes: 1 addition & 1 deletion images/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ RUN apache2ctl configtest
RUN chown -R www-data: $workdir

# Add settings
ADD config/settings.yml $workdir/config/
ADD config/settings-local.yml $workdir/config/

COPY start.sh $workdir/
COPY liveness.sh $workdir/
Expand Down
28 changes: 28 additions & 0 deletions images/web/config/settings-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# The server protocol and host
server_protocol: "http"
server_url: "openhistoricalmap.example.com"
status: "online"
# OAuth application for the web site
oauth_application: "OAUTH_CLIENT_ID"
oauth_key: "OAUTH_KEY"
# OAuth consumer key for iD
id_application: ""
# List of memcache servers to use for caching
memcache_servers: []
# URL of Nominatim instance to use for geocoding
nominatim_url: "https://nominatim.openhistoricalmap.org/"
# URL of Overpass instance to use for feature queries
overpass_url: "https://overpass-api.de/api/interpreter"
# SMTP settings for outbound mail
smtp_address: "localhost"
smtp_port: 25
smtp_domain: "localhost"
smtp_enable_starttls_auto: true
smtp_tls_verify_mode: "none"
smtp_authentication: null
smtp_user_name: null
smtp_password: null
doorkeeper_signing_key: |
-----BEGIN PRIVATE KEY-----
PRIVATE_KEY
-----END PRIVATE KEY-----
150 changes: 0 additions & 150 deletions images/web/config/settings.yml

This file was deleted.

39 changes: 21 additions & 18 deletions images/web/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,45 @@ production:
encoding: utf8" >$workdir/config/database.yml

#### SETTING UP SERVER_URL AND SERVER_PROTOCOL
sed -i -e 's/server_url: "openhistoricalmap.example.com"/server_url: "'$SERVER_URL'"/g' $workdir/config/settings.yml
sed -i -e 's/server_protocol: "http"/server_protocol: "'$SERVER_PROTOCOL'"/g' $workdir/config/settings.yml
sed -i -e 's/server_url: "openhistoricalmap.example.com"/server_url: "'$SERVER_URL'"/g' $workdir/config/settings-local.yml
sed -i -e 's/server_protocol: "http"/server_protocol: "'$SERVER_PROTOCOL'"/g' $workdir/config/settings-local.yml

### WEBSITE STATUS
sed -i "s/online/$WEBSITE_STATUS/g" $workdir/config/settings-local.yml

#### SETTING UP MAIL SENDER
sed -i -e 's/smtp_address: "localhost"/smtp_address: "'$MAILER_ADDRESS'"/g' $workdir/config/settings.yml
sed -i -e 's/smtp_domain: "localhost"/smtp_domain: "'$MAILER_DOMAIN'"/g' $workdir/config/settings.yml
sed -i -e 's/smtp_enable_starttls_auto: false/smtp_enable_starttls_auto: true/g' $workdir/config/settings.yml
sed -i -e 's/smtp_authentication: null/smtp_authentication: "login"/g' $workdir/config/settings.yml
sed -i -e 's/smtp_user_name: null/smtp_user_name: "'$MAILER_USERNAME'"/g' $workdir/config/settings.yml
sed -i -e 's/smtp_password: null/smtp_password: "'$MAILER_PASSWORD'"/g' $workdir/config/settings.yml
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
sed -i -e 's/smtp_address: "localhost"/smtp_address: "'$MAILER_ADDRESS'"/g' $workdir/config/settings-local.yml
sed -i -e 's/smtp_domain: "localhost"/smtp_domain: "'$MAILER_DOMAIN'"/g' $workdir/config/settings-local.yml
sed -i -e 's/smtp_enable_starttls_auto: false/smtp_enable_starttls_auto: true/g' $workdir/config/settings-local.yml
sed -i -e 's/smtp_authentication: null/smtp_authentication: "login"/g' $workdir/config/settings-local.yml
sed -i -e 's/smtp_user_name: null/smtp_user_name: "'$MAILER_USERNAME'"/g' $workdir/config/settings-local.yml
sed -i -e 's/smtp_password: null/smtp_password: "'$MAILER_PASSWORD'"/g' $workdir/config/settings-local.yml
sed -i -e 's/[email protected]/'$MAILER_FROM'/g' $workdir/config/settings-local.yml
sed -i -e 's/smtp_port: 25/smtp_port: '$MAILER_PORT'/g' $workdir/config/settings-local.yml

#### SET UP ID KEY
sed -i -e 's/id_application: ""/id_application: "'$OPENSTREETMAP_id_key'"/g' $workdir/config/settings.yml
sed -i -e 's/id_application: ""/id_application: "'$OPENSTREETMAP_id_key'"/g' $workdir/config/settings-local.yml

### SET UP OAUTH ID AND KEY
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_CLIENT_ID/'$OAUTH_CLIENT_ID'/g' $workdir/config/settings-local.yml
sed -i -e 's/OAUTH_KEY/'$OAUTH_KEY'/g' $workdir/config/settings-local.yml

#### Setup env vars for memcached server
sed -i -e 's/#memcache_servers: \[\]/memcache_servers: "'$OPENSTREETMAP_memcache_servers'"/g' $workdir/config/settings.yml
sed -i -e 's/memcache_servers: \[\]/memcache_servers: "'$OPENSTREETMAP_memcache_servers'"/g' $workdir/config/settings-local.yml

## SET NOMINATIM URL
sed -i -e 's/nominatim.openhistoricalmap.org/'$NOMINATIM_URL'/g' $workdir/config/settings.yml
sed -i -e 's/nominatim.openhistoricalmap.org/'$NOMINATIM_URL'/g' $workdir/config/settings-local.yml

## SET 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/config/settings-local.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

# ADD 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')
sed -i "s#PRIVATE_KEY#${DOORKEEPER_SIGNING_KEY}#" $workdir/config/settings.yml
sed -i "s#PRIVATE_KEY#${DOORKEEPER_SIGNING_KEY}#" $workdir/config/settings-local.yml

#### CHECK IF DB IS ALREADY UP AND START THE APP
flag=true
Expand All @@ -62,7 +65,7 @@ while "$flag" = true; do
sleep 2
done &

# Enable assets:precompile, to take lates changes for assets in $workdir/config/settings.yml.
# Enable assets:precompile, to take lates changes for assets in $workdir/config/settings-local.yml.
time bundle exec rake i18n:js:export assets:precompile

bundle exec rails db:migrate
Expand Down
2 changes: 1 addition & 1 deletion ohm/requirements.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dependencies:
- name: osm-seed
version: '0.1.0-n807.hc1acb2f'
version: '0.1.0-n781.h5f07b5b'
repository: https://devseed.com/osm-seed-chart/
1 change: 1 addition & 0 deletions values.production.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ osm-seed:
NEW_RELIC_LICENSE_KEY: {{PRODUCTION_NEW_RELIC_LICENSE_KEY}}
NEW_RELIC_APP_NAME: {{PRODUCTION_NEW_RELIC_APP_NAME}}
ORGANIZATION_NAME: OpenHistoricalMap
WEBSITE_STATUS: "online"
resources:
enabled: true
requests:
Expand Down
1 change: 1 addition & 0 deletions values.staging.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ osm-seed:
NEW_RELIC_LICENSE_KEY: {{STAGING_NEW_RELIC_LICENSE_KEY}}
NEW_RELIC_APP_NAME: {{STAGING_NEW_RELIC_APP_NAME}}
ORGANIZATION_NAME: OpenHistoricalMap
WEBSITE_STATUS: "online"
resources:
enabled: false
requests:
Expand Down

0 comments on commit 8f8f718

Please sign in to comment.