From 8e38cad31dfc313c3ff5a6c313da3add66737d1b Mon Sep 17 00:00:00 2001 From: Sascha Hagedorn Date: Mon, 12 Aug 2019 22:02:07 +0200 Subject: [PATCH 1/5] Add Dockerfile --- Dockerfile | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b01139b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM alpine as build +RUN apk add --no-cache curl unzip +RUN curl -L `curl -s https://api.github.com/repos/nrenner/brouter-web/releases/latest | grep browser_download_url | cut -d '"' -f 4` -o brouter-web.zip +RUN mkdir /tmp/brouter-web +RUN unzip -d /tmp/brouter-web brouter-web.zip + +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" ] \ No newline at end of file From 3d8e71271936b2f046312ccfcf64e30ebf62fd8a Mon Sep 17 00:00:00 2001 From: Sascha Hagedorn Date: Tue, 13 Aug 2019 22:02:18 +0200 Subject: [PATCH 2/5] Build Docker image from sources --- Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index b01139b..1a6986a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ -FROM alpine as build -RUN apk add --no-cache curl unzip -RUN curl -L `curl -s https://api.github.com/repos/nrenner/brouter-web/releases/latest | grep browser_download_url | cut -d '"' -f 4` -o brouter-web.zip +FROM node:8-alpine as build +RUN apk add --no-cache git RUN mkdir /tmp/brouter-web -RUN unzip -d /tmp/brouter-web brouter-web.zip +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 From ea895da29d73c12b7f9d437115663f5b1f196ab1 Mon Sep 17 00:00:00 2001 From: Sascha Hagedorn Date: Thu, 30 Jan 2020 11:34:55 +0100 Subject: [PATCH 3/5] Add description for running as Docker container --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0def705..685bd30 100644 --- a/README.md +++ b/README.md @@ -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:80: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 From a73108f291b51f92cd88bdc9187310cbd4ec93b3 Mon Sep 17 00:00:00 2001 From: Sascha Hagedorn Date: Thu, 30 Jan 2020 11:48:01 +0100 Subject: [PATCH 4/5] Remove unused dependency --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1a6986a..f218875 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ FROM node:8-alpine as build -RUN apk add --no-cache git RUN mkdir /tmp/brouter-web WORKDIR /tmp/brouter-web COPY . . @@ -9,4 +8,4 @@ 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" ] \ No newline at end of file +VOLUME [ "/usr/share/nginx/html" ] From c8d5e79d66adcab2e15322746d08694df436b4e1 Mon Sep 17 00:00:00 2001 From: Sascha Hagedorn Date: Thu, 30 Jan 2020 12:14:00 +0100 Subject: [PATCH 5/5] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 685bd30..4b5772a 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ This creates a Docker image with the name `brouter-web`. To run the previously build Docker image run: docker run --rm --name brouter-web \ - -p 127.0.0.1:80:80 \ + -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" \