-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcompose.yaml
More file actions
125 lines (113 loc) · 3.33 KB
/
compose.yaml
File metadata and controls
125 lines (113 loc) · 3.33 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
x-logging: &default-logging
driver: json-file
options:
max-size: '10m'
max-file: '5'
services:
postgres:
image: postgres:18.2-bookworm
networks:
- internal
env_file:
- .env
environment:
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql
restart: unless-stopped
logging: *default-logging
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U ${DB_USER} -d ${DB_NAME}']
interval: 10s
timeout: 5s
retries: 5
redis:
image: valkey/valkey:9.0.2-alpine
env_file:
- .env
networks:
- internal
command: ['valkey-server', '--appendonly', 'yes', '--requirepass', '${REDIS_PASSWORD}']
volumes:
- redis_data:/data
restart: unless-stopped
logging: *default-logging
healthcheck:
test: ['CMD', 'valkey-cli', '-a', '${REDIS_PASSWORD}', 'ping']
interval: 10s
timeout: 5s
retries: 5
static:
image: ghcr.io/mashrafdev/mahmoudashraf.dev-nginx:${IMAGE_TAG:?IMAGE_TAG is required}
networks:
- caddy
restart: unless-stopped
init: true
security_opt:
- no-new-privileges:true
logging: *default-logging
healthcheck:
test: ['CMD-SHELL', 'curl -s -I http://localhost/static/ > /dev/null || exit 1']
interval: 10s
timeout: 5s
retries: 5
django:
image: ghcr.io/mashrafdev/mahmoudashraf.dev:${IMAGE_TAG:?IMAGE_TAG is required}
networks:
- internal
- caddy
entrypoint: ['/app/bin/django-entrypoint.sh']
env_file:
- .env
init: true
stop_grace_period: 45s
restart: unless-stopped
security_opt:
- no-new-privileges:true
logging: *default-logging
labels:
caddy: mahmoudashraf.dev
caddy.reverse_proxy: '{{upstreams 8000}}'
# www Redirect
caddy_1: www.mahmoudashraf.dev
caddy_1.redir: https://mahmoudashraf.dev{uri} 301
# Redirects
caddy.redir_0: '/yt https://www.youtube.com/@mashrafdev 301'
caddy.redir_1: '/youtube https://www.youtube.com/@mashrafdev 301'
caddy.redir_2: '/gh https://github.com/mashrafdev 301'
caddy.redir_3: '/github https://github.com/mashrafdev 301'
caddy.redir_4: '/in https://www.linkedin.com/in/mashrafdev 301'
caddy.redir_5: '/linkedin https://www.linkedin.com/in/mashrafdev 301'
# Proxy /js/script.js to goatcounter
caddy.handle_0: '/js/script.js'
caddy.handle_0.rewrite: '/count.js'
caddy.handle_0.reverse_proxy: 'goatcounter:8080'
caddy.handle_0.reverse_proxy.header_up: 'Host stats.mahmoudashraf.dev'
# Proxy /count to goatcounter
caddy.handle_1: '/count'
caddy.handle_1.reverse_proxy: 'goatcounter:8080'
caddy.handle_1.reverse_proxy.header_up: 'Host stats.mahmoudashraf.dev'
# Static Files
caddy.handle_2: /static/*
caddy.handle_2.0_reverse_proxy: 'static:80'
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ['CMD', 'python', 'manage.py', 'health_check', 'health_check-container', 'django:8000']
interval: 60s
timeout: 10s
retries: 3
start_period: 30s
networks:
internal:
driver: bridge
caddy:
external: true
volumes:
postgres_data:
redis_data: