Skip to content

Commit 0656366

Browse files
authored
Merge pull request #35 from JawherKl/feature/22-update-docker
update docker composer and integrate postgres
2 parents ba36803 + bd662d4 commit 0656366

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ COPY . .
1717
EXPOSE 3000
1818

1919
# Command to run the application
20-
CMD ["node", "src/index.js"]
20+
CMD ["node", "index.js"]

docker-compose.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
11
version: "3.3"
22

33
services:
4+
db:
5+
image: postgres:15
6+
environment:
7+
POSTGRES_USER: postgres
8+
POSTGRES_PASSWORD: postgres
9+
POSTGRES_DB: node_api_db
10+
ports:
11+
- "5400:5432"
12+
volumes:
13+
- postgres-data:/var/lib/postgresql/data
14+
healthcheck:
15+
test: ["CMD-SHELL", "pg_isready -U postgres"]
16+
interval: 10s
17+
timeout: 5s
18+
retries: 5
19+
20+
pgadmin:
21+
image: dpage/pgadmin4
22+
environment:
23+
PGADMIN_DEFAULT_EMAIL: admin@admin.com
24+
PGADMIN_DEFAULT_PASSWORD: admin
25+
ports:
26+
- "5404:80"
27+
depends_on:
28+
- db
29+
volumes:
30+
- pgadmin-data:/var/lib/pgadmin
31+
restart: always
32+
433
node-api:
534
build:
635
context: .
@@ -9,9 +38,11 @@ services:
938
- "3000:3000"
1039
environment:
1140
NODE_ENV: development
12-
DATABASE_URL: postgresql://postgres:postgres@host.docker.internal:5450/node_api_db
41+
DATABASE_URL: postgresql://postgres:postgres@db:5432/node_api_db
1342
extra_hosts:
1443
- "host.docker.internal:host-gateway"
44+
depends_on:
45+
- db
1546

1647
prometheus:
1748
image: prom/prometheus
@@ -31,4 +62,6 @@ services:
3162
- grafana-storage:/var/lib/grafana
3263

3364
volumes:
65+
postgres-data:
66+
pgadmin-data:
3467
grafana-storage:

0 commit comments

Comments
 (0)