From 142899ac9f836b55024443dca12fd0564bc94dca Mon Sep 17 00:00:00 2001 From: Tristan Smith Date: Tue, 2 Feb 2021 21:31:00 -0500 Subject: [PATCH] Added Dockerfile * Updated README.md to reflect new Dockerfile running process * Added build-docker.sh * Added .dockerignore --- .dockerignore | 5 +++++ Dockerfile | 16 ++++++++++++++++ README.md | 17 +++++++++++++++++ build-docker.sh | 2 ++ 4 files changed, 40 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 build-docker.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c7bcc66 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.git +docker-compose.yaml +glass_start.sh +glass_stop.sh +config_backups \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f9f77e3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM node:8 +WORKDIR /home/node/app + +# install isc-dhcp-server; for config checking +RUN apt update && apt install isc-dhcp-server -y && rm -rf /var/cache/apt + +# cache node_modules +COPY package.json . +COPY package-lock.json . + +RUN npm install + +# copy the remainder of src +COPY . . + +CMD node ./bin/www \ No newline at end of file diff --git a/README.md b/README.md index d31e095..cdb4488 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,23 @@ +# Docker +1) Clone down the repo and do any configuration in `glass_config.json`. +2) Run `build-docker.sh` to create the container, tagged as `glass-isc-dhcp`. +3) Run the container for example: +`docker run -d --name glass --restart unless-stopped -p 8080:8080 -p 3000:3000 -v /var/lib/dhcp:/var/lib/dhcp -v /etc/dhcp/dhcpd.conf:/etc/dhcp/dhcpd.conf -v $(pwd)/config_backups:/home/node/app/config_backups glass-isc-dhcp:latest` + +> You can mount another config file if you want to store that outside the container, the app root is `/home/node/app`, so you can use `-v /path/to/glass_config.json:/home/node/app/config/glass_config.json` + +To update the container do the following: +1. Pull changes via `git` +2. Run `build-docker.sh` +3. Remove the old container, for example `docker stop glass && docker rm glass` + - Be sure to backup your config! `docker exec -it glass cat /home/node/app/config/glass_config.json` +4. Recreate the container, `docker run -d --name glass --restart unless-stopped -p 8080:8080 -p 3000:3000 -v /var/lib/dhcp:/var/lib/dhcp -v /etc/dhcp/dhcpd.conf:/etc/dhcp/dhcpd.conf -v $(pwd)/config_backups:/home/node/app/config_backups glass-isc-dhcp:latest` + +> If you had the config file mounted outside the container, edit the last command above accordingly. + # Installation * Instructions are per Debian/Ubuntu Distros diff --git a/build-docker.sh b/build-docker.sh new file mode 100644 index 0000000..d40e668 --- /dev/null +++ b/build-docker.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker build -t glass-isc-dhcp . \ No newline at end of file