Merge pull request #272 from saesh/master

Dockerfile for building and running brouter-web
This commit is contained in:
Norbert Renner 2020-01-30 12:24:53 +01:00 committed by GitHub
commit f1f57ec3ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 2 deletions

11
Dockerfile Normal file
View file

@ -0,0 +1,11 @@
FROM node:8-alpine as build
RUN mkdir /tmp/brouter-web
WORKDIR /tmp/brouter-web
COPY . .
RUN yarn install
RUN yarn run build
FROM nginx:alpine
COPY --from=build /tmp/brouter-web/index.html /usr/share/nginx/html
COPY --from=build /tmp/brouter-web/dist /usr/share/nginx/html/dist
VOLUME [ "/usr/share/nginx/html" ]

View file

@ -44,7 +44,7 @@ As an alternative to the above online version, the standalone server of BRouter
2. download one or more [data file(s)](https://brouter.de/brouter/segments4/) (rd5) into `segments4` directory
### Configure BRouter-Web
#### Configure BRouter-Web
In the `brouter-web` subdirectory:
@ -52,10 +52,57 @@ In the `brouter-web` subdirectory:
2. add your API keys (optional)
copy `keys.template.js` to `keys.js` and edit to add your keys
### Run
#### Run
1. start `./run.sh`
### Running as Docker container (client only)
brouter-web can be run as a Docker container, making it easy for continous deployment or running locally
without having to install any build tools.
The `Dockerfile` builds the application inside a NodeJS container and copies the built application into a
separate Nginx based image. The application runs from a webserver only container serving only static files.
#### Prerequisites
- Docker installed
- working directory is this repository
- `config.template.js` copied to `config.js` and modified with a Brouter server, see `BR.conf.host`
- `keys.template.js` to `keys.js` and add your API keys
- Optionally create `profiles` directory with `brf` profile files and add path to `config.js`:
BR.conf.profilesUrl = 'profiles/';
#### Building Docker image
To build the Docker container run:
docker build -t brouter-web .
This creates a Docker image with the name `brouter-web`.
#### Running Docker container
To run the previously build Docker image run:
docker run --rm --name brouter-web \
-p 127.0.0.1:8080:80 \
-v "`pwd`/config.js:/usr/share/nginx/html/config.js" \
-v "`pwd`/keys.js:/usr/share/nginx/html/keys.js" \
-v "`pwd`/profiles:/usr/share/nginx/html/profiles" \
brouter-web
This command does the following:
1. Runs a container with the name `brouter-web` and removes it automatically after stopping
1. Binds port 80 of the container to the host interface 127.0.0.1 on port 8080
1. Takes the absolute paths of `config.js`, `keys.js` and `profiles` and mounts them inside the container
1. Uses the image `brouter-web` to run as a container
brouter-web should be accessible at http://127.0.0.1:8080.
## Build
### Dependencies