Skip to content

Commit 5526a79

Browse files
committed
Major refactoring of docker containers/frontend
Previously, a javascript file would manually replace environment variables in another file, by opening it as a text file. This commit now introduces a config.json file, where the user can configure the backends, layers, overlays, and other options. The docker now uses Alpine 3.21, and does not install unnecessary dependencies. The user can now pass a custom config.json file to the docker file. Instructions have been written in the documentation. npm packages have also been updated.
1 parent 6a75184 commit 5526a79

File tree

11 files changed

+3382
-2774
lines changed

11 files changed

+3382
-2774
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ Serves the frontend at `http://localhost:9966` running queries against the routi
1616
docker run -p 9966:9966 osrm/osrm-frontend
1717
```
1818

19-
Per default routing requests are made against the backend at `http://localhost:5000`.
20-
You can change the backend by using `-e OSRM_BACKEND='http://localhost:5001'` in the `docker run` command.
19+
By default, the docker container uses the settings in `config/config.json` file. If you'd like to provide a custom config file (with your own backend server, layers and overlays), you can run the container with the following command:
20+
21+
```
22+
docker run -p 9966:9966 -v ./YOUR_CONFIG.json:/src/config/config.json osrm-frontend
23+
```
2124

2225
In case Docker complains about not being able to connect to the Docker daemon make sure you are in the `docker` group.
2326

@@ -56,15 +59,20 @@ npm run start-index
5659

5760
## Changing Backends
5861

59-
In `src/leaflet_options.js` adjust:
62+
In `config/config.json` add or adjust your own services:
6063

6164
```
6265
services: [{
63-
label: 'Car (fastest)',
66+
label: 'Car',
6467
path: 'http://localhost:5000/route/v1'
6568
}],
6669
```
6770

71+
You can also adjust your own layers and overlays.
72+
73+
## Debug
74+
> Note: "debug" pages currently do not work "out of the box" and require manual configuration
75+
6876
For debug tiles showing speeds and small components available at `/debug` adjust in `debug/index.html`
6977

7078
```

bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle.raw.js

Lines changed: 668 additions & 232 deletions
Large diffs are not rendered by default.

config/config.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"zoom": 13,
3+
"center": [
4+
50.8503,
5+
4.3517
6+
],
7+
"language": "en",
8+
"layers": [
9+
{
10+
"name": "openstreetmap.org",
11+
"url": "//tile.openstreetmap.org/{z}/{x}/{y}.png",
12+
"attribution": "© <a href=\"https://www.openstreetmap.org/copyright/en\">OpenStreetMap</a> contributors"
13+
},
14+
{
15+
"name": "openstreetmap.de",
16+
"url": "//tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png",
17+
"attribution": "<a target=\"_blank\" href=\"http://www.openstreetmap.org/\">Karte hergestellt aus OpenStreetMap-Daten</a> | Lizenz: <a rel=\"license\" target=\"_blank\" href=\"http://opendatacommons.org/licenses/odbl/\">Open Database License (ODbL)</a>"
18+
}
19+
],
20+
"overlays":[
21+
{
22+
"name": "Hiking",
23+
"url": "//tile.waymarkedtrails.org/hiking/{z}/{x}/{y}.png",
24+
"attribution": "© <a href=\"http://waymarkedtrails.org\">Sarah Hoffmann</a> (<a href=\"https://creativecommons.org/licenses/by-sa/3.0/\">CC-BY-SA</a>)"
25+
},
26+
{
27+
"name": "Bike",
28+
"url": "//tile.waymarkedtrails.org/cycling/{z}/{x}/{y}.png",
29+
"attribution": "© <a href=\"http://waymarkedtrails.org\">Sarah Hoffmann</a> (<a href=\"https://creativecommons.org/licenses/by-sa/3.0/\">CC-BY-SA</a>)"
30+
},
31+
{
32+
"name": "Small Components",
33+
"url": "https://tools.geofabrik.de/osmi/tiles/routing/{z}/{x}/{y}.png"
34+
}
35+
36+
],
37+
"services": [
38+
{
39+
"label": "Car",
40+
"path": "https://routing.openstreetmap.de/routed-car/route/v1",
41+
"debug": "car"
42+
},
43+
{
44+
"label": "Bike",
45+
"path": "https://routing.openstreetmap.de/routed-bike/route/v1",
46+
"debug": "bike"
47+
},
48+
{
49+
"label": "Foot",
50+
"path": "https://routing.openstreetmap.de/routed-foot/route/v1",
51+
"debug": "foot"
52+
}
53+
]
54+
}

docker/Dockerfile

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
FROM alpine:3.5
2-
3-
# Enables customized options using environment variables
4-
ENV OSRM_BACKEND='http://localhost:5000'
5-
ENV OSRM_CENTER='38.8995,-77.0269'
6-
ENV OSRM_ZOOM='13'
7-
ENV OSRM_LANGUAGE='en'
8-
ENV OSRM_LABEL='Car (fastest)'
9-
ENV OSRM_MAPBOX_TOKEN='pk.eyJ1IjoibXNsZWUiLCJhIjoiclpiTWV5SSJ9.P_h8r37vD8jpIH1A6i1VRg'
1+
FROM alpine:3.21
102

113
# Copy package.json
124
RUN mkdir -p /src
135
COPY package.json /src
146

157
# Install app dependencies
16-
RUN apk add --no-cache sed nodejs && \
8+
RUN apk add --no-cache npm && \
179
cd /src && \
1810
npm install
1911

@@ -23,4 +15,4 @@ WORKDIR /src
2315

2416
# Run App
2517
EXPOSE 9966
26-
CMD ["npm", "start"]
18+
CMD ["npm", "start"]

0 commit comments

Comments
 (0)