Skip to content

Commit deadff6

Browse files
committed
Update web-api container
1 parent 6549d9c commit deadff6

File tree

8 files changed

+292
-222
lines changed

8 files changed

+292
-222
lines changed

images/cgimap/start.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export CGIMAP_OAUTH_HOST=$POSTGRES_HOST
99
export CGIMAP_UPDATE_HOST=$POSTGRES_HOST
1010
# Export CGIMAP configuration
1111
export CGIMAP_LOGFILE="/var/www/log/cgimap.log"
12-
export CGIMAP_MEMCACHE=$OPENSTREETMAP_MEMCACHE_SERVERS
12+
export CGIMAP_MEMCACHE=$MEMCACHE_SERVER
1313
# Average number of bytes/s to allow each client
1414
export CGIMAP_RATELIMIT="204800"
1515
# Maximum debt in MB to allow each client before rate limiting

images/web/Dockerfile

+87-100
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,98 @@
1-
FROM ubuntu:22.04
2-
ENV DEBIAN_FRONTEND=noninteractive
3-
ENV workdir /var/www
4-
5-
# Production OSM setup
6-
ENV RAILS_ENV=production
7-
8-
# Install the openstreetmap-website dependencies
9-
RUN apt-get update \
10-
&& apt-get install -y \
11-
ruby ruby-dev ruby-bundler libmagickwand-dev libxml2-dev libxslt1-dev \
12-
apache2 apache2-dev build-essential git-core postgresql-client \
13-
libpq-dev libsasl2-dev imagemagick libffi-dev libgd-dev libarchive-dev libbz2-dev curl \
14-
default-jre-headless file gpg-agent libvips-dev locales software-properties-common tzdata unzip \
15-
advancecomp gifsicle libjpeg-progs jhead jpegoptim optipng pngcrush pngquant libyaml-dev \
16-
&& apt-get clean \
17-
&& rm -rf /var/lib/apt/lists/*
18-
19-
## Install node
20-
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
21-
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
22-
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
23-
RUN apt-get update && apt-get install -y nodejs yarn && \
24-
apt-get clean && \
25-
rm -rf /var/lib/apt/lists/*
26-
27-
# Install openstreetmap-cgimap requirements
28-
RUN apt-get update && apt-get -y install libxml2-dev libpqxx-dev libfcgi-dev zlib1g-dev libbrotli-dev \
29-
libboost-program-options-dev libfmt-dev libmemcached-dev libcrypto++-dev \
30-
libargon2-dev libyajl-dev cmake libapache2-mod-fcgid && \
31-
apt-get clean && \
32-
rm -rf /var/lib/apt/lists/*
33-
34-
# Install cgimap, before remove basic auth
35-
ENV cgimap /openstreetmap-cgimap
36-
ENV CGIMAP_GITSHA=26cd7fa10affe5dbd13dbe16de34421059f53f18
37-
RUN git clone -b master https://github.com/zerebubuth/openstreetmap-cgimap.git $cgimap \
38-
&& cd $cgimap \
39-
&& git checkout $CGIMAP_GITSHA \
40-
&& rm -rf .git \
41-
&& mkdir build \
42-
&& cd build \
43-
&& cmake .. \
44-
&& cmake --build .
45-
46-
# Install svgo required
47-
RUN npm install -g svgo
48-
49-
# Install openstreetmap-website
50-
RUN rm -rf $workdir/html
51-
52-
## Sep 2023
53-
ENV OPENSTREETMAP_WEBSITE_GITSHA=d23763d6cdbf5ec11f0e83f8e6e8fb32ed973e6a
54-
RUN curl -L https://github.com/openstreetmap/openstreetmap-website/archive/$OPENSTREETMAP_WEBSITE_GITSHA.zip --output website.zip && unzip website.zip
55-
RUN mv openstreetmap-website-$OPENSTREETMAP_WEBSITE_GITSHA/* $workdir/
56-
WORKDIR $workdir
57-
58-
# Install Ruby packages
59-
RUN gem install bundler && bundle install
60-
61-
# Configure database.yml and secrets.yml
62-
RUN cp $workdir/config/example.database.yml $workdir/config/database.yml
63-
RUN touch $workdir/config/settings.local.yml
64-
RUN cp $workdir/config/example.storage.yml $workdir/config/storage.yml
65-
RUN echo "#session key \n\
66-
production: \n\
67-
secret_key_base: $(rails secret)" > $workdir/config/secrets.yml
68-
# Protect sensitive information
69-
RUN chmod 600 $workdir/config/database.yml $workdir/config/secrets.yml
70-
RUN bundle exec bin/yarn install
1+
FROM ruby:3.3-slim AS builder
712

72-
RUN rails i18n:js:export assets:precompile
73-
74-
# The rack interface requires a `tmp` directory to use openstreetmap-cgimap
75-
RUN ln -s /tmp /var/www/tmp
3+
ENV DEBIAN_FRONTEND=noninteractive \
4+
workdir=/var/www
765

77-
# Add Apache configuration file
78-
ADD config/production.conf /etc/apache2/sites-available/production.conf
79-
RUN a2enmod headers
80-
RUN a2enmod setenvif
81-
RUN a2dissite 000-default
82-
RUN a2ensite production
6+
WORKDIR $workdir
837

84-
# Install Passenger + Apache module
85-
RUN apt-key adv --refresh-keys --keyserver keyserver.ubuntu.com
86-
RUN apt-get update && apt-get install -y libapache2-mod-passenger lighttpd
8+
# Install base build dependencies
9+
RUN apt-get update && \
10+
apt-get install -y --no-install-recommends \
11+
git curl gnupg build-essential \
12+
libarchive-dev zlib1g-dev libcurl4-openssl-dev \
13+
apache2 apache2-dev libapache2-mod-passenger libapache2-mod-fcgid libapr1-dev libaprutil1-dev \
14+
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 - \
17+
&& apt-get install -y nodejs \
18+
&& npm install -g yarn svgo \
19+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
8720

88-
# Enable the Passenger Apache module and restart Apache
89-
RUN echo "ServerName $(cat /etc/hostname)" >> /etc/apache2/apache2.conf
9021
RUN a2enmod passenger
9122

92-
# Check installation
93-
RUN /usr/bin/passenger-config validate-install
94-
RUN /usr/sbin/passenger-memory-stats
95-
96-
# Enable required apache modules for the cgimap Apache service
97-
RUN a2enmod proxy proxy_http rewrite lbmethod_byrequests proxy_fcgi
23+
# 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
32+
RUN gem install bundler && \
33+
bundle install && \
34+
yarn install && \
35+
bundle exec rake yarn:install
36+
37+
# Dummy config for precompile
38+
RUN cp config/example.database.yml config/database.yml && \
39+
cp config/example.storage.yml config/storage.yml && \
40+
touch config/settings.local.yml && \
41+
chmod 600 config/database.yml
42+
43+
# Create dummy credentials
44+
RUN rm -f config/credentials.yml.enc && \
45+
export RAILS_MASTER_KEY=$(openssl rand -hex 16) && \
46+
export SECRET_KEY_BASE=$(bundle exec rails secret) && \
47+
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 "\
50+
require 'active_support/encrypted_configuration'; \
51+
require 'yaml'; \
52+
creds = ActiveSupport::EncryptedConfiguration.new(\
53+
config_path: 'config/credentials.yml.enc', \
54+
key_path: 'config/master.key', \
55+
env_key: 'RAILS_MASTER_KEY', \
56+
raise_if_missing_key: true \
57+
); \
58+
credentials = { secret_key_base: '$SECRET_KEY_BASE' }; \
59+
creds.write(credentials.to_yaml); \
60+
puts 'Credentials configured correctly.'"
61+
62+
# Precompile assets
63+
RUN bundle exec rake i18n:js:export && \
64+
bundle exec rake assets:precompile
65+
66+
FROM ruby:3.3-slim
67+
68+
ENV DEBIAN_FRONTEND=noninteractive \
69+
workdir=/var/www
9870

99-
# Config the virtual host apache2
100-
RUN apache2ctl configtest
71+
WORKDIR $workdir
10172

102-
# Set Permissions for www-data
103-
RUN chown -R www-data: $workdir
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 \
78+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
10479

105-
# Add settings
106-
ADD config/settings.yml $workdir/config/
80+
COPY --from=builder /var/www /var/www
81+
COPY --from=builder /usr/local/bundle /usr/local/bundle
10782

108-
COPY start.sh $workdir/
109-
COPY liveness.sh $workdir/
83+
# Symlink tmp for Passenger
84+
RUN ln -s /tmp /var/www/tmp
11085

111-
CMD $workdir/start.sh
86+
# Apache configuration
87+
COPY config/production.conf /etc/apache2/sites-available/production.conf
88+
RUN a2enmod headers setenvif proxy proxy_http proxy_fcgi fcgid rewrite lbmethod_byrequests passenger && \
89+
a2dissite 000-default && \
90+
a2ensite production && \
91+
echo "ServerName localhost" >> /etc/apache2/apache2.conf && \
92+
apache2ctl configtest
93+
94+
COPY config/settings.yml $workdir/config/
95+
COPY start.sh liveness.sh $workdir/
96+
RUN chmod +x $workdir/*.sh
97+
RUN chown -R www-data:www-data /var/www
98+
CMD ["./start.sh"]

images/web/config/production.conf

+32-18
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,55 @@
22
# ServerName localhost
33
# Tell Apache and Passenger where your app's 'public' directory is
44
DocumentRoot /var/www/public
5-
PassengerRuby /usr/bin/ruby
5+
PassengerRuby /usr/local/bin/ruby
66
RewriteEngine On
7+
8+
# Redirect to HTTPS
79
RewriteCond %{HTTP:X-Forwarded-Proto} =http
8-
# Development mode in case domain is localhost
9-
# ======Redirect to HTTPS
1010
RewriteCond %{HTTP_HOST} !=localhost
1111
RewriteCond %{HTTP_HOST} !=127.0.0.1
1212
RewriteCond %{HTTPS} off
1313
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
1414

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

2020
<Location />
21-
CGIPassAuth On
21+
CGIPassAuth On
22+
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
2223
</Location>
2324

24-
# ======Proxying traffic to CGImap====
25+
# Proxying traffic to CGImap
26+
ProxyTimeout 1200
2527
RewriteCond %{REQUEST_URI} ^/api/0\.6/map
26-
RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
28+
RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
29+
2730
RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
28-
RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
29-
RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
30-
RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
31-
RewriteRule ^/api/0\.6/node/[0-9]+/ways(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
32-
RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
33-
RewriteRule ^/api/0\.6/(nodes|ways|relations)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
34-
RewriteRule ^/api/0\.6/changeset/[0-9]+/(upload|download)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
31+
RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
32+
RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
33+
RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
34+
RewriteRule ^/api/0\.6/node/[0-9]+/ways(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
35+
RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
36+
RewriteRule ^/api/0\.6/(nodes|ways|relations)(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
37+
RewriteRule ^/api/0\.6/changeset/[0-9]+/(upload|download)(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
3538

3639
# Relax Apache security settings
3740
<Directory /var/www/public>
3841
AllowOverride None
3942
Allow from all
4043
Options -MultiViews
4144
</Directory>
42-
</VirtualHost>
45+
46+
# Additional FastCGI configurations
47+
<IfModule mod_proxy_fcgi.c>
48+
ProxyTimeout 1200
49+
ProxyBadHeader Ignore
50+
</IfModule>
51+
52+
<IfModule mod_fcgid.c>
53+
FcgidIOTimeout 1200
54+
FcgidConnectTimeout 1200
55+
</IfModule>
56+
</VirtualHost>

images/web/config/settings.yml

+28-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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
@@ -32,7 +32,7 @@ default_changeset_query_limit: 100
3232
# Maximum limit on the number of changesets returned by the changeset query api method
3333
max_changeset_query_limit: 100
3434
# Maximum number of nodes that will be returned by the api in a map request
35-
max_number_of_nodes: 50000
35+
max_number_of_nodes: 100000
3636
# Maximum number of nodes that can be in a way (checked on save)
3737
max_number_of_way_nodes: 2000
3838
# Maximum number of members that can be in a relation (checked on save)
@@ -50,21 +50,26 @@ max_trace_size: 1000000
5050
# Zoom level to use for postcode results from the geocoder
5151
postcode_zoom: 15
5252
# Timeout for API calls in seconds
53-
api_timeout: 300
53+
api_timeout: 600
5454
# Timeout for web pages in seconds
55-
web_timeout: 30
55+
web_timeout: 600
5656
# Periods (in hours) which are allowed for user blocks
5757
user_block_periods: [0, 1, 3, 6, 12, 24, 48, 96, 168, 336, 731, 4383, 8766, 87660]
5858
# Account deletion cooldown period (in hours) since last changeset close; null to disable, 0 to make sure there aren't any open changesets when the deletion happens
5959
user_account_deletion_delay: null
6060
# Rate limit for message sending
6161
max_messages_per_hour: 60
62+
# Default limit on the number of messages returned by inbox and outbox message api
63+
default_message_query_limit: 100
64+
# Maximum number of messages returned by inbox and outbox message api
65+
max_message_query_limit: 100
6266
# Rate limit for friending
6367
max_friends_per_hour: 60
6468
# Rate limit for changeset comments
6569
min_changeset_comments_per_hour: 1
6670
initial_changeset_comments_per_hour: 6
6771
max_changeset_comments_per_hour: 60
72+
comments_to_max_changeset_comments: 200
6873
moderator_changeset_comments_per_hour: 36000
6974
# Rate limit for changes
7075
min_changes_per_hour: 100
@@ -73,6 +78,13 @@ max_changes_per_hour: 100000
7378
days_to_max_changes: 7
7479
importer_changes_per_hour: 1000000
7580
moderator_changes_per_hour: 1000000
81+
# Size limit for changes
82+
min_size_limit: 10000000
83+
initial_size_limit: 30000000
84+
max_size_limit: 5400000000
85+
days_to_max_size_limit: 28
86+
importer_size_limit: 5400000000
87+
moderator_size_limit: 5400000000
7688
# Domain for handling message replies
7789
#messages_domain: "messages.openstreetmap.org"
7890
# MaxMind GeoIPv2 database
@@ -94,25 +106,26 @@ attachments_dir: ":rails_root/public/attachments"
94106
# Log file to use for logstash
95107
#logstash_path: ""
96108
# List of memcache servers to use for caching
97-
#memcache_servers: []
98-
# Enable HTTP basic authentication support
99-
basic_auth_support: true
100-
# Enable legacy OAuth 1.0 support
101-
oauth_10_support: true
102-
oauth_10_registration: true
109+
memcache_servers: []
103110
# URL of Nominatim instance to use for geocoding
104-
nominatim_url: "https://nominatim.openstreetmap.org/"
111+
nominatim_url: "https://nominatim-api.openstreetmap.org/"
105112
# Default editor
106113
default_editor: "id"
107114
# OAuth application for the web site
108-
oauth_application: "OAUTH_CLIENT_ID"
109-
oauth_key: "OAUTH_KEY"
115+
oauth_application: ""
116+
oauth_key: ""
110117
# OAuth application for iD
111118
id_application: ""
112119
# Imagery to return in capabilities as blacklisted
113-
imagery_blacklist: []
120+
imagery_blacklist:
121+
# Current Google imagery URLs have google or googleapis in the domain
122+
- ".*\\.google(apis)?\\..*/.*"
123+
# Blacklist VWorld
124+
- "http://xdworld\\.vworld\\.kr:8080/.*"
125+
# Blacklist here
126+
- ".*\\.here\\.com[/:].*"
114127
# URL of Overpass instance to use for feature queries
115-
overpass_url: "https://overpass-api.de/api/interpreter"
128+
overpass_url: "https://overpass-api.openstreetmap.org/api/interpreter"
116129
overpass_credentials: false
117130
# Routing endpoints
118131
graphhopper_url: "https://graphhopper.com/api/1/route"

0 commit comments

Comments
 (0)