OpenRailwayMap icon indicating copy to clipboard operation
OpenRailwayMap copied to clipboard

feat: add containerfile and build config

Open vhscom opened this issue 1 year ago • 2 comments

Summary

This pull request adds a Dockerfile for building and running the OpenRailwayMap project. The Dockerfile includes three stages: setting up PostGIS, building dependencies, and configuring Apache to serve the application. This setup will facilitate a streamlined and consistent development environment.

Changes

  • Added a multi-stage Dockerfile:
    • Stage 1: PostGIS Setup
      • Installs PostgreSQL and PostGIS dependencies.
      • Configures PostgreSQL with custom settings.
    • Stage 2: Build Stage
      • Installs necessary build dependencies.
      • Clones the OpenRailwayMap repository and installs Leaflet.
    • Stage 3: Final Stage
      • Installs required runtime packages.
      • Sets up and configures Apache with virtual hosts.
      • Copies the built files and PostgreSQL data from previous stages.
      • Exposes necessary ports and starts services.
  • Included Apache virtual host configuration files:
    • www.openrailwaymap.test.conf
    • api.openrailwaymap.test.conf
    • tiles.openrailwaymap.test.conf

Instructions for Running

This can be done using either Podman or Docker. Tested with Podman 4.9.4 during development.

  1. Ensure /etc/hosts contains new hostfile entries for .test domain like:
    127.0.0.1   openrailwaymap.test www.openrailwaymap.test
    ::1         openrailwaymap.test www.openrailwaymap.test
    127.0.0.1   a.tiles.openrailwaymap.test b.tiles.openrailwaymap.test c.tiles.openrailwaymap.test
    ::1         a.tiles.openrailwaymap.test b.tiles.openrailwaymap.test c.tiles.openrailwaymap.test
    
  2. Build the container image:
    podman build -t openrailwaymap:latest .
    
  3. Run the container image:
    docker run -d -p 8080:80 -p 5432:5432 --name openrailwaymap openrailwaymap:latest
    
  4. Access the container's shell (if needed for debugging):
    docker exec -it openrailwaymap /bin/bash
    
  5. View Apache logs (within the container):
    tail -f /var/log/apache2/error.log /var/log/apache2/access.log
    

Without any further configuration or set-up, the user should be able to access the running application on their local machine (and localhost:8080 will show a default apache site so we know it works).

Screenshot from 2024-05-25 19-00-18

Tested on Asahi Linux 6.8.9-404.asahi.fc39.aarch64+16k using Podman 4.9.4 on 25 May 2024.

vhscom avatar May 25 '24 23:05 vhscom

I merged #857 a minute ago. Could you please update your pull request. At least postgis_sfcgal and postgis_topology are not required any more.

Nakaner avatar Jun 01 '24 10:06 Nakaner

Updated postgres setup to accomodate postgis changes and reran locally with success:

podman run -d -p 8080:80 -p 5432:5432 --replace --name openrailwaymap openrailwaymap:latest

Branch updated with squashed changes.

vhscom avatar Jun 02 '24 19:06 vhscom