Skip to content

Commit 3840d40

Browse files
committed
Update osm website version
1 parent b0e15ce commit 3840d40

File tree

4 files changed

+148
-57
lines changed

4 files changed

+148
-57
lines changed

images/web/Dockerfile

Lines changed: 105 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
FROM ruby:3.3-slim AS builder
22

33
ENV DEBIAN_FRONTEND=noninteractive \
4-
workdir=/var/www
4+
workdir=/var/www \
5+
BUNDLE_PATH=/usr/local/bundle \
6+
GEM_HOME=/usr/local/bundle \
7+
GEM_PATH=/usr/local/bundle \
8+
PATH="/usr/local/bundle/bin:$PATH" \
9+
RAILS_ENV=production
510

611
WORKDIR $workdir
712

@@ -10,25 +15,23 @@ RUN apt-get update && \
1015
apt-get install -y --no-install-recommends \
1116
git curl gnupg build-essential \
1217
libarchive-dev zlib1g-dev libcurl4-openssl-dev \
13-
apache2 apache2-dev libapache2-mod-passenger libapache2-mod-fcgid libapr1-dev libaprutil1-dev \
18+
apache2 apache2-dev libapache2-mod-fcgid libapr1-dev libaprutil1-dev \
1419
postgresql-client libpq-dev libxml2-dev libyaml-dev \
15-
pngcrush optipng advancecomp pngquant jhead jpegoptim gifsicle libjpeg-progs \
16-
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
20+
pngcrush optipng advancecomp pngquant jhead jpegoptim gifsicle libjpeg-progs unzip\
21+
&& curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
1722
&& apt-get install -y nodejs \
1823
&& npm install -g yarn svgo \
1924
&& apt-get clean && rm -rf /var/lib/apt/lists/*
2025

21-
RUN a2enmod passenger
2226

2327
# Clone OSM Website
24-
ENV OPENSTREETMAP_WEBSITE_GITSHA=ea3760f94d9d74d3aaa8492182b9e1a15ec1effa
25-
RUN rm -rf $workdir/* && \
26-
git clone https://github.com/openstreetmap/openstreetmap-website.git $workdir && \
27-
cd $workdir && \
28-
git checkout $OPENSTREETMAP_WEBSITE_GITSHA && \
29-
git fetch && rm -rf .git
30-
31-
# Install Ruby/Node dependencies
28+
ENV OPENSTREETMAP_WEBSITE_GITSHA=acb1e73fa98e6cb7adf67f99e0be5891dcd4f6ea
29+
ENV OSM_WEBSITE_URL=https://github.com/openstreetmap/openstreetmap-website/archive/${OPENSTREETMAP_WEBSITE_GITSHA}.zip
30+
RUN rm -rf $workdir/* && curl -fsSL $OSM_WEBSITE_URL -o /tmp/openstreetmap-website.zip && \
31+
unzip /tmp/openstreetmap-website.zip -d /tmp && \
32+
mv /tmp/openstreetmap-website-$OPENSTREETMAP_WEBSITE_GITSHA/* $workdir && \
33+
rm -rf /tmp/*
34+
3235
RUN gem install bundler && \
3336
bundle install && \
3437
yarn install && \
@@ -45,8 +48,8 @@ RUN rm -f config/credentials.yml.enc && \
4548
export RAILS_MASTER_KEY=$(openssl rand -hex 16) && \
4649
export SECRET_KEY_BASE=$(bundle exec rails secret) && \
4750
echo $RAILS_MASTER_KEY > config/master.key && \
48-
EDITOR="echo" RAILS_MASTER_KEY=$RAILS_MASTER_KEY rails credentials:edit && \
49-
RAILS_MASTER_KEY=$RAILS_MASTER_KEY rails runner "\
51+
EDITOR="echo" RAILS_MASTER_KEY=$RAILS_MASTER_KEY bundle exec rails credentials:edit && \
52+
RAILS_MASTER_KEY=$RAILS_MASTER_KEY bundle exec rails runner "\
5053
require 'active_support/encrypted_configuration'; \
5154
require 'yaml'; \
5255
creds = ActiveSupport::EncryptedConfiguration.new(\
@@ -59,40 +62,108 @@ RUN rm -f config/credentials.yml.enc && \
5962
creds.write(credentials.to_yaml); \
6063
puts 'Credentials configured correctly.'"
6164

62-
# Precompile assets
63-
RUN bundle exec rake i18n:js:export && \
64-
bundle exec rake assets:precompile
65+
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
66+
RUN SECRET_KEY_BASE_DUMMY=1 \
67+
bundle exec i18n export && \
68+
bundle exec rails assets:precompile
69+
6570

6671
FROM ruby:3.3-slim
6772

6873
ENV DEBIAN_FRONTEND=noninteractive \
69-
workdir=/var/www
70-
71-
WORKDIR $workdir
72-
73-
# Install only runtime dependencies
74-
RUN apt-get update && apt-get install -y --no-install-recommends \
75-
apache2 libapache2-mod-passenger libapache2-mod-fcgid \
76-
libpq5 libxml2 libyaml-0-2 libarchive13 file libgd-dev \
77-
postgresql-client curl \
74+
workdir=/var/www \
75+
BUNDLE_PATH=/usr/local/bundle \
76+
GEM_HOME=/usr/local/bundle \
77+
GEM_PATH=/usr/local/bundle \
78+
PATH="/usr/local/bundle/bin:$PATH" \
79+
RAILS_ENV=production \
80+
PATH="$PATH:$GEM_HOME/bin"
81+
82+
# Install base dependencies for Passenger gem compilation and runtime
83+
RUN BUILD_DEPS=" \
84+
build-essential \
85+
apache2-dev \
86+
libcurl4-openssl-dev \
87+
zlib1g-dev \
88+
libssl-dev \
89+
npm \
90+
" \
91+
&& apt-get update && apt-get install -y --no-install-recommends \
92+
$BUILD_DEPS \
93+
libgd-dev \
94+
apache2 \
95+
libapache2-mod-fcgid \
96+
libpq5 \
97+
libxml2 \
98+
libyaml-0-2 \
99+
libarchive13 \
100+
file \
101+
pngcrush \
102+
optipng \
103+
advancecomp \
104+
pngquant \
105+
jhead \
106+
jpegoptim \
107+
gifsicle \
108+
postgresql-client \
109+
curl \
110+
libvips \
111+
nodejs \
112+
\
113+
&& npm install -g svgo \
114+
\
115+
# Install Passenger as a gem and compile the Apache module
116+
\
117+
&& gem install passenger --no-document \
118+
&& yes | passenger-install-apache2-module --auto --languages ruby \
119+
&& passenger-config validate-install --auto \
120+
\
121+
# Delete the build dependencies to reduce image size
122+
\
123+
&& apt-get purge -y --auto-remove $BUILD_DEPS \
124+
\
125+
# libgd-dev is requiered by the app on run time to process gps files
126+
\
127+
&& apt-get update && apt-get install -y --no-install-recommends libgd3 libgd-dev \
128+
\
129+
# Final cleanup
130+
\
78131
&& apt-get clean && rm -rf /var/lib/apt/lists/*
79132

80-
COPY --from=builder /var/www /var/www
81-
COPY --from=builder /usr/local/bundle /usr/local/bundle
82-
83-
# Symlink tmp for Passenger
84-
RUN ln -s /tmp /var/www/tmp
85133

86134
# Apache configuration
87135
COPY config/production.conf /etc/apache2/sites-available/production.conf
136+
137+
RUN passenger-install-apache2-module --snippet > /etc/apache2/mods-available/passenger.load && \
138+
passenger-config build-native-support
139+
88140
RUN a2enmod headers setenvif proxy proxy_http proxy_fcgi fcgid rewrite lbmethod_byrequests passenger && \
89141
a2dissite 000-default && \
90142
a2ensite production && \
91143
echo "ServerName localhost" >> /etc/apache2/apache2.conf && \
92144
apache2ctl configtest
93145

146+
RUN echo '#!/bin/bash\nexec /usr/local/bin/ruby --yjit --yjit-exec-mem-size=64 "$@"' > /usr/local/bin/ruby_yjit && \
147+
chmod +x /usr/local/bin/ruby_yjit
148+
149+
WORKDIR $workdir
150+
151+
COPY --chown=www-data:www-data --from=builder /var/www /$workdir
152+
COPY --from=builder /usr/local/bundle /usr/local/bundle
153+
94154
COPY config/settings.yml $workdir/config/
95155
COPY start.sh liveness.sh $workdir/
96-
RUN chmod +x $workdir/*.sh
97-
RUN chown -R www-data:www-data /var/www
156+
157+
RUN ln -s /tmp /var/www/tmp
158+
159+
RUN mkdir -p /var/www/log && \
160+
touch /var/www/log/production.log && \
161+
chown -R www-data:www-data /var/www/log /var/www/public && \
162+
chown -R www-data:www-data /var/www
163+
98164
CMD ["./start.sh"]
165+
166+
167+
168+
169+

images/web/config/production.conf

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,13 @@
55
PassengerRuby /usr/local/bin/ruby
66
RewriteEngine On
77

8-
# Redirect to HTTPS
9-
RewriteCond %{HTTP:X-Forwarded-Proto} =http
8+
# Redirect HTTP to HTTPS for current domain (except localhost)
109
RewriteCond %{HTTP_HOST} !=localhost
1110
RewriteCond %{HTTP_HOST} !=127.0.0.1
1211
RewriteCond %{HTTPS} off
12+
RewriteCond %{HTTP:X-Forwarded-Proto} !https
1313
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
1414

15-
# Redirect to www openstreetmap.org
16-
# RewriteCond %{HTTP_HOST} =openstreetmap.org
17-
# RewriteCond %{HTTP_HOST} !^www\. [NC]
18-
# RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
19-
2015
<Location />
2116
CGIPassAuth On
2217
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

images/web/config/settings.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ default_legale: GB
102102
# Location of data for attachments
103103
attachments_dir: ":rails_root/public/attachments"
104104
# Log file to use
105-
#log_path: ""
105+
log_path: "/var/www/log/production.log"
106106
# Log file to use for logstash
107107
#logstash_path: ""
108108
# List of memcache servers to use for caching
109109
memcache_servers: []
110110
# URL of Nominatim instance to use for geocoding
111-
nominatim_url: "https://nominatim-api.openstreetmap.org/"
111+
nominatim_url: "https://nominatim.openstreetmap.org/"
112112
# Default editor
113113
default_editor: "id"
114114
# OAuth application for the web site
@@ -131,6 +131,11 @@ overpass_credentials: false
131131
graphhopper_url: "https://graphhopper.com/api/1/route"
132132
fossgis_osrm_url: "https://routing.openstreetmap.de/"
133133
fossgis_valhalla_url: "https://valhalla1.openstreetmap.de/route"
134+
135+
# Endpoints for Wikimedia integration
136+
# wikidata_api_url: "https://www.wikidata.org/w/api.php"
137+
# wikimedia_commons_url: "https://commons.wikimedia.org/wiki/"
138+
134139
# External authentication credentials
135140
#google_auth_id: ""
136141
#google_auth_secret: ""
@@ -141,8 +146,15 @@ fossgis_valhalla_url: "https://valhalla1.openstreetmap.de/route"
141146
#github_auth_secret: ""
142147
#microsoft_auth_id: ""
143148
#microsoft_auth_secret: ""
144-
#wikipedia_auth_id: ""
145-
#wikipedia_auth_secret: ""
149+
# wikipedia_auth_id: ""
150+
# wikipedia_auth_secret: ""
151+
#apple_auth_id: ""
152+
#apple_team_id: ""
153+
#apple_key_id: ""
154+
#apple_private_key: ""
155+
# openstreetmap_auth_id: ""
156+
# openstreetmap_auth_secret: ""
157+
# openstreetmap_auth_scopes: ["read_prefs"]
146158
# Thunderforest authentication details
147159
#thunderforest_key: ""
148160
# Tracestrack authentication details
@@ -154,10 +166,10 @@ csp_enforce: false
154166
# URL for reporting Content-Security-Policy violations
155167
#csp_report_url: ""
156168
# Storage services to use in production mode
157-
avatar_storage: "local"
158-
trace_file_storage: "local"
159-
trace_image_storage: "local"
160-
trace_icon_storage: "local"
169+
avatar_storage: "local" # TODO: Change to S3
170+
trace_file_storage: "local" # TODO: Change to S3
171+
trace_image_storage: "local" # TODO: Change to S3
172+
trace_icon_storage: "local" # TODO: Change to S3
161173
# Root URL for storage services
162174
# avatar_storage_url:
163175
# trace_image_storage_url:

images/web/start.sh

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ start_background_jobs() {
9999
done
100100
}
101101

102+
log_and_tail() {
103+
local file=$1
104+
if [ -f "$file" ]; then
105+
echo "Logs from: $file"
106+
tail -F "$file" &
107+
else
108+
echo "⚠️ Log file not found: $file"
109+
fi
110+
}
111+
112+
102113
setup_production() {
103114
setup_env_vars
104115

@@ -107,11 +118,8 @@ setup_production() {
107118
sleep 2
108119
done
109120

110-
# echo "Running asset precompilation..."
111-
# time bundle exec rake i18n:js:export assets:precompile
112-
113-
echo "Copying static assets..."
114-
cp "$workdir/public/leaflet-ohm-timeslider-v2/assets/"* "$workdir/public/assets/"
121+
# Create the /passenger-instreg directory if it doesn’t exist. This is required in newer versions of Passenger.
122+
mkdir -p /var/run/passenger-instreg
115123

116124
echo "Running database migrations..."
117125
time bundle exec rails db:migrate
@@ -121,12 +129,17 @@ setup_production() {
121129
./cgimap.sh
122130
fi
123131

132+
echo "Logging and tailing logs..."
133+
# log_and_tail /var/www/log/production.log
134+
# log_and_tail /var/www/log/jobs_work.log
135+
log_and_tail /var/log/apache2/error.log
136+
log_and_tail /var/log/apache2/access.log
137+
124138
echo "Starting Apache server..."
125-
apachectl -k start -DFOREGROUND &
126-
start_background_jobs
139+
start_background_jobs &
140+
apachectl -k start -DFOREGROUND
127141
}
128142

129-
130143
setup_development() {
131144
restore_db
132145
cp "$workdir/config/example.storage.yml" "$workdir/config/storage.yml"

0 commit comments

Comments
 (0)