feat: add containerfile and build config
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.
- Stage 1: PostGIS Setup
- 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.
- Ensure
/etc/hostscontains new hostfile entries for.testdomain 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 - Build the container image:
podman build -t openrailwaymap:latest . - Run the container image:
docker run -d -p 8080:80 -p 5432:5432 --name openrailwaymap openrailwaymap:latest - Access the container's shell (if needed for debugging):
docker exec -it openrailwaymap /bin/bash - 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).
Tested on Asahi Linux 6.8.9-404.asahi.fc39.aarch64+16k using Podman 4.9.4 on 25 May 2024.
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.
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.