-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose-localdb.yml
More file actions
67 lines (64 loc) · 2.03 KB
/
docker-compose-localdb.yml
File metadata and controls
67 lines (64 loc) · 2.03 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
services:
discordbot_database:
image: postgres:latest
container_name: discordbot_database
hostname: postgres
restart: always
env_file: .env
environment:
TZ: UTC
POSTGRES_USER: ${POSTGRESQL_USER}
PGUSER: ${POSTGRESQL_USER}
POSTGRES_PASSWORD: ${POSTGRESQL_PASSWORD}
POSTGRES_DB: ${POSTGRESQL_DATABASE}
PGDATABASE: ${POSTGRESQL_DATABASE}
POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256 --auth-local=scram-sha-256"
ports:
- ${POSTGRESQL_PORT}:5432
volumes:
- discordbot_database_data:/var/lib/postgresql:rw
networks:
- postgres_network
command: >
bash -c "
docker-entrypoint.sh postgres &
until pg_isready -U ${POSTGRESQL_USER} -h localhost; do sleep 1; done;
PGPASSWORD=${POSTGRESQL_PASSWORD} psql -U ${POSTGRESQL_USER} -d postgres -tc \"SELECT 1 FROM pg_database WHERE datname = '${POSTGRESQL_DATABASE}'\" | grep -q 1 || PGPASSWORD=${POSTGRESQL_PASSWORD} psql -U ${POSTGRESQL_USER} -d postgres -c \"CREATE DATABASE ${POSTGRESQL_DATABASE}\";
wait
"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRESQL_USER} -d ${POSTGRESQL_DATABASE}"]
interval: 10s
timeout: 10s
retries: 5
start_period: 30s
discordbot_alembic:
build:
context: .
dockerfile: Dockerfile
container_name: discordbot_alembic
restart: always
env_file: .env
environment:
DOCKER_BUILDKIT: 1
networks:
- postgres_network
depends_on:
discordbot_database:
condition: service_healthy
command: ["sh", "-c", "uv run --frozen --no-sync alembic upgrade head && touch /tmp/alembic_done && sleep infinity"]
deploy:
restart_policy:
delay: 60s
healthcheck:
test: ["CMD", "sh", "-c", "test -f /tmp/alembic_done"]
interval: 5s
timeout: 5s
retries: 12
start_period: 120s
volumes:
discordbot_database_data:
name: "discordbot_database_data"
networks:
postgres_network:
name: postgres_network