Skip to content

Commit

Permalink
Update web container - testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Feb 16, 2024
1 parent d65ff70 commit a6e7fb7
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 112 deletions.
184 changes: 93 additions & 91 deletions images/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,146 +1,148 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive
ENV RUBY_MAJOR 3.0
ARG RUBY_VERSION=3.0.6
ENV RUBY_VERSION $RUBY_VERSION
ENV PATH /opt/ruby/bin:$PATH:/opt/rbenv/plugins/ruby-build/bin

# ruby-build
RUN set -ex \
&& mkdir -p /etc/network/interfaces.d \
&& BaseDeps=' \
git \
gcc \
autoconf \
bison \
build-essential \
libssl-dev \
libyaml-dev \
libreadline6-dev \
zlib1g-dev \
libncurses5-dev \
libffi-dev \
libgdbm6 \
libgdbm-dev \
make \
wget \
curl \
iproute2 \
net-tools \
tzdata \
locales \
ca-certificates' \
&& apt-get update \
&& DEBCONF_NOWARNINGS=yes apt-get -y upgrade \
&& DEBCONF_NOWARNINGS=yes DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $BaseDeps \
&& rm -rf /var/lib/apt/lists/* \
&& git clone https://github.com/sstephenson/ruby-build.git /opt/rbenv/plugins/ruby-build \
&& ruby-build ${RUBY_VERSION} /opt/ruby

ENV workdir /var/www
ENV RAILS_ENV=production

# Install the openstreetmap-website dependencies
RUN apt-get update \
&& apt-get install -y \
libmagickwand-dev libxml2-dev libxslt1-dev \
nodejs npm libv8-dev apache2 apache2-dev build-essential git-core postgresql-client \
libpq-dev libsasl2-dev imagemagick libffi-dev libgd-dev libarchive-dev libbz2-dev yarnpkg curl unzip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install openstreetmap-cgimap requiriments
# Install system packages then clean up to minimize image size
RUN apt-get update \
&& apt-get -y install \
libxml2-dev libpqxx-dev libfcgi-dev zlib1g-dev \
libboost-dev libboost-program-options-dev libboost-filesystem-dev \
libboost-system-dev libboost-locale-dev libmemcached-dev \
libcrypto++-dev libargon2-dev libyajl-dev automake autoconf libtool \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*


&& apt-get install --no-install-recommends -y \
build-essential \
curl \
default-jre-headless \
file \
git-core \
gpg-agent \
libarchive-dev \
libffi-dev \
libgd-dev \
libpq-dev \
libsasl2-dev \
libvips-dev \
libxml2-dev \
libxslt1-dev \
libyaml-dev \
locales \
postgresql-client \
ruby \
ruby-dev \
ruby-bundler \
software-properties-common \
tzdata \
unzip \
apache2 \
apache2-dev \
libyaml-dev \
&& add-apt-repository -y ppa:mozillateam/ppa \
&& echo "Package: *\nPin: release o=LP-PPA-mozillateam\nPin-Priority: 1001" > /etc/apt/preferences.d/mozilla-firefox \
&& apt-get install --no-install-recommends -y \
firefox-geckodriver \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install node
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 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 \
libmemcached-dev libcrypto++-dev libargon2-dev libyajl-dev \
automake autoconf libtool && \
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
# openstreetmap-cgimap version at Jun 21, 2021
RUN cd $cgimap && git checkout v0.8.6
RUN cd $cgimap && git checkout $CGIMAP_GITSHA
RUN cd $cgimap && \
./autogen.sh && \
./configure && \
make && \
make install
./autogen.sh && \
./configure && \
make && \
make install

# Install node
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 svgo required
RUN npm install -g svgo

# Install openstreetmap-website
RUN rm -rf $workdir/html

ENV OPENSTREETMAP_WEBSITE_GITSHA=c24b5481812aba9e83da1fd855ccb37f92c5d75e
RUN mkdir -p $workdir/
ENV OPENSTREETMAP_WEBSITE_GITSHA=6c03ef52bdba8c2b1549cb5baad8bcbb0fb48864
RUN curl -L https://github.com/openstreetmap/openstreetmap-website/archive/$OPENSTREETMAP_WEBSITE_GITSHA.zip --output website.zip && unzip website.zip
RUN mv openstreetmap-website-$OPENSTREETMAP_WEBSITE_GITSHA/* $workdir/
WORKDIR $workdir
RUN echo "gem 'image_optim_pack', :git => 'https://github.com/toy/image_optim_pack.git'" >> Gemfile

# Install Ruby packages
RUN gem install bundler && bundle install
# # change the echo here with a reason for changing the commithash
# RUN echo 'update map style'
# RUN git fetch

# Install Ruby packages
RUN gem update bundler
RUN bundle install
RUN bundle exec bin/yarn install

# Configure database.yml and secrets.yml
RUN cp $workdir/config/example.database.yml $workdir/config/database.yml
RUN touch $workdir/config/settings.local.yml
RUN cp $workdir/config/example.storage.yml $workdir/config/storage.yml
RUN echo "export SECRET_KEY_BASE=\$(bundle exec rake secret)" >> /etc/profile
ENV SECRET_KEY_BASE=${SECRET_KEY_BASE}

RUN echo "#session key \n\
production: \n\
secret_key_base: $(bundle exec rake secret)" > $workdir/config/secrets.yml
production: \n\
secret_key_base: ${SECRET_KEY_BASE}" > $workdir/config/secrets.yml
# Protect sensitive information
RUN chmod 600 $workdir/config/database.yml $workdir/config/secrets.yml

RUN yarn install
RUN bundle exec rake yarn:install
RUN bundle exec rake i18n:js:export
RUN bundle exec rake assets:precompile
# RUN bundle exec rake i18n:js:export
# RUN bundle exec rake assets:precompile

RUN apt-get update && apt-get install -y libapache2-mod-passenger

# The rack interface requires a `tmp` directory to use openstreetmap-cgimap
RUN ln -s /tmp /var/www/tmp

# Add Apache configuration file
ADD config/production.conf /etc/apache2/sites-available/production.conf
RUN a2enmod headers
RUN a2enmod setenvif
RUN a2dissite 000-default
RUN a2ensite production

# Install Passenger + Apache module
RUN apt-get update && apt-get install -y libapache2-mod-passenger

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

# # Check installation
# RUN /usr/bin/passenger-config validate-install
# RUN /usr/sbin/passenger-memory-stats
# Check installation
RUN /usr/bin/passenger-config validate-install
RUN /usr/sbin/passenger-memory-stats

# Enable required apache modules for the cgimap Apache service
RUN a2enmod proxy proxy_http rewrite
RUN a2enmod proxy proxy_http rewrite lbmethod_byrequests proxy_fcgi

# Config the virtual host apache2
ADD config/cgimap.conf /tmp/
RUN sed -e 's/RewriteRule ^(.*)/#RewriteRule ^(.*)/' \
-e 's/\/var\/www/\/var\/www\/public/g' \
/tmp/cgimap.conf > /etc/apache2/sites-available/cgimap.conf
RUN chmod 644 /etc/apache2/sites-available/cgimap.conf
RUN a2ensite cgimap
RUN apache2ctl configtest

# Set Permissions for www-data
RUN chown -R www-data: $workdir

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

COPY start.sh $workdir/
COPY liveness.sh $workdir/

CMD $workdir/start.sh


73 changes: 52 additions & 21 deletions images/web/config/settings.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# The server protocol and host
server_protocol: "http"
server_url: "openstreetmap.example.com"
Expand Down Expand Up @@ -28,30 +27,52 @@ status: "online"
max_request_area: 0.25
# Number of GPS trace/trackpoints returned per-page
tracepoints_per_page: 5000
# Default limit on the number of changesets returned by the changeset query api method
default_changeset_query_limit: 100
# Maximum limit on the number of changesets returned by the changeset query api method
max_changeset_query_limit: 100
# Maximum number of nodes that will be returned by the api in a map request
max_number_of_nodes: 50000
# Maximum number of nodes that can be in a way (checked on save)
max_number_of_way_nodes: 2000
# Maximum number of members that can be in a relation (checked on save)
max_number_of_relation_members: 32000
# The maximum area you're allowed to request notes from, in square degrees
max_note_request_area: 25
# Default limit on the number of notes returned by the note search api method
default_note_query_limit: 100
# Maximum limit on the number of notes returned by the note search api method
max_note_query_limit: 10000
# Maximum value of open issues counter for moderators, anything equal or greater to this value "n" is shown as "n+"
max_issues_count: 99
# Zoom level to use for postcode results from the geocoder
postcode_zoom: 15
# Zoom level to use for geonames results from the geocoder
geonames_zoom: 12
# Timeout for API calls in seconds
api_timeout: 300
# Timeout for web pages in seconds
web_timeout: 30
# Periods (in hours) which are allowed for user blocks
user_block_periods: [0, 1, 3, 6, 12, 24, 48, 96, 168, 336, 731, 4383, 8766, 87660]
# 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
user_account_deletion_delay: null
# Rate limit for message sending
max_messages_per_hour: 60
# Rate limit for friending
max_friends_per_hour: 60
# Rate limit for changeset comments
min_changeset_comments_per_hour: 1
initial_changeset_comments_per_hour: 6
max_changeset_comments_per_hour: 60
moderator_changeset_comments_per_hour: 36000
# Rate limit for changes
min_changes_per_hour: 100
initial_changes_per_hour: 1000
max_changes_per_hour: 100000
days_to_max_changes: 7
importer_changes_per_hour: 1000000
moderator_changes_per_hour: 1000000
# Domain for handling message replies
#messages_domain: "messages.openstreetmap.org"
# Geonames authentication details
#geonames_username: ""
# MaxMind GeoIPv2 database
#maxmind_database: ""
# Users to show as being nearby
Expand All @@ -64,9 +85,6 @@ spam_threshold: 50
diary_feed_delay: 0
# Default legale (jurisdiction location) for contributor terms
default_legale: GB
# Location of GPX traces and images
gpx_trace_dir: "/home/osm/traces"
gpx_image_dir: "/home/osm/images"
# Location of data for attachments
attachments_dir: ":rails_root/public/attachments"
# Log file to use
Expand All @@ -75,44 +93,44 @@ attachments_dir: ":rails_root/public/attachments"
#logstash_path: ""
# List of memcache servers to use for caching
#memcache_servers: []
# Enable HTTP basic authentication support
basic_auth_support: true
# Enable legacy OAuth 1.0 support
oauth_10_support: true
oauth_10_registration: true
# URL of Nominatim instance to use for geocoding
nominatim_url: "https://nominatim.openstreetmap.org/"
# Default editor
default_editor: "id"
# OAuth application for the web site
#oauth_application: ""
# OAuth consumer key for iD
#id_key: ""
# OAuth application for iD
#id_application: ""
# Imagery to return in capabilities as blacklisted
imagery_blacklist:
# Current Google imagery URLs have google or googleapis in the domain
# with a vt or kh endpoint, and x, y and z query parameters
- ".*\\.google(apis)?\\..*/(vt|kh)[\\?/].*([xyz]=.*){3}.*"
# Blacklist VWorld
- "http://xdworld\\.vworld\\.kr:8080/.*"
# Blacklist here
- ".*\\.here\\.com[/:].*"
imagery_blacklist: []
# URL of Overpass instance to use for feature queries
overpass_url: "https://overpass-api.de/api/interpreter"
overpass_credentials: false
# Routing endpoints
graphhopper_url: "https://graphhopper.com/api/1/route"
fossgis_osrm_url: "https://routing.openstreetmap.de/"
fossgis_valhalla_url: "https://valhalla1.openstreetmap.de/route"
# External authentication credentials
#google_auth_id: ""
#google_auth_secret: ""
#google_openid_realm: ""
#facebook_auth_id: ""
#facebook_auth_secret: ""
#windowslive_auth_id: ""
#windowslive_auth_secret: ""
#github_auth_id: ""
#github_auth_secret: ""
#microsoft_auth_id: ""
#microsoft_auth_secret: ""
#wikipedia_auth_id: ""
#wikipedia_auth_secret: ""
# Thunderforest authentication details
#thunderforest_key: ""
# Tracestrack authentication details
#tracestrack_key: ""
# Key for generating TOTP tokens
#totp_key: ""
# Enforce Content-Security-Policy
Expand All @@ -134,7 +152,20 @@ trace_icon_storage: "local"
smtp_address: "localhost"
smtp_port: 25
smtp_domain: "localhost"
smtp_enable_starttls_auto: false
smtp_enable_starttls_auto: true
smtp_tls_verify_mode: "none"
smtp_authentication: null
smtp_user_name: null
smtp_password: null
# Matomo settings for analytics
#matomo:
# Signup rate limits
#signup_ip_per_day:
#signup_ip_max_burst:
#signup_email_per_day:
#signup_email_max_burst:
# Private key for signing id_tokens
#doorkeeper_signing_key: |
# -----BEGIN PRIVATE KEY-----
# ...
# -----END PRIVATE KEY-----

0 comments on commit a6e7fb7

Please sign in to comment.