diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..c47e05e0a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM node:10-alpine + +# nuxt host and port to be replaced in package.json. (See 2.3 in bwHCPrototypeManual) +# NUXT_HOST should have a value with public available IP address from within container. +# If changing NUXT_PORT, also change exposed port. +ARG NUXT_HOST=0.0.0.0 +ARG NUXT_PORT=3000 + +# Backend access setup. (See 2.4 in bwHCPrototypeManual) +ARG BACKEND_PROTOCOL=http +ARG BACKEND_HOSTNAME=localhost +ARG BACKEND_PORT=8080 + +COPY . /bwhc-frontend + +WORKDIR /bwhc-frontend + +RUN npm install + +# Prepare package.json +RUN sed -i -r "s/^(\s*)\"host\"[^,]*(,?)/\1\"host\": \"$NUXT_HOST\"\2/" ./package.json +RUN sed -i -r "s/^(\s*)\"port\"[^,]*(,?)/\1\"port\": \"$NUXT_PORT\"\2/" ./package.json + +# Prepare nuxt.config.js +RUN sed -i -r "s/^(\s*)baseUrl[^,]*(,?)/\1baseUrl: process.env.BASE_URL || '$BACKEND_PROTOCOL:\/\/$BACKEND_HOSTNAME'\2/" ./nuxt.config.js +RUN sed -i -r "s/^(\s*)port[^,]*(,?)/\1port: process.env.port || ':$BACKEND_PORT'\2/" ./nuxt.config.js + +RUN npm run generate + +EXPOSE $NUXT_PORT + +CMD npm start diff --git a/README.md b/README.md index 94f74106d..85d45397a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# bwHC Frontend +# bwHC Frontend __bwHC Frontend__ is a web application developed using the [nuxt.js](https://nuxtjs.org/docs/get-started/installation/) framework. It is designed to run complementary with the bwHC Backend application. @@ -6,7 +6,7 @@ __bwHC Frontend__ is a web application developed using the [nuxt.js](https://nux ## 1. Installation with Install script -* Define the directory for the installation +* Define the directory for the installation * Run the install script ``` @@ -101,6 +101,25 @@ Login credentials into the freshly installed system, without any users: admin/ad This allows log-in as a temp-user to create a first real user account, and becomes effectless once a user has been created in the system. The first created user MUST thus be given "Admin" rights to be able to create more user accounts. +## 3 Docker image + +Use the following command to build the docker image + +``` +docker build -t bwhc-frontend . +``` + +This will create the image using default build arguments and mark it as `bwhc-frontend`. To customize the build, spezify custom values. + +* `NUXT_HOST` and `NUXT_PORT`: Server configuration, see 2.3 of bwHC manual for more information. +* `BACKEND_PROTOCOL`, `BACKEND_HOSTNAME` and `BACKEND_PORT`: Backend access, see 2.4 of bwHC manual for more information. + +e.g.: + +``` +docker build -t bwhc-frontend --build-arg NUXT_PORT=1234 . +``` + ## License Information MIT License