Skip to content
Merged
25 changes: 22 additions & 3 deletions compose/web.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
services:
db:
container_name: db
platform: linux/amd64
image: ohm-db:v2
build:
Expand All @@ -14,31 +15,49 @@ services:
- web_network

web:
container_name: web
image: ohm-web:v1
build:
context: ./../images/web
dockerfile: Dockerfile
volumes:
- ./../../ohm-website/:/var/www/
- ./../images/web/config/settings.yml:/tmp/settings.yml:rw
- ./../images/web/start.sh:/var/www/start.sh
env_file:
- ./../envs/.env.web
ports:
- '3000:3000'
- '3000:80'
networks:
- web_network
depends_on:
- db
- memcached

memcached:
container_name: memcached
image: memcached:latest
ports:
- '11211:11211'
networks:
- web_network

# cgimap:
# container_name: cgimap
# image: ohm-cgimap:v1
# build:
# context: ./../images/cgimap
# dockerfile: Dockerfile
# env_file:
# - ./../envs/.env.web
# environment:
# MEMCACHE_SERVER: memcached:11211
# # ports:
# # - '8000:8000'
# networks:
# - web_network
# depends_on:
# - db
# - memcached

networks:
web_network:
driver: bridge
14 changes: 11 additions & 3 deletions images/db/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Stage 1: Compilar el plugin para PostgreSQL 17
FROM postgres:17 AS builder

# Instalar dependencias de compilación
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
build-essential \
Expand All @@ -18,7 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& update-ca-certificates \
&& rm -rf /var/lib/apt/lists/*

# Clonar y compilar el plugin osmdbt para PostgreSQL 17
# Clone and build osmdbt plugin for PostgreSQL 17
RUN git clone https://github.com/openstreetmap/osmdbt.git /tmp/osmdbt && \
cd /tmp/osmdbt && \
git checkout v0.9 && \
Expand All @@ -29,6 +28,15 @@ RUN git clone https://github.com/openstreetmap/osmdbt.git /tmp/osmdbt && \

FROM postgres:17

RUN apt-get update && apt-get install -y --no-install-recommends \
postgresql-17-postgis-3 \
postgresql-17-postgis-3-scripts \
&& rm -rf /var/lib/apt/lists/*

# Auto-create required extensions on fresh initdb
COPY ./scripts/init-extensions.sh /docker-entrypoint-initdb.d/10-extensions.sh
RUN chmod +x /docker-entrypoint-initdb.d/10-extensions.sh

COPY --from=builder /tmp/osmdbt/postgresql-plugin/build/osm-logical.so /usr/lib/postgresql/17/lib/osm-logical.so

RUN ln -s /usr/lib/postgresql/17/lib/osm-logical.so /usr/lib/postgresql/17/lib/osm_logical.so
Expand Down
8 changes: 8 additions & 0 deletions images/db/scripts/init-extensions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -e

psql --username="$POSTGRES_USER" --dbname="$POSTGRES_DB" -v ON_ERROR_STOP=1 <<-'EOSQL'
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS btree_gist;
EOSQL
17 changes: 11 additions & 6 deletions images/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.3-slim AS builder
FROM ruby:3.4-slim AS builder

ENV DEBIAN_FRONTEND=noninteractive \
workdir=/var/www \
Expand All @@ -14,7 +14,7 @@ WORKDIR $workdir
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git curl gnupg build-essential \
libarchive-dev zlib1g-dev libcurl4-openssl-dev \
libarchive-dev zlib1g-dev libcurl4-openssl-dev libgd-dev \
apache2 apache2-dev libapache2-mod-fcgid libapr1-dev libaprutil1-dev \
postgresql-client libpq-dev libxml2-dev libyaml-dev \
pngcrush optipng advancecomp pngquant jhead jpegoptim gifsicle libjpeg-progs unzip\
Expand All @@ -24,14 +24,14 @@ RUN apt-get update && \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Download OHM Website using gitsha, faster than cloning
ENV OPENHISTORICALMAP_WEBSITE_GITSHA=8690db86e4e5b51c4d59c1e2ec273bb2f8471189
ENV OPENHISTORICALMAP_WEBSITE_GITSHA=ecd8301fd333946b50137fb702bb5c1cbd1c3970
ENV OHM_WEBSITE_URL=https://github.com/OpenHistoricalMap/ohm-website/archive/${OPENHISTORICALMAP_WEBSITE_GITSHA}.zip
RUN rm -rf $workdir/* && curl -fsSL $OHM_WEBSITE_URL -o /tmp/ohm-website.zip && \
unzip /tmp/ohm-website.zip -d /tmp && \
mv /tmp/ohm-website-$OPENHISTORICALMAP_WEBSITE_GITSHA/* $workdir && \
rm -rf /tmp/*

RUN gem install bundler && \
RUN gem install bundler -v 4.0.11 --no-document && \
bundle install && \
yarn install && \
bundle exec rake yarn:install
Expand Down Expand Up @@ -77,7 +77,7 @@ RUN git clone https://github.com/OpenHistoricalMap/leaflet-ohm-timeslider-v2.git
cp leaflet-ohm-timeslider.* $workdir/app/assets/stylesheets/ && \
cp assets/* $workdir/app/assets/images/

FROM ruby:3.3-slim
FROM ruby:3.4-slim

ENV DEBIAN_FRONTEND=noninteractive \
workdir=/var/www \
Expand Down Expand Up @@ -116,14 +116,15 @@ RUN BUILD_DEPS=" \
gifsicle \
postgresql-client \
curl \
git \
libvips \
nodejs \
\
&& npm install -g svgo \
\
# Install Passenger as a gem and compile the Apache module
\
&& gem install passenger --no-document \
&& gem install passenger -v 6.1.3 --no-document \
&& yes | passenger-install-apache2-module --auto --languages ruby \
&& passenger-config validate-install --auto \
\
Expand Down Expand Up @@ -152,6 +153,10 @@ RUN a2enmod headers setenvif proxy proxy_http proxy_fcgi fcgid rewrite lbmethod_
echo "ServerName localhost" >> /etc/apache2/apache2.conf && \
apache2ctl configtest

# Install bundler matching ohm-website Gemfile.lock to avoid Passenger preloader Gem::LoadError.
RUN gem install bundler -v 4.0.11 --no-document


RUN echo '#!/bin/bash\nexec /usr/local/bin/ruby --yjit --yjit-exec-mem-size=64 "$@"' > /usr/local/bin/ruby_yjit && \
chmod +x /usr/local/bin/ruby_yjit

Expand Down
3 changes: 3 additions & 0 deletions images/web/config/production.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
DocumentRoot /var/www/public
PassengerAppEnv production
PassengerRuby /usr/local/bin/ruby
# Load Bundler before Ruby preloads default gems so Gemfile.lock pins
# (e.g. stringio 3.2.0) win over Ruby-bundled defaults like 3.1.2.
PassengerPreloadBundler on
RewriteEngine On

# Redirect to HTTPS
Expand Down
2 changes: 1 addition & 1 deletion values.staging.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ osm-seed:
accessMode: ReadWriteOnce
mountPath: /var/lib/postgresql/data
subPath: postgresql-db
AWS_ElasticBlockStore_volumeID : vol-05ffbd749907e949f
AWS_ElasticBlockStore_volumeID : vol-001f9c55b42984b18
AWS_ElasticBlockStore_size: 200Gi
resources:
enabled: false
Expand Down
Loading