-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdocker-compose.yml
90 lines (84 loc) · 2.93 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
version: "3.9"
networks:
backend:
driver: overlay
name: backend
# traefik:
# driver: overlay
# name: traefik
# portainer-agent:
# driver: overlay
# name: portainer-agent
services:
####################
# --- Database --- #
####################
postgres:
image: postgres:9.6
environment:
POSTGRES_USER: ${POSTGRES_USER?Variable not set}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD?Variable not set}
POSTGRES_DB: ${POSTGRES_DB?Variable not set}
POSTGRES_PORT: ${POSTGRES_PORT?Variable not set}
PGDATA: /var/lib/postgresql/data/pgdata
ports:
- ${POSTGRES_PORT?Variable not set}:${POSTGRES_PORT?Variable not set}
volumes:
- ./infrastructure/containers/postgres/data:/var/lib/postgresql/data/
networks:
- backend
healthcheck:
test: [ "CMD-SHELL", "pg_isready --username ${POSTGRES_USER} --dbname ${POSTGRES_DB} --port ${POSTGRES_PORT}" ]
interval: 10s
timeout: 10s
retries: 10
deploy:
labels:
traefik.enable: "false"
replicas: 1
# # dpage/pgadmin is the official image; the docs were a bit hard to find:
# # https://www.pgadmin.org/docs/pgadmin4/6.1/container_deployment.html
# pgadmin:
# image: dpage/pgadmin4
# environment:
# PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL?Variable not set}
# PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD?Variable not set}
# networks:
# - traefik
# - backend
# volumes:
# - ./infrastructure/containers/pgadmin-volume/:/pgadmin/
# deploy:
# replicas: 1
# placement:
# constraints: [node.role == manager]
database-backup:
image: rootski/database-backup
build:
context: ./infrastructure/containers/postgres/automatic-backup/
dockerfile: Dockerfile
environment:
BACKUP_BUCKET: rootski-database-backups
BACKUP_DIR: /backups
BACKUP_INTERVAL: 24h
# AWS connection variables. Default to "" if the env vars are not set
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-""}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-""}
# database connection variables
# "postgres" is used as the host because it is the name of the service container
# that is running the database. database-backup and postgres containers must be
# running on the same network for this to work
POSTGRES_HOST: postgres
POSTGRES_PORT: ${POSTGRES_PORT?Variable not set}
POSTGRES_DB: ${POSTGRES_DB?Variable not set}
POSTGRES_USER: ${POSTGRES_USER?Variable not set}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD?Variable not set}
volumes:
- ./infrastructure/containers/postgres/backups:/backups
- ./infrastructure/containers/postgres/automatic-backup/backup_or_restore.py:/app/backup_or_restore.py
- ./infrastructure/containers/postgres/automatic-backup/scripts:/app/scripts
networks:
- backend
deploy:
replicas: 1
# labels: