Skip to content

Commit 96cee68

Browse files
committed
Add docker setup files
Using docker compose since we have two containers: - One for the hub running a nodejs-alpine image - The other for a mysql database
1 parent fd1fbb3 commit 96cee68

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

.dockerignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.vscode
2+
.git*
3+
.env
4+
.dockerignore
5+
*Dockerfile*
6+
*docker-compose*
7+
**/node_modules
8+
dist
9+
coverage

Dockerfile

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM node:9-alpine
2+
3+
RUN npm i npm@latest -g
4+
5+
## Install build toolchain, install node deps and compile native add-ons
6+
RUN apk add --no-cache --virtual python make g++
7+
8+
# Create app directory
9+
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
10+
11+
# Set the working directory for the application
12+
WORKDIR /home/node/app
13+
14+
# Before running install, switch to non-root user "node"
15+
USER node
16+
17+
# A wildcard is used to ensure both package.json AND package-lock.json are copied
18+
COPY package*.json ./
19+
20+
# Install app dependencies
21+
RUN npm ci
22+
23+
WORKDIR /home/node/app
24+
COPY . .
25+
26+
EXPOSE 5000
27+
CMD [ "npm", "run", "start:watch" ]

docker-compose.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
version: '2.1'
2+
services:
3+
hub-dev:
4+
container_name: hub
5+
build: .
6+
depends_on:
7+
mysql_db:
8+
condition: service_healthy
9+
volumes:
10+
- .:/home/node/app/
11+
- /home/node/app/node_modules
12+
environment:
13+
- DB_TYPE=mysql
14+
- DB_HOST=mysql_db
15+
- DB_USER=root
16+
- DB_PASSWORD=root
17+
- DB_DATABASE=hub
18+
ports:
19+
- "5000:5000"
20+
networks:
21+
- backend
22+
mysql_db:
23+
container_name: mysql_db
24+
image: mysql:5.7
25+
command: --default-authentication-plugin=mysql_native_password --log_error_verbosity=1
26+
environment:
27+
MYSQL_ROOT_PASSWORD: root
28+
MYSQL_DATABASE: hub
29+
ports:
30+
- "3306:3306"
31+
healthcheck:
32+
test: ["CMD-SHELL", "mysqladmin ping -h localhost --silent"]
33+
timeout: 5s
34+
retries: 10
35+
networks:
36+
- backend
37+
networks:
38+
backend:

0 commit comments

Comments
 (0)