Skip to content

Commit 86231d7

Browse files
dockerise the service
1 parent df9d00f commit 86231d7

6 files changed

+103
-0
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
npm-debug.log
3+
*.sqlite

Dockerfile

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM node AS prebuilder
2+
3+
WORKDIR /app
4+
COPY src/ /app/src/
5+
COPY \
6+
.babelrc.js \
7+
package.json \
8+
yarn.lock \
9+
/app/
10+
11+
RUN \
12+
yarn install && \
13+
yarn build
14+
15+
# ***********************
16+
# jettison the prebuilder
17+
18+
FROM node:slim as runtime
19+
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
20+
21+
RUN \
22+
sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
23+
apt-get update && \
24+
apt-get -y upgrade && \
25+
apt-get install -y bash-completion vim && \
26+
apt-get clean
27+
28+
WORKDIR /srv/diminution
29+
COPY --from=prebuilder\
30+
/app/node_modules/\
31+
./node_modules/
32+
33+
COPY --from=prebuilder\
34+
/app/dist/\
35+
./dist/
36+
37+
COPY --from=prebuilder\
38+
/app/package.json\
39+
./
40+
41+
EXPOSE 4100
42+
CMD [ "node", "dist/index.js" ]

docker-compose.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
services:
2+
app:
3+
build: .
4+
env_file: .env
5+
environment:
6+
DEBUG: ${DEBUG}
7+
expose:
8+
- "4100"
9+
restart: always
10+
volumes:
11+
- app-data:/srv/diminution
12+
13+
nginx:
14+
build: ./nginx/
15+
depends_on:
16+
- app
17+
ports:
18+
- "8080:8080"
19+
restart: always
20+
volumes:
21+
- type: volume
22+
source: app-data
23+
target: /srv/diminution
24+
read_only: true
25+
- ./nginx/diminution.conf:/etc/nginx/conf.d/diminution.conf
26+
- ./persist/logs/:/var/log/
27+
- ./persist/logs/nginx:/var/log/nginx
28+
29+
volumes:
30+
app-data:

nginx/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM nginx
2+
3+
RUN rm /etc/nginx/conf.d/default.conf
4+
COPY ./diminution.conf /etc/nginx/conf.d/

nginx/diminution.conf

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
server {
2+
listen 8080;
3+
listen [::]:8080;
4+
5+
server_name diminution;
6+
7+
location /favicon.ico { access_log off; log_not_found off; }
8+
9+
location / {
10+
proxy_http_version 1.1;
11+
proxy_cache_bypass $http_upgrade;
12+
13+
proxy_set_header Upgrade $http_upgrade;
14+
proxy_set_header Connection 'upgrade';
15+
proxy_set_header Host $host;
16+
proxy_set_header X-Real-IP $remote_addr;
17+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
18+
proxy_set_header X-Forwarded-Proto $scheme;
19+
20+
proxy_pass http://app:4100;
21+
}
22+
}

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"scripts": {
88
"build": "npx babel src --out-dir ./dist --no-copy-ignored --delete-dir-on-start --minified",
99
"dev": "nodemon --exec babel-node src/index.js",
10+
"docker:build": "docker build -t overture/diminution .",
11+
"docker:run": "docker run -p 4100:4100 --name diminution -v `pwd`/persist/database.sqlite:/srv/diminution/dist/database/database.sqlite -d overture/diminution",
1012
"test": "echo \"Error: no test specified\" && exit 1"
1113
},
1214
"author": "",

0 commit comments

Comments
 (0)