Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copying Timeslider during the build process #428

Merged
merged 6 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions images/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ruby:3.3.0
ENV DEBIAN_FRONTEND=noninteractive
ENV workdir /var/www
ENV workdir=/var/www

# Production OSM setup
ENV RAILS_ENV=production
Expand Down Expand Up @@ -32,7 +32,7 @@ RUN apt-get update && apt-get -y install libxml2-dev libpqxx-dev libfcgi-dev zl
rm -rf /var/lib/apt/lists/*

# Install cgimap
ENV cgimap /tmp/openstreetmap-cgimap
ENV cgimap=/tmp/openstreetmap-cgimap
ENV CGIMAP_GITSHA=26cd7fa10affe5dbd13dbe16de34421059f53f18
RUN git clone -b master https://github.com/zerebubuth/openstreetmap-cgimap.git $cgimap \
&& cd $cgimap \
Expand Down Expand Up @@ -120,6 +120,18 @@ RUN cd $workdir/public/map-styles && git fetch --depth 1 origin $OPENHISTORICALM
RUN rm -rf $workdir/public/map-styles/.git
COPY update_map_styles.py $workdir/

# Clone leaflet-ohm-timeslider-v2
ENV LEAFLET_OHM_TIMESLIDER_V2=dd0acbdc9432fae6a4d09a17a4848c391e5064f0
RUN git clone https://github.com/OpenHistoricalMap/leaflet-ohm-timeslider-v2.git $workdir/public/leaflet-ohm-timeslider-v2 \
&& cd $workdir/public/leaflet-ohm-timeslider-v2 \
&& git checkout dd0acbdc9432fae6a4d09a17a4848c391e5064f0 \
&& rm -rf .git \
&& chmod 777 -R assets/ \
&& cp decimaldate.* $workdir/app/assets/javascripts/ \
&& cp leaflet-ohm-timeslider.* $workdir/app/assets/javascripts/ \
&& cp leaflet-ohm-timeslider.* $workdir/app/assets/stylesheets/ \
&& cp assets/* $workdir/app/assets/images/

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

Expand Down
26 changes: 15 additions & 11 deletions images/web/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ workdir="/var/www"
export RAILS_ENV=production
#### Because we can not set up many env variable in build process, we are going to process here!

#### SETTING UP THE PRODUCTION DATABASE
#### Setting up the production database
echo " # Production DB
production:
adapter: postgresql
Expand All @@ -13,14 +13,14 @@ production:
password: ${POSTGRES_PASSWORD}
encoding: utf8" >$workdir/config/database.yml

#### SETTING UP SERVER_URL AND SERVER_PROTOCOL
#### Setting up server_url and server_protocol
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
### Setting up website status
sed -i "s/online/$WEBSITE_STATUS/g" $workdir/config/settings.yml

#### SETTING UP MAIL SENDER
#### Setting up mail sender
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
Expand All @@ -30,11 +30,11 @@ 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.local.yml
sed -i -e 's/smtp_port: 25/smtp_port: '$MAILER_PORT'/g' $workdir/config/settings.local.yml

#### SET UP ID KEY
#### Setting up id key fro the website
sed -i -e 's/id_application: ""/id_application: "'$OPENSTREETMAP_id_key'"/g' $workdir/config/settings.local.yml
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 id and key for iD editor
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
sed -i -e 's/# oauth_application: "OAUTH_CLIENT_ID"/oauth_application: "'$OAUTH_CLIENT_ID'"/g' $workdir/config/settings.yml
Expand All @@ -43,24 +43,25 @@ sed -i -e 's/# oauth_key: "OAUTH_CLIENT_ID"/oauth_key: "'$OAUTH_KEY'"/g' $workdi
#### Setup env vars for memcached server
sed -i -e 's/memcache_servers: \[\]/memcache_servers: "'$OPENSTREETMAP_memcache_servers'"/g' $workdir/config/settings.local.yml

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

## SET OVERPASS URL
#### Setting up overpass url
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
#### 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')
sed -i "s#PRIVATE_KEY#${DOORKEEPER_SIGNING_KEY}#" $workdir/config/settings.local.yml

# UPDATE MAP-STYLES
#### Updating map-styles
python3 update_map_styles.py

#### CHECK IF DB IS ALREADY UP AND START THE APP

#### Checking if db is already up and start the app
flag=true
while "$flag" = true; do
pg_isready -h $POSTGRES_HOST -p 5432 >/dev/null 2>&2 || continue
Expand All @@ -74,6 +75,9 @@ while "$flag" = true; do
# Enable assets:precompile, to take lates changes for assets in $workdir/config/settings.local.yml.
time bundle exec rake i18n:js:export assets:precompile

# Since leaflet-ohm-timeslider.css points directly to the svg files, they need to be copied to the public/assets directory.
cp $workdir/public/leaflet-ohm-timeslider-v2/assets/* $workdir/public/assets/

bundle exec rails db:migrate

# Start cgimap
Expand Down
2 changes: 1 addition & 1 deletion values.production.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ ohm:
NODEGROUP_TYPE: web_large # Nodegroup type to run the job
# Maximum number of active jobs in high concurrency queue
MAX_ACTIVE_JOBS: 10
DELETE_OLD_JOBS_AGE: 60 # 1 hours
DELETE_OLD_JOBS_AGE: 7200 # 2 hours
## Execute purging
EXECUTE_PURGE: true
PURGE_CONCURRENCY: 64
Expand Down
Loading