From 7ff254535f9fa6cbc8d75441c98c8ff6fca70903 Mon Sep 17 00:00:00 2001 From: Candid Dauth Date: Fri, 12 Apr 2024 11:30:34 +0200 Subject: [PATCH] Fix example docker-compose file (#264) --- docs/src/developers/server/docker.md | 146 +++++++++++++-------------- 1 file changed, 68 insertions(+), 78 deletions(-) diff --git a/docs/src/developers/server/docker.md b/docs/src/developers/server/docker.md index 18074a99..f2562464 100644 --- a/docs/src/developers/server/docker.md +++ b/docs/src/developers/server/docker.md @@ -10,45 +10,44 @@ FacilMap needs a database supported by [Sequelize](https://sequelize.org/master/ ## docker-compose -To run FacilMap with MySQL using [docker-compose](https://docs.docker.com/compose/), here is an example `docker-compose.yml`: +To run FacilMap with MariaDB using [docker-compose](https://docs.docker.com/compose/), here is an example `docker-compose.yml`: ```yaml -version: "2" services: - facilmap: - image: facilmap/facilmap - ports: - - 8080:8080 - links: - - mysql - depends_on: - mysql: - condition: service_healthy - environment: - USER_AGENT: My FacilMap (https://facilmap.example.org/, facilmap@example.org) - TRUST_PROXY: "true" - DB_TYPE: mysql - DB_HOST: db - DB_NAME: facilmap - DB_USER: facilmap - DB_PASSWORD: password - ORS_TOKEN: # Get an API key on https://go.openrouteservice.org/ (needed for routing) - MAPBOX_TOKEN: # Get an API key on https://www.mapbox.com/signup/ (needed for routing) - MAXMIND_USER_ID: # Sign up here https://www.maxmind.com/en/geolite2/signup (needed for geoip lookup to show initial map state) - MAXMIND_LICENSE_KEY: - LIMA_LABS_TOKEN: # Get an API key on https://maps.lima-labs.com/ (optional, needed for double-resolution tiles) - restart: unless-stopped - mysql: - image: mariadb - environment: - MYSQL_DATABASE: facilmap - MYSQL_USER: facilmap - MYSQL_PASSWORD: password - MYSQL_RANDOM_ROOT_PASSWORD: "true" - command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci - healthcheck: - test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD - restart: unless-stopped + facilmap: + image: facilmap/facilmap + ports: + - 8080:8080 + links: + - mariadb + depends_on: + mariadb: + condition: service_healthy + environment: + USER_AGENT: My FacilMap (https://facilmap.example.org/, facilmap@example.org) + TRUST_PROXY: "true" + DB_TYPE: mysql + DB_HOST: mariadb + DB_NAME: facilmap + DB_USER: facilmap + DB_PASSWORD: password + ORS_TOKEN: # Get an API key on https://go.openrouteservice.org/ (needed for routing) + MAPBOX_TOKEN: # Get an API key on https://www.mapbox.com/signup/ (needed for routing) + MAXMIND_USER_ID: # Sign up here https://www.maxmind.com/en/geolite2/signup (needed for geoip lookup to show initial map state) + MAXMIND_LICENSE_KEY: + LIMA_LABS_TOKEN: # Get an API key on https://maps.lima-labs.com/ (optional, needed for double-resolution tiles) + restart: unless-stopped + mariadb: + image: mariadb + environment: + MYSQL_DATABASE: facilmap + MYSQL_USER: facilmap + MYSQL_PASSWORD: password + MYSQL_RANDOM_ROOT_PASSWORD: "true" + command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci + healthcheck: + test: healthcheck.sh --su-mysql --connect --innodb_initialized + restart: unless-stopped ``` Here is an example with Postgres: @@ -56,49 +55,40 @@ Here is an example with Postgres: ```yaml version: "2" services: - facilmap: - image: facilmap/facilmap - ports: - - 8080:8080 - links: - - postgres - depends_on: - postgres: - condition: service_healthy - environment: - USER_AGENT: My FacilMap (https://facilmap.example.org/, facilmap@example.org) - TRUST_PROXY: "true" - DB_TYPE: postgres - DB_HOST: db - DB_NAME: facilmap - DB_USER: facilmap - DB_PASSWORD: password - ORS_TOKEN: # Get an API key on https://go.openrouteservice.org/ (needed for routing) - MAPBOX_TOKEN: # Get an API key on https://www.mapbox.com/signup/ (needed for routing) - MAXMIND_USER_ID: # Sign up here https://www.maxmind.com/en/geolite2/signup (needed for geoip lookup to show initial map state) - MAXMIND_LICENSE_KEY: - LIMA_LABS_TOKEN: # Get an API key on https://maps.lima-labs.com/ (optional, needed for double-resolution tiles) - restart: unless-stopped - postgres: - image: postgis/postgis - environment: - POSTGRES_USER: facilmap - POSTGRES_PASSWORD: password - POSTGRES_DB: facilmap - healthcheck: - test: pg_isready -d $$POSTGRES_DB - restart: unless-stopped + facilmap: + image: facilmap/facilmap + ports: + - 8080:8080 + links: + - postgres + depends_on: + postgres: + condition: service_healthy + environment: + USER_AGENT: My FacilMap (https://facilmap.example.org/, facilmap@example.org) + TRUST_PROXY: "true" + DB_TYPE: postgres + DB_HOST: db + DB_NAME: facilmap + DB_USER: facilmap + DB_PASSWORD: password + ORS_TOKEN: # Get an API key on https://go.openrouteservice.org/ (needed for routing) + MAPBOX_TOKEN: # Get an API key on https://www.mapbox.com/signup/ (needed for routing) + MAXMIND_USER_ID: # Sign up here https://www.maxmind.com/en/geolite2/signup (needed for geoip lookup to show initial map state) + MAXMIND_LICENSE_KEY: + LIMA_LABS_TOKEN: # Get an API key on https://maps.lima-labs.com/ (optional, needed for double-resolution tiles) + restart: unless-stopped + postgres: + image: postgis/postgis + environment: + POSTGRES_USER: facilmap + POSTGRES_PASSWORD: password + POSTGRES_DB: facilmap + healthcheck: + test: pg_isready -d $$POSTGRES_DB + restart: unless-stopped ``` To start FacilMap, run `docker-compose up -d` in the directory of the `docker-compose.yml` file. To upgrade FacilMap, run `docker-compose pull` and then restart it by running `docker-compose up -d`. -Note that this exposes FacilMap through unencrypted HTTP on port 8080. In a production setup, FacilMap should be served by a reverse proxy that provides HTTPS. Usually, the `ports` directive can be removed then. - -## docker create - -To manually create the necessary docker containers, use these commands: - -```bash -docker create --name=facilmap_db -e MYSQL_DATABASE=facilmap -e MYSQL_USER=facilmap -e MYSQL_PASSWORD=password -e MYSQL_RANDOM_ROOT_PASSWORD=true --restart=unless-stopped mariadb --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci -docker create --link=facilmap_db -p 8080:8080 --name=facilmap -e "USER_AGENT=My FacilMap (https://facilmap.example.org/, facilmap@example.org)" -e TRUST_PROXY=true -e DB_TYPE=mysql -e DB_HOST=facilmap_db -e DB_NAME=facilmap -e DB_USER=facilmap -e DB_PASSWORD=facilmap -e ORS_TOKEN= -e MAPBOX_TOKEN= -e MAXMIND_USER_ID= -e MAXMIND_LICENSE_KEY= -e LIMA_LABS_TOKEN= --restart=unless-stopped facilmap/facilmap -``` \ No newline at end of file +Note that this exposes FacilMap through unencrypted HTTP on port 8080. In a production setup, FacilMap should be served by a reverse proxy that provides HTTPS. Usually, the `ports` directive can be removed then. \ No newline at end of file