Skip to content

Commit

Permalink
Add Dockerfile
Browse files Browse the repository at this point in the history
This adds a Dockerfile to build bwHC Frontend from current sources.

By passing arguments to the docker build command, the build is able to
modify values in file `nuxt.config.js`.
  • Loading branch information
pcvolkmer committed Jun 30, 2023
1 parent f3fb354 commit 763b835
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# 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.

--------

## 1. Installation with Install script

* Define the directory for the installation
* Define the directory for the installation
* Run the install script

```
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 763b835

Please sign in to comment.