Skip to content

Commit 1a2d0d1

Browse files
committed
Update README and docker-compose
1 parent cb705c0 commit 1a2d0d1

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ To properly set up and run the app perform following steps:
1919
5. Before 2nd and every other app run (i.e. before executing Step4) set `spring.flyway.enabled` property to `false` located in `src/main/resources/application.properties`
2020

2121
## 2. App containerization
22-
If you prefer not to have...
23-
#TODO: Finish this!!!!!!!!!!!!!
22+
If you prefer not to have needed Postgres 12 version installed on your computer locally you can run docker-compose.
23+
In that use case you need to:
24+
1. Disable port 5432 in order for containerized Postgres image to run
25+
2. Create docker network named `app_db_net`.
26+
27+
Finally, execute `docker compose up -d` command to start both application and database containers.
2428

2529

2630
## 3. REST Endpoints

docker-compose.yml

+20-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: '3.8'
21
# TODO Read following docs:
32
# https://github.com/docker-library/docs/blob/master/postgres/README.md
43
# https://github.com/docker-library/docs/tree/master/openjdk
@@ -13,6 +12,7 @@ services:
1312
image: postgres:12.9
1413
restart: always
1514
container_name: postgres_db
15+
hostname: postgres_db
1616
volumes:
1717
- postgres-data:/var/lib/postgresql/data
1818
# - postgres-data:/var/lib/postgresql/data
@@ -22,37 +22,44 @@ services:
2222
POSTGRES_DB: todo_db
2323
# TODO: try mapping to different host and container ports
2424
networks:
25-
- app_db_net
25+
app_db_net:
26+
aliases:
27+
- postgres_db
28+
- app
2629
ports:
2730
- "5432:5432"
2831

2932
app:
3033
#image: openjdk:8
3134
build: .
32-
image: nixos89/todo_app:0.2
35+
image: nixos89/todo_app:0.1
36+
restart: on-failure
3337
container_name: todo_app
38+
hostname: postgres_db
3439
depends_on:
35-
- postgres_db
40+
- "postgres_db"
3641
ports:
3742
- "8080:8080"
3843
volumes:
3944
- ./build/libs:/app
4045
networks:
41-
- app_db_net
46+
app_db_net:
47+
aliases:
48+
- postgres_db
49+
- app
4250
environment:
43-
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres_db:5432/todo_db
44-
- SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.Driver
45-
- SPRING_DATASOURCE_USERNAME=postgres
46-
- SPRING_DATASOURCE_PASSWORD=postgres
47-
- SPRING_JPA_HIBERNATE_DDL_AUTO=update
48-
- SPRING_FLYWAY_USER=postgres
49-
- SPRING_FLYWAY_PASSWORD=postgres
51+
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres_db:5432/todo_db
52+
SPRING_DATASOURCE_DRIVER_CLASS_NAME: org.postgresql.Driver
53+
SPRING_DATASOURCE_USERNAME: postgres
54+
SPRING_DATASOURCE_PASSWORD: postgres
55+
SPRING_JPA_HIBERNATE_DDL_AUTO: update
56+
SPRING_FLYWAY_USER: postgres
57+
SPRING_FLYWAY_PASSWORD: postgres
5058

5159
networks:
5260
app_db_net:
5361
driver: bridge
5462
external: true
55-
# name: project
5663

5764
volumes:
5865
postgres-data:

0 commit comments

Comments
 (0)