From b7edccd6d3b74213214f141e4ff9b96c9c1d024c Mon Sep 17 00:00:00 2001 From: Carsten Milling Date: Sat, 2 May 2020 16:40:44 +0200 Subject: [PATCH] add Dockerfile --- .dockerignore | 2 ++ Dockerfile | 22 ++++++++++++++++++++++ README.md | 24 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d1b0a12 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.git* +node_modules diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2088a82 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM node:12 +LABEL maintainer="cmil@hashtable.de" + +ENV dbhost 0.0.0.0 +ENV dbport 1984 +ENV dbname histvv + +WORKDIR /usr/src/histvv +COPY . . +RUN npm install + +# add wait-for-it.sh so it can be used with docker-compose +RUN wget https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh \ + -O /usr/local/bin/wait-for-it.sh \ + && chmod +x /usr/local/bin/wait-for-it.sh + +EXPOSE 3000/tcp + +# override node:12 ENTRYPOINT +ENTRYPOINT [] + +CMD /usr/src/histvv/bin/www --db $dbname --dbhost $dbhost --dbport $dbport diff --git a/README.md b/README.md index 3d74dc3..ee444f1 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,30 @@ histvv-server --static ./histvv-data/public --xsl ./histvv-data/custom.xsl Now the server can be accessed under http://localhost:3000/. It can be stopped with the `Ctrl-C` key combination. +## Docker + +The `Dockerfile` in this repo allows to build and run a docker container like this: + +```bash +docker build -t histvv/server . +docker run -ti -p 3000:3000 -e dbhost=10.1.2.3 histvv/server +``` + +This would run a containerized histvv-server connecting to a BaseX database hosted at `10.1.2.3` (with the default port `1984` and database name `histvv`). +It would be available at http://localhost:3000/. + +The exposed port of the histvv-server and the database it connects to can be +overridden from the command line: + +```bash +docker run -ti \ + -p 3003:3000 \ + -e dbhost=10.1.2.3 \ + -e dbport=1999 \ + -e dbname=histvv_leipzig \ + histvv/server +``` + ## Development With `npm start` you can run an instance of the histvv server that reloads