From 0b88e9600439554d8db1efa9ec1bf4b36b1cac39 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Thu, 2 May 2024 15:26:26 -0500 Subject: [PATCH 1/8] Update version of passenger --- images/web/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/images/web/Dockerfile b/images/web/Dockerfile index 348b1a73..69abadd8 100644 --- a/images/web/Dockerfile +++ b/images/web/Dockerfile @@ -87,7 +87,8 @@ RUN a2ensite production # Install Passenger + Apache module RUN apt-key adv --refresh-keys --keyserver keyserver.ubuntu.com -RUN apt-get update && apt-get install -y libapache2-mod-passenger lighttpd +RUN apt-get update +RUN apt-get install -y libapache2-mod-passenger lighttpd # Enable the Passenger Apache module and restart Apache RUN echo "ServerName $(cat /etc/hostname)" >> /etc/apache2/apache2.conf From 4ec985b4da1da1c27329f056e449301b42e9368a Mon Sep 17 00:00:00 2001 From: Rub21 Date: Thu, 2 May 2024 16:46:10 -0500 Subject: [PATCH 2/8] Update Ruby and passenger version --- images/web/Dockerfile | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/images/web/Dockerfile b/images/web/Dockerfile index 69abadd8..9ae1a885 100644 --- a/images/web/Dockerfile +++ b/images/web/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:22.04 +FROM ruby:3.3.0 ENV DEBIAN_FRONTEND=noninteractive ENV workdir /var/www @@ -8,7 +8,7 @@ ENV RAILS_ENV=production # Install the openstreetmap-website dependencies RUN apt-get update \ && apt-get install -y \ - ruby ruby-dev ruby-bundler libmagickwand-dev libxml2-dev libxslt1-dev \ + libmagickwand-dev libxml2-dev libxslt1-dev \ apache2 apache2-dev build-essential git-core postgresql-client \ libpq-dev libsasl2-dev imagemagick libffi-dev libgd-dev libarchive-dev libbz2-dev curl \ default-jre-headless file gpg-agent libvips-dev locales software-properties-common tzdata unzip \ @@ -17,13 +17,27 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* ## Install node -RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - +RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list RUN apt-get update && apt-get install -y nodejs yarn && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* +# Install Passenger + Apache module +RUN apt-get update && apt-get install -y \ + cmake \ + libgcrypt20 \ + openssl \ + rubygems \ + s3cmd && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* +RUN gem install passenger +RUN passenger-install-apache2-module + +# RUN apt-get install -y libapache2-mod-passenger lighttpd + # Install openstreetmap-cgimap requirements RUN apt-get update && apt-get -y install libpqxx-dev libfcgi-dev zlib1g-dev \ libboost-dev libboost-program-options-dev libfmt-dev \ @@ -85,10 +99,10 @@ RUN a2enmod setenvif RUN a2dissite 000-default RUN a2ensite production -# Install Passenger + Apache module -RUN apt-key adv --refresh-keys --keyserver keyserver.ubuntu.com -RUN apt-get update -RUN apt-get install -y libapache2-mod-passenger lighttpd +# # Install Passenger + Apache module +# RUN apt-key adv --refresh-keys --keyserver keyserver.ubuntu.com +# RUN apt-get update +# RUN apt-get install -y libapache2-mod-passenger lighttpd # Enable the Passenger Apache module and restart Apache RUN echo "ServerName $(cat /etc/hostname)" >> /etc/apache2/apache2.conf From 4c6d0f6e5ee5e96f0128e9f08c3feacc55d0472d Mon Sep 17 00:00:00 2001 From: Rub21 Date: Fri, 3 May 2024 01:32:23 +0000 Subject: [PATCH 3/8] Update web api docker contianer --- images/web/Dockerfile | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/images/web/Dockerfile b/images/web/Dockerfile index 9ae1a885..2a0d2691 100644 --- a/images/web/Dockerfile +++ b/images/web/Dockerfile @@ -1,8 +1,6 @@ -FROM ruby:3.3.0 +FROM phusion/passenger-ruby33 ENV DEBIAN_FRONTEND=noninteractive ENV workdir /var/www - -# Production OSM setup ENV RAILS_ENV=production # Install the openstreetmap-website dependencies @@ -24,17 +22,17 @@ RUN apt-get update && apt-get install -y nodejs yarn && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -# Install Passenger + Apache module -RUN apt-get update && apt-get install -y \ - cmake \ - libgcrypt20 \ - openssl \ - rubygems \ - s3cmd && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* -RUN gem install passenger -RUN passenger-install-apache2-module +# # Install Passenger + Apache module +# RUN apt-get update && apt-get install -y \ +# cmake \ +# libgcrypt20 \ +# openssl \ +# rubygems \ +# s3cmd && \ +# apt-get clean && \ +# rm -rf /var/lib/apt/lists/* +# RUN gem install passenger +# RUN passenger-install-apache2-module # RUN apt-get install -y libapache2-mod-passenger lighttpd @@ -99,14 +97,13 @@ RUN a2enmod setenvif RUN a2dissite 000-default RUN a2ensite production -# # Install Passenger + Apache module -# RUN apt-key adv --refresh-keys --keyserver keyserver.ubuntu.com -# RUN apt-get update -# RUN apt-get install -y libapache2-mod-passenger lighttpd - # Enable the Passenger Apache module and restart Apache RUN echo "ServerName $(cat /etc/hostname)" >> /etc/apache2/apache2.conf -RUN a2enmod passenger + +# # Install Passenger + Apache module +RUN passenger-install-apache2-module + +# RUN a2enmod passenger # Check installation RUN /usr/bin/passenger-config validate-install @@ -116,7 +113,7 @@ RUN /usr/sbin/passenger-memory-stats RUN a2enmod proxy proxy_http rewrite lbmethod_byrequests proxy_fcgi # Config the virtual host apache2 -RUN apache2ctl configtest +# RUN apache2ctl configtest # Set Permissions for www-data RUN chown -R www-data: $workdir From c5e18983fbcc4c60a4917305b1f4a7471c7285ca Mon Sep 17 00:00:00 2001 From: Rub21 Date: Fri, 3 May 2024 04:21:14 +0000 Subject: [PATCH 4/8] Update passenger version --- images/web/Dockerfile | 66 +++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/images/web/Dockerfile b/images/web/Dockerfile index 2a0d2691..0757589f 100644 --- a/images/web/Dockerfile +++ b/images/web/Dockerfile @@ -1,6 +1,8 @@ -FROM phusion/passenger-ruby33 +FROM ruby:3.3.0 ENV DEBIAN_FRONTEND=noninteractive ENV workdir /var/www + +# Production OSM setup ENV RAILS_ENV=production # Install the openstreetmap-website dependencies @@ -22,20 +24,6 @@ RUN apt-get update && apt-get install -y nodejs yarn && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -# # Install Passenger + Apache module -# RUN apt-get update && apt-get install -y \ -# cmake \ -# libgcrypt20 \ -# openssl \ -# rubygems \ -# s3cmd && \ -# apt-get clean && \ -# rm -rf /var/lib/apt/lists/* -# RUN gem install passenger -# RUN passenger-install-apache2-module - -# RUN apt-get install -y libapache2-mod-passenger lighttpd - # Install openstreetmap-cgimap requirements RUN apt-get update && apt-get -y install libpqxx-dev libfcgi-dev zlib1g-dev \ libboost-dev libboost-program-options-dev libfmt-dev \ @@ -44,16 +32,19 @@ RUN apt-get update && apt-get -y install libpqxx-dev libfcgi-dev zlib1g-dev \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -# Install cgimap -ENV cgimap /tmp/openstreetmap-cgimap -ENV CGIMAP_GITSHA=5cd3d21bebe9d205828608be4c65bbda8b464308 -RUN git clone -b master https://github.com/zerebubuth/openstreetmap-cgimap.git $cgimap -RUN cd $cgimap && git checkout $CGIMAP_GITSHA -RUN cd $cgimap && \ - ./autogen.sh && \ - ./configure && \ - make && \ - make install +# # Install cgimap +# ENV cgimap /tmp/openstreetmap-cgimap +# ENV CGIMAP_GITSHA=5cd3d21bebe9d205828608be4c65bbda8b464308 +# RUN git clone -b master https://github.com/zerebubuth/openstreetmap-cgimap.git $cgimap +# RUN cd $cgimap && git checkout $CGIMAP_GITSHA +# RUN cd $cgimap && \ +# ./autogen.sh && \ +# ./configure && \ +# make && \ +# make install + +# Install Passenger +RUN gem install passenger # Install svgo required RUN npm install -g svgo @@ -97,23 +88,30 @@ RUN a2enmod setenvif RUN a2dissite 000-default RUN a2ensite production -# Enable the Passenger Apache module and restart Apache +# # Enable the Passenger Apache module and restart Apache RUN echo "ServerName $(cat /etc/hostname)" >> /etc/apache2/apache2.conf -# # Install Passenger + Apache module -RUN passenger-install-apache2-module +# Install Passenger +RUN gem install passenger && passenger-install-apache2-module --auto + +# Config passenger module +RUN echo "LoadModule passenger_module $(passenger-config --root)/buildout/apache2/mod_passenger.so" > /etc/apache2/mods-available/passenger.load +RUN echo "\n\ + PassengerRoot $(passenger-config --root)\n\ + PassengerRuby /usr/bin/ruby\n\ +" > /etc/apache2/mods-available/passenger.conf -# RUN a2enmod passenger +RUN a2enmod passenger -# Check installation -RUN /usr/bin/passenger-config validate-install -RUN /usr/sbin/passenger-memory-stats +# # Check installation +RUN /usr/local/bundle/bin/passenger-config validate-install +RUN /usr/local/bundle/bin/passenger-memory-stats -# Enable required apache modules for the cgimap Apache service +# # Enable required apache modules for the cgimap Apache service RUN a2enmod proxy proxy_http rewrite lbmethod_byrequests proxy_fcgi # Config the virtual host apache2 -# RUN apache2ctl configtest +RUN apache2ctl configtest # Set Permissions for www-data RUN chown -R www-data: $workdir From 204b820651ed730b664ad50622f13625efd18fb3 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Fri, 3 May 2024 04:25:58 +0000 Subject: [PATCH 5/8] Update ruby path --- images/web/Dockerfile | 27 ++++++++++++--------------- images/web/config/production.conf | 2 +- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/images/web/Dockerfile b/images/web/Dockerfile index 0757589f..ee436c0d 100644 --- a/images/web/Dockerfile +++ b/images/web/Dockerfile @@ -32,19 +32,19 @@ RUN apt-get update && apt-get -y install libpqxx-dev libfcgi-dev zlib1g-dev \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -# # Install cgimap -# ENV cgimap /tmp/openstreetmap-cgimap -# ENV CGIMAP_GITSHA=5cd3d21bebe9d205828608be4c65bbda8b464308 -# RUN git clone -b master https://github.com/zerebubuth/openstreetmap-cgimap.git $cgimap -# RUN cd $cgimap && git checkout $CGIMAP_GITSHA -# RUN cd $cgimap && \ -# ./autogen.sh && \ -# ./configure && \ -# make && \ -# make install +# Install cgimap +ENV cgimap /tmp/openstreetmap-cgimap +ENV CGIMAP_GITSHA=5cd3d21bebe9d205828608be4c65bbda8b464308 +RUN git clone -b master https://github.com/zerebubuth/openstreetmap-cgimap.git $cgimap +RUN cd $cgimap && git checkout $CGIMAP_GITSHA +RUN cd $cgimap && \ + ./autogen.sh && \ + ./configure && \ + make && \ + make install # Install Passenger -RUN gem install passenger +RUN gem install passenger && passenger-install-apache2-module --auto # Install svgo required RUN npm install -g svgo @@ -91,14 +91,11 @@ RUN a2ensite production # # Enable the Passenger Apache module and restart Apache RUN echo "ServerName $(cat /etc/hostname)" >> /etc/apache2/apache2.conf -# Install Passenger -RUN gem install passenger && passenger-install-apache2-module --auto - # Config passenger module RUN echo "LoadModule passenger_module $(passenger-config --root)/buildout/apache2/mod_passenger.so" > /etc/apache2/mods-available/passenger.load RUN echo "\n\ PassengerRoot $(passenger-config --root)\n\ - PassengerRuby /usr/bin/ruby\n\ + PassengerRuby /usr/local/bin/ruby\n\ " > /etc/apache2/mods-available/passenger.conf RUN a2enmod passenger diff --git a/images/web/config/production.conf b/images/web/config/production.conf index 7108bb17..68a36f76 100644 --- a/images/web/config/production.conf +++ b/images/web/config/production.conf @@ -2,7 +2,7 @@ # ServerName localhost # Tell Apache and Passenger where your app's 'public' directory is DocumentRoot /var/www/public - PassengerRuby /usr/bin/ruby + PassengerRuby /usr/local/bin/ruby RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} =http # Development mode in case domain is localhost From 5f2ea7c6f79c5141a80856c20eff03d68b0d4a25 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Fri, 3 May 2024 12:18:04 +0000 Subject: [PATCH 6/8] Fix cgimap installation --- images/web/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/images/web/Dockerfile b/images/web/Dockerfile index ee436c0d..18487a13 100644 --- a/images/web/Dockerfile +++ b/images/web/Dockerfile @@ -42,6 +42,7 @@ RUN cd $cgimap && \ ./configure && \ make && \ make install +RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local_libs.conf && ldconfig # Install Passenger RUN gem install passenger && passenger-install-apache2-module --auto From be7123afcc26a27726180f8fd5d2d91a4c9879fa Mon Sep 17 00:00:00 2001 From: Rub21 Date: Fri, 3 May 2024 12:52:55 +0000 Subject: [PATCH 7/8] Set online staging site --- values.staging.template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/values.staging.template.yaml b/values.staging.template.yaml index b099315f..d0d33906 100644 --- a/values.staging.template.yaml +++ b/values.staging.template.yaml @@ -120,7 +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: "api_readonly" + WEBSITE_STATUS: "online" resources: enabled: false requests: From fa53ef6f71506a29a4ff1f8283b235f14154e525 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Fri, 3 May 2024 13:30:51 +0000 Subject: [PATCH 8/8] Rename settings-local.yml to settings.local.yml --- images/web/Dockerfile | 2 +- ...{settings-local.yml => settings.local.yml} | 0 images/web/start.sh | 36 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) rename images/web/config/{settings-local.yml => settings.local.yml} (100%) diff --git a/images/web/Dockerfile b/images/web/Dockerfile index 18487a13..f1b18e40 100644 --- a/images/web/Dockerfile +++ b/images/web/Dockerfile @@ -115,7 +115,7 @@ RUN apache2ctl configtest RUN chown -R www-data: $workdir # Add settings -ADD config/settings-local.yml $workdir/config/ +ADD config/settings.local.yml $workdir/config/ COPY start.sh $workdir/ COPY liveness.sh $workdir/ diff --git a/images/web/config/settings-local.yml b/images/web/config/settings.local.yml similarity index 100% rename from images/web/config/settings-local.yml rename to images/web/config/settings.local.yml diff --git a/images/web/start.sh b/images/web/start.sh index 7a522a93..2bf6f8fb 100755 --- a/images/web/start.sh +++ b/images/web/start.sh @@ -14,40 +14,40 @@ 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-local.yml -sed -i -e 's/server_protocol: "http"/server_protocol: "'$SERVER_PROTOCOL'"/g' $workdir/config/settings-local.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.yml #### 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 -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/openstreetmap@example.com/'$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 +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/openstreetmap@example.com/'$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-local.yml +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 -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_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 sed -i -e 's/# oauth_key: "OAUTH_CLIENT_ID"/oauth_key: "'$OAUTH_KEY'"/g' $workdir/config/settings.yml #### Setup env vars for memcached server -sed -i -e 's/memcache_servers: \[\]/memcache_servers: "'$OPENSTREETMAP_memcache_servers'"/g' $workdir/config/settings-local.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-local.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-local.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 @@ -55,7 +55,7 @@ sed -i -e 's/overpass-api.de/'$OVERPASS_URL'/g' $workdir/app/assets/javascripts/ 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 +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 @@ -68,7 +68,7 @@ while "$flag" = true; do sleep 2 done & - # Enable assets:precompile, to take lates changes for assets in $workdir/config/settings-local.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