Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
68 lines (64 loc) · 2.89 KB
/
Copy pathdocker-compose.yml
File metadata and controls
68 lines (64 loc) · 2.89 KB
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
# Local development database.
#
# docker compose up -d start an empty Postgres
# docker compose --profile app up --build -d start Postgres and the app on 8080
# docker compose down stop it (data is kept)
# docker compose down -v stop it and delete all data
#
# Works the same on Windows, macOS and Linux, so nobody needs a local
# Postgres install. Credentials below are development-only defaults and are
# deliberately overridable - do not put real credentials in this file or in
# application.properties, override them with a .env file instead.
#
# The container starts empty on purpose. It used to mount
# db/V1__initial_schema.sql as an initdb script, which meant the schema had
# two owners: the entrypoint applied V1 and Flyway then had to be told to
# tolerate a database it had never migrated. Flyway owns it now, so the app
# creates the schema on its first start and there is one place a table can
# come from. Volumes created before this change are unaffected.
services:
db:
image: postgres:16
container_name: faf-db
# Come back automatically after a Docker or machine restart, so the database
# is not left down while something that depends on it is brought back up.
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-clanadmin}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-devpassword}
POSTGRES_DB: ${POSTGRES_DB:-clan_management}
# Published on 127.0.0.1 only, so the database is reachable from this machine
# and not from everyone else on the same network (a laptop on campus wifi).
# The app container still reaches it as db:5432 over the compose network.
ports:
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
volumes:
- faf-db-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-clanadmin} -d ${POSTGRES_DB:-clan_management}"]
interval: 5s
timeout: 5s
retries: 12
app:
build: .
container_name: faf-app
profiles: ["app"]
depends_on:
db:
condition: service_healthy
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/${POSTGRES_DB:-clan_management}
SPRING_DATASOURCE_USERNAME: ${POSTGRES_USER:-clanadmin}
SPRING_DATASOURCE_PASSWORD: ${POSTGRES_PASSWORD:-devpassword}
# dev switches on the in-memory accounts, and admin/admin is a site
# administrator there, so this default is for demos only
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-dev}
# inside the container the app has to listen on the container's own
# interface, the dev profile's 127.0.0.1 would leave it unreachable
SERVER_ADDRESS: 0.0.0.0
# 127.0.0.1 only: with the dev profile on, anyone who could reach this port
# could sign in as admin/admin and use the admin console
ports:
- "127.0.0.1:8080:8080"
volumes:
faf-db-data: