-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.postgres.yml
More file actions
68 lines (64 loc) · 3.16 KB
/
Copy pathdocker-compose.postgres.yml
File metadata and controls
68 lines (64 loc) · 3.16 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
# Runs the stack on PostgreSQL instead of SQL Server.
#
# docker compose -f docker-compose.yml -f docker-compose.postgres.yml up -d
#
# Both are first-class: the same model, the same tests, the same CI checks. What differs is what
# the two databases genuinely do not share, and each of those is named in ProviderSpecificMapping
# rather than left to a convention - the filtered index that keeps one plan active, and the
# concurrency token, which PostgreSQL carries on its own `xmin` system column instead of a
# SQL Server `rowversion`.
#
# Migrations live in their own assembly per provider, because a migration is generated SQL rather
# than a description of intent: `nvarchar(200)` and `character varying(200)` cannot share a file.
# The application picks the assembly from Database__Provider at startup.
#
# Verified as far as this environment allows, and no further. The model, the mapping differences
# and the generated SQL are covered by tests and by CI on both providers; `docker compose config`
# renders this merge. What has NOT happened is either database actually running - the registry is
# filtered here, so no image was pulled and no migration was ever applied.
services:
core:
environment:
Database__Provider: postgresql
ConnectionStrings__Default: "Host=postgres;Database=echelon;Username=${POSTGRES_USER:-postgres};Password=${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required (see .env.example)}"
ConnectionStrings__Archive: "Host=postgres;Database=echelon_archive;Username=${POSTGRES_USER:-postgres};Password=${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required (see .env.example)}"
# Merged, not !override: overriding the whole map would drop what another override file put
# there, and the two are meant to combine - postgres.yml plus single-instance.yml is a valid
# deployment. `required: false` is what removes a dependency without erasing the map: the
# profiled-out service is not started, and Compose warns instead of refusing the project.
depends_on:
mssql:
condition: service_healthy
required: false
postgres:
condition: service_healthy
postgres:
image: postgres:17-alpine
environment:
POSTGRES_USER: "${POSTGRES_USER:-postgres}"
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required (see .env.example)}"
# The archive is a second database, so it cannot be POSTGRES_DB - that creates only one.
# Both are created by the init script below.
POSTGRES_DB: echelon
volumes:
- pgdata:/var/lib/postgresql/data
- ./scripts/postgres-init.sql:/docker-entrypoint-initdb.d/10-archive.sql:ro
healthcheck:
# -U, or pg_isready checks the OS user and reports ready before the role exists.
test: ["CMD-SHELL", "pg_isready -U \"$$POSTGRES_USER\" -d echelon"]
interval: 5s
timeout: 3s
retries: 10
start_period: 10s
deploy:
resources:
limits:
cpus: "4"
memory: 4G
restart: unless-stopped
# Kept in the model rather than deleted, so `docker compose config` still describes the full
# stack and switching back is dropping this file.
mssql:
profiles: ["never"]
volumes:
pgdata: