Skip to content

Commit

Permalink
Merge pull request #457 from OpenHistoricalMap/refactor/web_docker
Browse files Browse the repository at this point in the history
Refactoring web-api docker compose for development mode
  • Loading branch information
Rub21 authored Jan 28, 2025
2 parents 2dedb69 + 4969ff0 commit 4035364
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 163 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/chartpress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- 'main'
- 'staging'
- 'development'
- 'fix/tiler_server'
- 'refactor/web_docker'
jobs:
build:
runs-on: ubuntu-20.04
Expand Down
2 changes: 2 additions & 0 deletions chartpress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ charts:
valuesPath: osm-seed.tmApi.image
tiler-cache:
valuesPath: ohm.tilerCache.image
cgimap:
valuesPath: ohm.cgimap.image
10 changes: 8 additions & 2 deletions compose/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
## Development Mode

Compose files are for development mode, e.g.:
- Web Api

- Tiler DB
```sh
docker compose -f compose/web.yml up memcached
docker compose -f compose/web.yml build
docker compose -f compose/web.yml run --service-ports web bash
```

- Tiler server

```sh
docker compose -f compose/tiler.yml run --service-ports tiler bash
Expand Down
39 changes: 31 additions & 8 deletions compose/web.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.8'
services:
db:
platform: linux/amd64
Expand All @@ -8,19 +7,43 @@ services:
dockerfile: Dockerfile
ports:
- '5432:5432'
volumes:
- ./data/db-data:/var/lib/postgresql/data
env_file:
- ./../envs/.env.web
restart: always
networks:
- web_network

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

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

networks:
web_network:
driver: bridge

volumes:
caddy_data:
caddy_config:
48 changes: 48 additions & 0 deletions images/cgimap/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM ruby:3.3.0
ENV DEBIAN_FRONTEND=noninteractive
ENV workdir=/var/www

# Production OSM setup
ENV RAILS_ENV=production

# Install the openstreetmap-website dependencies
RUN apt-get update \
&& apt-get install -y \
libmagickwand-dev libxml2-dev libxslt1-dev \
apache2 apache2-dev build-essential git-core postgresql-client \
libpq-dev libsasl2-dev imagemagick libffi-dev libgd-dev libarchive-dev libbz2-dev curl \
default-jre-headless file gpg-agent libvips-dev locales software-properties-common tzdata unzip \
advancecomp gifsicle libjpeg-progs jhead jpegoptim optipng pngcrush pngquant \
&& 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 libxml2-dev libpqxx-dev libfcgi-dev zlib1g-dev libbrotli-dev \
libboost-program-options-dev libfmt-dev libmemcached-dev libcrypto++-dev \
libargon2-dev libyajl-dev cmake libapache2-mod-fcgid && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install cgimap v2.0.1
ENV cgimap=/tmp/openstreetmap-cgimap
ENV CGIMAP_GITSHA=8ea707e10aeab5698e6859856111816d75354592
RUN git clone -b master https://github.com/zerebubuth/openstreetmap-cgimap.git $cgimap \
&& cd $cgimap \
&& git checkout $CGIMAP_GITSHA \
&& rm -rf .git \
&& mkdir build \
&& cd build \
&& cmake .. \
&& cmake --build .

RUN cp $cgimap/build/openstreetmap-cgimap /usr/local/bin/ && rm -rf $cgimap

RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local_libs.conf && ldconfig
49 changes: 1 addition & 48 deletions images/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,4 @@
FROM ruby:3.3.0
ENV DEBIAN_FRONTEND=noninteractive
ENV workdir=/var/www

# Production OSM setup
ENV RAILS_ENV=production

# Install the openstreetmap-website dependencies
RUN apt-get update \
&& apt-get install -y \
libmagickwand-dev libxml2-dev libxslt1-dev \
apache2 apache2-dev build-essential git-core postgresql-client \
libpq-dev libsasl2-dev imagemagick libffi-dev libgd-dev libarchive-dev libbz2-dev curl \
default-jre-headless file gpg-agent libvips-dev locales software-properties-common tzdata unzip \
advancecomp gifsicle libjpeg-progs jhead jpegoptim optipng pngcrush pngquant \
&& 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 libxml2-dev libpqxx-dev libfcgi-dev zlib1g-dev libbrotli-dev \
libboost-program-options-dev libfmt-dev libmemcached-dev libcrypto++-dev \
libargon2-dev libyajl-dev cmake libapache2-mod-fcgid && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install cgimap v2.0.1
ENV cgimap=/tmp/openstreetmap-cgimap
ENV CGIMAP_GITSHA=8ea707e10aeab5698e6859856111816d75354592
RUN git clone -b master https://github.com/zerebubuth/openstreetmap-cgimap.git $cgimap \
&& cd $cgimap \
&& git checkout $CGIMAP_GITSHA \
&& rm -rf .git \
&& mkdir build \
&& cd build \
&& cmake .. \
&& cmake --build .

RUN cp $cgimap/build/openstreetmap-cgimap /usr/local/bin/ && rm -rf $cgimap

RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local_libs.conf && ldconfig
FROM ghcr.io/openhistoricalmap/cgimap:0.0.1-0.dev.git.2087.h94d548c

# Install Passenger
RUN gem install passenger && passenger-install-apache2-module --auto
Expand Down
15 changes: 3 additions & 12 deletions images/web/config/production.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

<Location />
Require all granted
# Use "Deny from" instead of "Require not ip" to ensure compatibility
<RequireAll>
Require all granted
Require not ip 10.10.34.172
</RequireAll>
# For TM, do not use cgimap auth.
<If "%{HTTP_REFERER} !~ m#https://tasks(-\w+)?\.openhistoricalmap\.org/#">
CGIPassAuth On
Expand All @@ -50,12 +44,9 @@

# Relax Apache security settings
<Directory /var/www/public>
AllowOverride None
Options -MultiViews
<RequireAll>
Require all granted
Require not ip 10.10.34.172
</RequireAll>
AllowOverride None
Allow from all
Options -MultiViews
</Directory>

# Additional FastCGI configurations
Expand Down
Loading

0 comments on commit 4035364

Please sign in to comment.