-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
134 lines (127 loc) · 3.89 KB
/
docker-compose.yaml
File metadata and controls
134 lines (127 loc) · 3.89 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
126
127
128
129
130
131
132
133
134
services:
traefik:
image: traefik:v3.0
container_name: pynews-traefik
ports:
- "80:80"
- "443:443"
- "127.0.0.1:8080:8080" # Dashboard only accessible locally
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik:/etc/traefik:rw
command:
- --configfile=/etc/traefik/traefik.yml
restart: unless-stopped
networks:
- pynews-network
labels:
- "traefik.enable=false"
pynews-api:
build:
context: .
dockerfile: Dockerfile
target: development
container_name: pynews-server
expose:
- "8000"
env_file:
- .env
restart: unless-stopped
volumes:
- sqlite_data:/app/data
environment:
- SQLITE_PATH=/app/data/pynewsdb.db
- SQLITE_URL=sqlite+aiosqlite:////app/data/pynewsdb.db
depends_on:
- sqlite-init
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/healthcheck"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- pynews-network
labels:
- "traefik.enable=true"
# HTTP router (for Let's Encrypt challenge and localhost access)
- "traefik.http.routers.pynews-api-http.rule=Host(`www.pynews.org`) || Host(`pynews.org`) || Host(`localhost`)"
- "traefik.http.routers.pynews-api-http.entrypoints=web"
- "traefik.http.routers.pynews-api-http.priority=1"
# HTTPS router
- "traefik.http.routers.pynews-api-https.rule=Host(`www.pynews.org`) || Host(`pynews.org`)"
- "traefik.http.routers.pynews-api-https.entrypoints=websecure"
- "traefik.http.routers.pynews-api-https.tls=true"
- "traefik.http.routers.pynews-api-https.tls.certresolver=letsencrypt"
- "traefik.http.routers.pynews-api-https.priority=1"
- "traefik.http.services.pynews-api.loadbalancer.server.port=8000"
sqlite-init:
image: alpine:latest
container_name: pynews-sqlite-init
volumes:
- sqlite_data:/data
command: >
sh -c "
mkdir -p /data &&
touch /data/pynewsdb.db &&
chmod 777 /data &&
chmod 666 /data/pynewsdb.db &&
chown -R root:root /data &&
echo 'SQLite database initialized'
"
restart: "no"
networks:
- pynews-network
scanapi-tests:
build:
context: .
dockerfile: Dockerfile
target: scanapi-test
container_name: scanapi-tests
env_file:
- .env
environment:
- BASE_URL=http://pynews-server:8000
volumes:
- report-data:/server/scanapi
depends_on:
pynews-api:
condition: service_healthy
command: ["/server/run-tests.sh"]
networks:
- pynews-network
scanapi-report-viewer:
image: nginx:alpine
container_name: scanapi-report-viewer
expose:
- "80"
volumes:
- report-data:/usr/share/nginx/html
depends_on:
- scanapi-tests
networks:
- pynews-network
labels:
- "traefik.enable=true"
# HTTP router
- "traefik.http.routers.scanapi-reports-http.rule=(Host(`www.pynews.org`) || Host(`pynews.org`)) && PathPrefix(`/reports`)"
- "traefik.http.routers.scanapi-reports-http.entrypoints=web"
- "traefik.http.routers.scanapi-reports-http.priority=50"
# HTTPS router
- "traefik.http.routers.scanapi-reports-https.rule=(Host(`www.pynews.org`) || Host(`pynews.org`)) && PathPrefix(`/reports`)"
- "traefik.http.routers.scanapi-reports-https.entrypoints=websecure"
- "traefik.http.routers.scanapi-reports-https.tls=true"
- "traefik.http.routers.scanapi-reports-https.tls.certresolver=letsencrypt"
- "traefik.http.routers.scanapi-reports-https.priority=50"
- "traefik.http.services.scanapi-reports.loadbalancer.server.port=80"
volumes:
report-data:
sqlite_data:
driver: local
driver_opts:
type: none
o: bind
device: ./data
networks:
pynews-network:
driver: bridge