forked from OKaluzny/demoWithTests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
59 lines (58 loc) · 1.78 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Docker Compose file Reference (https://docs.docker.com/compose/compose-file/)
version: '3.8'
networks:
backend:
name: demo
driver: bridge
volumes:
postgres_data:
driver: local
# Define services
services:
# App backend service
app:
image: demo-app:latest
build:
context: ./
dockerfile: "Dockerfile"
# Give the container the name web-app. You can changes to something else.
container_name: web-app
# Forward the exposed port 8080 on the container to port 8080 on the host machine
ports:
- "8089:8089"
networks:
- backend
# This service depends on postgres. Start that first.
depends_on:
- db
healthcheck:
test: curl --fail http://app:8089/actuator/health
interval: 1m
timeout: 10s
retries: 5
# Database Service (Postgres)
db:
# Use the Docker Image postgres. This will pull the 12 version.
image: postgres:14
# Give the container the name postgres-db. You can changes to something else.
container_name: postgres-db
restart: always
# Set a volume some that database is not lost after shutting down the container.
# I used the name postgres-data but you can changed it to something else.
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- backend
# Maps port 5432 (localhost) to port 5432 on the container. You can change the ports to fix your needs.
ports:
- "5433:5432"
# Setup the username, password, and database name. You can changes these values.
environment:
- "POSTGRES_USER=postgres"
- "POSTGRES_PASSWORD=postgres"
- "POSTGRES_DB=employee"
healthcheck:
test: [ "CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}" ]
interval: 1m
timeout: 10s
retries: 5