Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:12
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080

ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
RUN chmod +x /wait

## Launch the wait tool and then your application
CMD /wait && npm start
# CMD [ "node", "server"]
5 changes: 3 additions & 2 deletions app/config/db.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
HOST: "localhost",
HOST: "db",
USER: "postgres",
PASSWORD: "123",
PASSWORD: "postgres",
PORT: "5432",
DB: "testdb",
dialect: "postgres",
pool: {
Expand Down
2 changes: 1 addition & 1 deletion app/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Sequelize = require("sequelize");
const sequelize = new Sequelize(dbConfig.DB, dbConfig.USER, dbConfig.PASSWORD, {
host: dbConfig.HOST,
dialect: dbConfig.dialect,

port: dbConfig.PORT,
pool: {
max: dbConfig.pool.max,
min: dbConfig.pool.min,
Expand Down
28 changes: 28 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: "3.7"
services:
node_backend:
container_name: "node_backend"
build: .
environment:
WAIT_HOSTS: db:5432
ports:
- "8080:8080"
depends_on:
- db

db:
image: "postgres:12"
container_name: "postgres"
ports:
- "5432:5432"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=testdb
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5