Skip to content

Commit d6e58fc

Browse files
authored
Update OSM website version and configs (#384)
* Update osm website version * Update OSM website gitsha * Uncomment the dockerfile * Istall missing libs - libgd-dev * Updte web gitsha * Replace arabic key for better to chekc beter logs * Update settings * Print logs * Update configs for the website * Update config * Update script to start * Update replication script
1 parent 3ab019d commit d6e58fc

File tree

5 files changed

+179
-60
lines changed

5 files changed

+179
-60
lines changed

images/replication-job/start.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,16 @@ function enable_osmdbt_replication() {
100100

101101
# Use osmdbt-enable-replication to set up replication properly
102102
echo "$(date +%F_%H:%M:%S): Running osmdbt-enable-replication..."
103-
if /osmdbt/build/src/osmdbt-enable-replication -c "$osmdbtConfig" 2>&1 | tee -a "${logDirectory}/osmdbt-enable-replication.log"; then
103+
local log_file="${logDirectory}/osmdbt-enable-replication.log"
104+
if /osmdbt/build/src/osmdbt-enable-replication -c "$osmdbtConfig" 2>&1 | tee -a "$log_file"; then
104105
echo "$(date +%F_%H:%M:%S): Successfully enabled osmdbt replication."
105106
return 0
106107
else
108+
# Check if error is "already exists" - this is acceptable
109+
if grep -qi "already exists" "$log_file" 2>/dev/null; then
110+
echo "$(date +%F_%H:%M:%S): Replication slot '$REPLICATION_SLOT' already exists. Replication should be enabled."
111+
return 0
112+
fi
107113
local error_msg="ERROR: Failed to enable osmdbt replication. Check PostgreSQL configuration (wal_level=logical, max_replication_slots >= 1, user with REPLICATION attribute)."
108114
echo "$(date +%F_%H:%M:%S): $error_msg"
109115
send_slack_message "🚨 ${ENVIROMENT:-production}: $error_msg"

images/web/Dockerfile

Lines changed: 101 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,24 @@ 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+
libgd-dev \
21+
pngcrush optipng advancecomp pngquant jhead jpegoptim gifsicle libjpeg-progs unzip\
22+
&& curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
1723
&& apt-get install -y nodejs \
1824
&& npm install -g yarn svgo \
1925
&& apt-get clean && rm -rf /var/lib/apt/lists/*
2026

21-
RUN a2enmod passenger
2227

2328
# 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
29+
ENV OPENSTREETMAP_WEBSITE_GITSHA=a244e419719ded592fb87e7ffd360f6e462a0d67
30+
ENV OSM_WEBSITE_URL=https://github.com/openstreetmap/openstreetmap-website/archive/${OPENSTREETMAP_WEBSITE_GITSHA}.zip
31+
RUN rm -rf $workdir/* && curl -fsSL $OSM_WEBSITE_URL -o /tmp/openstreetmap-website.zip && \
32+
unzip /tmp/openstreetmap-website.zip -d /tmp && \
33+
mv /tmp/openstreetmap-website-$OPENSTREETMAP_WEBSITE_GITSHA/* $workdir && \
34+
rm -rf /tmp/*
35+
3236
RUN gem install bundler && \
3337
bundle install && \
3438
yarn install && \
@@ -45,8 +49,8 @@ RUN rm -f config/credentials.yml.enc && \
4549
export RAILS_MASTER_KEY=$(openssl rand -hex 16) && \
4650
export SECRET_KEY_BASE=$(bundle exec rails secret) && \
4751
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 "\
52+
EDITOR="echo" RAILS_MASTER_KEY=$RAILS_MASTER_KEY bundle exec rails credentials:edit && \
53+
RAILS_MASTER_KEY=$RAILS_MASTER_KEY bundle exec rails runner "\
5054
require 'active_support/encrypted_configuration'; \
5155
require 'yaml'; \
5256
creds = ActiveSupport::EncryptedConfiguration.new(\
@@ -59,40 +63,103 @@ RUN rm -f config/credentials.yml.enc && \
5963
creds.write(credentials.to_yaml); \
6064
puts 'Credentials configured correctly.'"
6165

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

6672
FROM ruby:3.3-slim
6773

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

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
85134

86135
# Apache configuration
87136
COPY config/production.conf /etc/apache2/sites-available/production.conf
137+
138+
RUN passenger-install-apache2-module --snippet > /etc/apache2/mods-available/passenger.load && \
139+
passenger-config build-native-support
140+
88141
RUN a2enmod headers setenvif proxy proxy_http proxy_fcgi fcgid rewrite lbmethod_byrequests passenger && \
89142
a2dissite 000-default && \
90143
a2ensite production && \
91144
echo "ServerName localhost" >> /etc/apache2/apache2.conf && \
92145
apache2ctl configtest
93146

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

images/web/config/production.conf

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# ServerName localhost
33
# Tell Apache and Passenger where your app's 'public' directory is
44
DocumentRoot /var/www/public
5+
PassengerAppEnv production
56
PassengerRuby /usr/local/bin/ruby
67
RewriteEngine On
78

@@ -12,22 +13,19 @@
1213
RewriteCond %{HTTPS} off
1314
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
1415

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]
16+
RewriteCond %{HTTP_HOST} =SERVER_DOMAIN_PLACEHOLDER
17+
RewriteCond %{HTTP_HOST} !^www\. [NC]
18+
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
1919

2020
<Location />
2121
CGIPassAuth On
2222
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
2323
</Location>
2424

25-
# Proxying traffic to CGImap
25+
#Proxying traffic to CGImap
2626
ProxyTimeout 1200
2727
RewriteCond %{REQUEST_URI} ^/api/0\.6/map
2828
RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
29-
30-
RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
3129
RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
3230
RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
3331
RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
@@ -53,4 +51,12 @@
5351
FcgidIOTimeout 1200
5452
FcgidConnectTimeout 1200
5553
</IfModule>
54+
55+
# Allow CORS for JSON, PBF, and PNG files for map-style
56+
<FilesMatch "\.(json|pbf|png)$">
57+
Header set Access-Control-Allow-Origin "*"
58+
Header set Access-Control-Allow-Methods "GET, OPTIONS"
59+
Header set Access-Control-Allow-Headers "Content-Type"
60+
</FilesMatch>
61+
5662
</VirtualHost>

images/web/config/settings.yml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# The server protocol and host
22
server_protocol: "http"
3-
server_url: "openstreetmap.example.com"
3+
server_url: "openstreetmap.example.com"
44
# Publisher
55
#publisher_url: ""
66
# The generator
77
generator: "OpenStreetMap server"
88
copyright_owner: "OpenStreetMap and contributors"
99
attribution_url: "http://www.openstreetmap.org/copyright"
1010
license_url: "http://opendatacommons.org/licenses/odbl/1-0/"
11+
# Legal email address
12+
legal_email: "legal@openstreetmap.org"
1113
# Support email address
1214
support_email: "openstreetmap@example.com"
1315
# Sender addresses for emails
@@ -102,13 +104,13 @@ default_legale: GB
102104
# Location of data for attachments
103105
attachments_dir: ":rails_root/public/attachments"
104106
# Log file to use
105-
#log_path: ""
107+
log_path: "/var/www/log/production.log"
106108
# Log file to use for logstash
107109
#logstash_path: ""
108110
# List of memcache servers to use for caching
109111
memcache_servers: []
110112
# URL of Nominatim instance to use for geocoding
111-
nominatim_url: "https://nominatim-api.openstreetmap.org/"
113+
nominatim_url: "https://nominatim.openstreetmap.org/"
112114
# Default editor
113115
default_editor: "id"
114116
# OAuth application for the web site
@@ -131,6 +133,11 @@ overpass_credentials: false
131133
graphhopper_url: "https://graphhopper.com/api/1/route"
132134
fossgis_osrm_url: "https://routing.openstreetmap.de/"
133135
fossgis_valhalla_url: "https://valhalla1.openstreetmap.de/route"
136+
137+
# Endpoints for Wikimedia integration
138+
wikidata_api_url: "https://www.wikidata.org/w/api.php"
139+
wikimedia_commons_url: "https://commons.wikimedia.org/wiki/"
140+
134141
# External authentication credentials
135142
#google_auth_id: ""
136143
#google_auth_secret: ""
@@ -141,8 +148,15 @@ fossgis_valhalla_url: "https://valhalla1.openstreetmap.de/route"
141148
#github_auth_secret: ""
142149
#microsoft_auth_id: ""
143150
#microsoft_auth_secret: ""
144-
#wikipedia_auth_id: ""
145-
#wikipedia_auth_secret: ""
151+
# wikipedia_auth_id: ""
152+
# wikipedia_auth_secret: ""
153+
#apple_auth_id: ""
154+
#apple_team_id: ""
155+
#apple_key_id: ""
156+
#apple_private_key: ""
157+
# openstreetmap_auth_id: ""
158+
# openstreetmap_auth_secret: ""
159+
# openstreetmap_auth_scopes: ["read_prefs"]
146160
# Thunderforest authentication details
147161
#thunderforest_key: ""
148162
# Tracestrack authentication details
@@ -154,10 +168,10 @@ csp_enforce: false
154168
# URL for reporting Content-Security-Policy violations
155169
#csp_report_url: ""
156170
# 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"
171+
avatar_storage: "s3" # TODO: Change to S3
172+
trace_file_storage: "s3" # TODO: Change to S3
173+
trace_image_storage: "s3" # TODO: Change to S3
174+
trace_icon_storage: "s3" # TODO: Change to S3
161175
# Root URL for storage services
162176
# avatar_storage_url:
163177
# trace_image_storage_url:
@@ -185,3 +199,5 @@ doorkeeper_signing_key: |
185199
-----BEGIN PRIVATE KEY-----
186200
PRIVATE_KEY
187201
-----END PRIVATE KEY-----
202+
203+
mastodon_url: "https://mapstodon.space/@osm"

0 commit comments

Comments
 (0)