![]() |
||
---|---|---|
.. | ||
cache | ||
database | ||
export | ||
routing | ||
.npmignore | ||
README.md | ||
elevation.js | ||
geoip.js | ||
listeners.js | ||
package-lock.json | ||
package.json | ||
search.js | ||
server.js | ||
socket.js | ||
utils.js | ||
webserver.js |
README.md
Running the FacilMap server
Using docker
FacilMap is available as facilmap/facilmap2
on Docker Hub. Here is
an example docker-compose.yml
:
version: "2"
services:
facilmap:
image: facilmap/facilmap2
ports:
- 8080
links:
- db
environment:
USER_AGENT: My FacilMap (https://facilmap.example.org/, facilmap@example.org)
DB_TYPE: mysql
DB_HOST: db
DB_NAME: facilmap
DB_USER: facilmap
DB_PASSWORD: password
OSR_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)
MAPZEN_TOKEN: # Get an API key on https://mapzen.com/developers/sign_up (needed for elevation info)
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:
restart: on-failure
db:
image: mariadb
environment:
MYSQL_DATABASE: facilmap
MYSQL_USER: facilmap
MYSQL_PASSWORD: password
MYSQL_RANDOM_ROOT_PASSWORD: "true"
Or the same using docker create
:
docker create --link=mysql_mysql_1 -p 8080 --name=facilmap -e "USER_AGENT=My FacilMap (https://facilmap.example.org/, facilmap@example.org)" -e DB_TYPE=mysql -e DB_HOST=mysql_mysql_1 -e DB_NAME=facilmap -e DB_USER=facilmap -e DB_PASSWORD=facilmap -e OSR_TOKEN= -e MAPBOX_TOKEN= -e MAPZEN_TOKEN= --restart on-failure facilmap/facilmap2
See below for the available config options.
Both the FacilMap server and the frontend will be available via HTTP on port 8080
. It is recommended to use a reverse
proxy, such as rankenstein/https-proxy-letsencrypt
,
to make it available over HTTPS.
Standalone
To run the FacilMap server by hand, follow the following steps:
- Make sure that you have a recent version of Node.js and a database (MariaDB, MySQL, PostgreSQL, SQLite, Microsoft SQL Server) set up. (Note that only MySQL has been tested so far.)
- Install the facilmap server (
npm install -g facilmap-server
). - If you want to use a database other than MySQL, you will have to install the driver using
npm install -g pg
(for PostgreSQL),npm install -g sqlite3
, ornpm install -g tedious
(for MSSQL). - Download config.js and adjust the settings (see below for an explanation of the different parameters)
- Run
facilmap-server config.js
Config
The config can be set either by using environment variables (useful for docker) or by editing config.js
.
config.js value |
Environment variable | Meaning |
---|---|---|
userAgent |
USER_AGENT |
Will be used for all HTTP requests (search, routing, GPX/KML/OSM/GeoJSON files). You better provide your e-mail address in here. |
host |
The ip address to listen on. | |
port |
The port to listen on. | |
db.type |
DB_TYPE |
The type of database. Either mysql , postgres , mariadb , sqlite , or mssql . |
db.host |
DB_HOST |
The host name of the database server (default: localhost ). |
db.port |
DB_PORT |
The port of the database server (optional). |
db.database |
DB_NAME |
The name of the database (default: facilmap ). |
db.user |
DB_USER |
The username to connect to the database with (default: facilmap ). |
db.password |
DB_PASSWORD |
The password to connect to the database with. |
orsToken |
ORS_TOKEN |
OpenRouteService API key. |
mapboxToken |
MAPBOX_TOKEN |
Mapbox API key. |
mapzenToken |
MAPZEN_TOKEN |
Mapzen API key. |
maxmindUserId |
MAXMIND_USER_ID |
MaxMind user ID. |
maxmindLicenseKey |
MAXMIND_LICENSE_KEY |
MaxMind license key. |
Development
To get the server running, run yarn run deps
to install the dependencies, and then yarn run server
to start the server.
For developing the frontend/client, FacilMap server can integrate a webpack-dev-server. This server will automatically
recompile the frontend files when a file changes, and even delay reloads until the compilation has finished. To run
the dev server, first link the dependencies by running yarn link
in the client/
and frontend/
directories, and then
yarn link facilmap-frontend facilmap-client
in the server/
directory. Then start the server in development mode
using FM_DEV=true npm run server
.
To enable debug output of various components, additionally prepend the command by DEBUG=*
. See the documentation of
debug. To only enable the debug logging of SQL queries, use DEBUG=sql
. To
enable the logging of outgoing HTTP requests, set DEBUG=request
.