1
|
version: '3.8'
|
2
|
|
3
|
services:
|
4
|
db: # PostgreSQL database
|
5
|
image: postgres:14.2
|
6
|
container_name: postgres-db
|
7
|
environment:
|
8
|
- POSTGRES_DB=test # database name
|
9
|
- POSTGRES_USER=test # database user
|
10
|
- POSTGRES_PASSWORD=Password.123 # database password
|
11
|
expose:
|
12
|
- 5432
|
13
|
ports:
|
14
|
- "5432:5432" # expose port 5432 (PostgreSQL) out of the docker container to the local machine
|
15
|
|
16
|
|
17
|
app: # Spring boot application
|
18
|
build: .
|
19
|
container_name: app-backend # name of the container
|
20
|
ports:
|
21
|
- "8080:8080" # expose port 8080 out of the docker container do the local machine
|
22
|
depends_on:
|
23
|
- db
|
24
|
environment:
|
25
|
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/test # overwrites application.properties datasource url to connect to the database
|
26
|
|
27
|
volumes:
|
28
|
db-data:
|