-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-compose.yml
70 lines (59 loc) · 2.39 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
59
60
61
62
63
64
65
66
67
68
69
70
# Reference : https://www.section.io/engineering-education/running-a-multi-container-springboot-postgresql-application-with-docker-compose/
version: '3.1'
services:
application:
container_name: container_main_info_keeper
image: info_keeper_main_image
build: . # or build the image from the dockerfile located at the current directory
# pull docker image that I've already created for this application. It can be local docker image as well
# image: badripaudel77/info-keeper-spring-boot-docker:my-info-app #docker image from the docker-hub
# image: 'info-keeper-spring-boot-docker-local' #local image build using docker-build command
# map ports of 8080 from my computer to the docker container's port of 5000
ports:
- "5000:8080"
networks:
- info_keeper_network
# This APP services depends upon postgres Service
depends_on:
[pg_database]
restart: always
#Define Environment
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://pg_database:5432/info_keeper_sb_docker
- SPRING_DATASOURCE_USERNAME=postgres
- SPRING_DATASOURCE_PASSWORD=_BadriPostgres1@
- SPRING_JPA_HIBERNATE_DDL_AUTO=update
# - APP_ENV_NAME=uat
pg_database:
#official image of postgres from the docker hub, by default pulls the latest one.
image: postgres:16
container_name: container_postgres_service
# map the ports for postgres
ports:
- "5433:5432"
networks:
- info_keeper_network
# As data is stored on container's volume, it will be erased once we delete or remove the container.
# to persist data even after the removal of the container, we need to mount volume so that the volume on /var/lib/postgresql/data
# will be mapped to the given location.
# in my case /Users/badripaudel/IdeaProjects/Information-Keeper-SB/data it has data and app using the same docker compose file
# use data from this location.
volumes:
# - grails_web_db:/var/lib/postgresql/data
- ./data:/var/lib/postgresql/data
# define environments for the postgres
environment:
- POSTGRES_PASSWORD=_BadriPostgres1@
- POSTGRES_USER=postgres
- POSTGRES_DB=info_keeper_sb_docker
# - POSTGRES_DB=test_dump
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
networks:
info_keeper_network:
driver: bridge
#volumes:
# grails_web_db: