-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocker-compose.yml
158 lines (152 loc) · 5.89 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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
version: '3'
services:
traefik:
image: traefik:v2.10
ports:
- '80:80'
- '443:443'
- '8080:8080' # Dashboard
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- traefik-certificates:/certificates
command:
- '--api.dashboard=true'
- '--providers.docker=true'
- '--providers.docker.exposedbydefault=false'
- '--entrypoints.web.address=:80'
- '--entrypoints.websecure.address=:443'
- '--entrypoints.dashboard.address=:8080'
- '--certificatesresolvers.letsencrypt.acme.email=admin@openaastra.com'
- '--certificatesresolvers.letsencrypt.acme.tlschallenge=true'
- '--certificatesresolvers.letsencrypt.acme.storage=/certificates/acme.json'
- '--accesslog=true'
- '--log=true'
labels:
# Dashboard
- 'traefik.enable=true'
- 'traefik.http.routers.dashboard.rule=Host(`dashboard.api.openastra.com`)'
- 'traefik.http.routers.dashboard.service=api@internal'
- 'traefik.http.routers.dashboard.entrypoints=websecure'
- 'traefik.http.routers.dashboard.tls=true'
- 'traefik.http.routers.dashboard.tls.certresolver=letsencrypt'
- 'traefik.http.routers.dashboard.middlewares=auth'
# Basic auth middleware
- 'traefik.http.middlewares.auth.basicauth.users=admin:$$apr1$$zhsv7RzN$$sS6t73YKjNbudbRCuE2oF0' # Replace with your hash
# Add HTTPS redirect middleware
- 'traefik.http.middlewares.https-redirect.redirectscheme.scheme=https'
- 'traefik.http.middlewares.https-redirect.redirectscheme.permanent=true'
# Apply the redirect middleware
- 'traefik.http.routers.dashboard-http.middlewares=https-redirect'
# Add constraint label for better control
- 'traefik.docker.network=traefik-public'
- 'traefik.constraint-label=traefik-public'
networks:
- traefik-public
restart: always
backend:
build:
context: ./backend
dockerfile: Dockerfile
environment:
- PROJECT_NAME=OpenAstra
- POSTGRES_SERVER=db
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- FIRST_SUPERUSER_PASSWORD=openastra123
- DOMAIN=api.openastra.com
- ENVIRONMENT=production
- BACKEND_CORS_ORIGINS=https://openastra.com,https://www.openastra.com
- SECRET_KEY=yBUzteofjwxyj4b3RLGJGntojhb8B_i0mt2Oy7T-gIU
- USERS_OPEN_REGISTRATION=False
- DB_TYPE=sqlite
- POSTGRES_PORT=5432
- POSTGRES_DB=app
volumes:
- ~/.openastra:/root/.openastra
ports:
- '8000:8000'
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.backend.rule=Host(`api.openastra.com`)'
- 'traefik.http.routers.backend.entrypoints=websecure'
- 'traefik.http.routers.backend.tls.certresolver=letsencrypt'
# HTTP to HTTPS redirect
- 'traefik.http.routers.backend-http.rule=Host(`api.openastra.com`)'
- 'traefik.http.routers.backend-http.entrypoints=web'
- 'traefik.http.routers.backend-http.middlewares=redirect-to-https'
- 'traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https'
- 'traefik.http.services.backend.loadbalancer.server.port=8000'
# Add network and constraint labels
- 'traefik.docker.network=traefik-public'
- 'traefik.constraint-label=traefik-public'
networks:
- traefik-public
restart: always
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
environment:
- NEXT_PUBLIC_API_URL=https://api.openastra.com
- OPENAI_API_KEY=xxxxxxx
- NEXT_TELEMETRY_DISABLED=1
- NEXT_PUBLIC_DISABLE_TELEMETRY=false
- NEXTAUTH_URL=https://openastra.com
- NEXTAUTH_SECRET=yBUzteofjwxyj4b3RLGJGntojhb8B_i0mt2Oy7T-gIU
- NEXTAUTH_URL_INTERNAL=http://frontend:3000
- NEXT_PUBLIC_APP_URL=https://openastra.com
- BACKEND_HOST=https://api.openastra.com
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.frontend.rule=Host(`openastra.com`)' # Your main domain
- 'traefik.http.routers.frontend.entrypoints=websecure'
- 'traefik.http.routers.frontend.tls.certresolver=letsencrypt'
- 'traefik.http.services.frontend.loadbalancer.server.port=3000'
# HTTP to HTTPS redirect
- 'traefik.http.routers.frontend-http.rule=Host(`openastra.com`)'
- 'traefik.http.routers.frontend-http.entrypoints=web'
- 'traefik.http.routers.frontend-http.middlewares=redirect-to-https'
# Add network and constraint labels
- 'traefik.docker.network=traefik-public'
- 'traefik.constraint-label=traefik-public'
# Enhance www handling
- 'traefik.http.middlewares.frontend-www-redirect.redirectregex.regex=^http(s)?://www.(openastra.com)/(.*)$'
- 'traefik.http.middlewares.frontend-www-redirect.redirectregex.replacement=http$${1}://openastra.com/$${3}'
# Apply www redirect middleware
- 'traefik.http.routers.frontend.middlewares=frontend-www-redirect'
- 'traefik.http.routers.frontend-http.middlewares=https-redirect,frontend-www-redirect'
networks:
- traefik-public
restart: always
sqlite-web:
image: coleifer/sqlite-web:latest
command:
[
'sqlite_web',
'--host',
'0.0.0.0',
'--password',
'--port',
'8080',
'/db/app.db',
]
ports:
- '8082:8080' # Port mapping, adjust if necessary
volumes:
- ~/.openastra:/db # Mount the directory containing the SQLite file (read-only)
environment:
- SQLITE_WEB_PASSWORD=o$$pn$$tr@123
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.sqlite-web.rule=Host(`sqlite-web.openastra.com`)'
- 'traefik.http.routers.sqlite-web.entrypoints=websecure'
- 'traefik.http.routers.sqlite-web.tls.certresolver=letsencrypt'
networks:
- traefik-public
restart: always
networks:
traefik-public:
name: traefik-public
volumes:
traefik-certificates: