-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdocker-compose.yml
49 lines (42 loc) · 1.41 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
version: '3.8'
services:
db:
image: postgres:16
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
healthcheck:
test:
[
"CMD-SHELL",
"PGPASSWORD=$${POSTGRES_PASSWORD} psql -U $${POSTGRES_USER} -d $${POSTGRES_DB} -c 'SELECT 1;' || exit 1"
]
interval: 1s
timeout: 5s
retries: 10
# This allows accessing externally from "localhost" in addition to "127.0.0.1"
ports:
- ${POSTGRES_PORT}:5432
app:
image: node:20-bullseye
restart: unless-stopped
volumes:
- ..:/workspaces:cached
- ../scripts:/scripts:cached
# Overrides default command so things don't shut down after the process ends.
command: sleep infinity
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
# depends_on:
# - db
# environment:
# - POSTGRES_HOST=db # connect to the Postgres container with Docker Networking
# - POSTGRES_PORT=5432 # use internal port of Postgres container
volumes:
postgres-data: