Skip to content

Commit f5e72b3

Browse files
authored
feat: nginx支持https/密码通过secret存放 (#242)
* feat: nginx支持https * feat: 密码通过secret存放
1 parent c68ad9a commit f5e72b3

11 files changed

Lines changed: 176 additions & 101 deletions

File tree

deployment/docker/datamate/docker-compose.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ services:
88
image: ${REGISTRY:-}datamate-backend
99
restart: on-failure
1010
privileged: true
11+
environment:
12+
DB_PASSWORD: ${DB_PASSWORD:-password}
1113
volumes:
1214
- dataset_volume:/dataset
1315
- flow_volume:/flow
@@ -25,6 +27,7 @@ services:
2527
privileged: true
2628
environment:
2729
- log_level=DEBUG
30+
- pgsql_password=${DB_PASSWORD:-password}
2831
volumes:
2932
- dataset_volume:/dataset
3033
- flow_volume:/flow
@@ -45,7 +48,7 @@ services:
4548
image: ${REGISTRY:-}datamate-frontend
4649
restart: on-failure
4750
ports:
48-
- "30000:80"
51+
- "30000:3000"
4952
volumes:
5053
- frontend_log_volume:/var/log/datamate/frontend
5154
networks: [ datamate ]
@@ -59,7 +62,7 @@ services:
5962
restart: on-failure
6063
environment:
6164
- POSTGRES_USER=postgres
62-
- POSTGRES_PASSWORD=password
65+
- POSTGRES_PASSWORD=${DB_PASSWORD:-password}
6366
volumes:
6467
- postgresql_volume:/var/lib/postgresql/data
6568
- database_log_volume:/var/log/datamate/database
@@ -77,7 +80,7 @@ services:
7780
PG_HOST: "datamate-database"
7881
PG_PORT: "5432"
7982
PG_USER: "postgres"
80-
PG_PASSWORD: "password"
83+
PG_PASSWORD: ${DB_PASSWORD:-password}
8184
PG_DATABASE: "datamate"
8285
command:
8386
- python
@@ -167,7 +170,7 @@ services:
167170
volumes:
168171
- ./conf.yaml:/app/conf.yaml:ro
169172
- deer-flow-log-volume:/var/log/deer-flow
170-
restart: unless-stopped
173+
restart: on-failure
171174
networks:
172175
- datamate
173176
profiles:
@@ -180,7 +183,7 @@ services:
180183
- .env
181184
depends_on:
182185
- deer-flow-backend
183-
restart: unless-stopped
186+
restart: on-failure
184187
networks:
185188
- datamate
186189
profiles:
@@ -195,7 +198,7 @@ services:
195198
tty: true
196199
image: heartexlabs/label-studio:latest
197200
privileged: true
198-
restart: unless-stopped
201+
restart: on-failure
199202
user: root
200203
expose:
201204
- "8000"
@@ -207,7 +210,7 @@ services:
207210
- DJANGO_DB=default
208211
- POSTGRE_NAME=labelstudio
209212
- POSTGRE_USER=postgres
210-
- POSTGRE_PASSWORD=password
213+
- POSTGRE_PASSWORD=${DB_PASSWORD:-password}
211214
- POSTGRE_PORT=5432
212215
- POSTGRE_HOST=datamate-database
213216
- LABEL_STUDIO_HOST=${LABEL_STUDIO_HOST:-}
@@ -276,6 +279,7 @@ services:
276279

277280
milvus:
278281
container_name: milvus-standalone
282+
restart: on-failure
279283
image: milvusdb/milvus:v2.6.5
280284
command: ["milvus", "run", "standalone"]
281285
security_opt:

deployment/helm/datamate/charts/frontend/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ service:
5656
# This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
5757
type: NodePort
5858
# This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports
59-
port: 80
59+
port: 3000
6060
nodePort: 30000
6161

6262
resources: {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: datamate-conf
5+
data:
6+
{{- range $key, $val := .Values.secrets.data }}
7+
{{ $key }}: {{ $val | toString | b64enc | quote }}
8+
{{- end }}

deployment/helm/datamate/values.yaml

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public:
3737
log: 1Gi
3838
database: 1Gi
3939
operator: 1Gi
40+
secrets:
41+
data:
42+
DB_PASSWORD: "password"
4043

4144
datasetVolume: &datasetVolume
4245
name: dataset-volume
@@ -68,13 +71,17 @@ database:
6871
- name: POSTGRES_USER
6972
value: postgres
7073
- name: POSTGRES_PASSWORD
71-
value: &dbPass "password"
74+
valueFrom:
75+
secretKeyRef:
76+
name: datamate-conf
77+
key: DB_PASSWORD
7278
volumes:
7379
- *dataVolume
7480
- *logVolume
7581
volumeMounts:
7682
- name: data-volume
7783
mountPath: /var/lib/postgresql/data
84+
subPath: postgres
7885
- name: log-volume
7986
mountPath: /var/log/datamate/database
8087
subPath: database
@@ -86,7 +93,10 @@ backend:
8693
- SYS_ADMIN
8794
env:
8895
- name: DB_PASSWORD
89-
value: *dbPass
96+
valueFrom:
97+
secretKeyRef:
98+
name: datamate-conf
99+
key: DB_PASSWORD
90100
- name: datamate.rag.milvus-uri
91101
value: "http://milvus:19530"
92102
volumes:
@@ -106,8 +116,11 @@ backend:
106116

107117
backend-python:
108118
env:
109-
- name: DB_PASSWORD
110-
value: *dbPass
119+
- name: pgsql_password
120+
valueFrom:
121+
secretKeyRef:
122+
name: datamate-conf
123+
key: DB_PASSWORD
111124
volumes:
112125
- *datasetVolume
113126
- *flowVolume
@@ -134,16 +147,10 @@ frontend:
134147
nodePort: 30000
135148
volumes:
136149
- *logVolume
137-
- name: datamate-nginx-conf
138-
configMap:
139-
name: datamate-nginx-conf
140150
volumeMounts:
141151
- name: log-volume
142152
mountPath: /var/log/datamate/frontend
143153
subPath: frontend
144-
- mountPath: /etc/nginx/conf.d/backend.conf
145-
name: datamate-nginx-conf
146-
subPath: backend.conf
147154

148155
runtime:
149156
enabled: false
@@ -160,7 +167,10 @@ runtime:
160167
- name: MYSQL_USER
161168
value: "root"
162169
- name: MYSQL_PASSWORD
163-
value: *dbPass
170+
valueFrom:
171+
secretKeyRef:
172+
name: datamate-conf
173+
key: DB_PASSWORD
164174
- name: MYSQL_DATABASE
165175
value: "datamate"
166176
volumes:
@@ -207,15 +217,18 @@ ray-cluster:
207217
value: "0"
208218
- name: RAY_TQDM_PATCH_PRINT
209219
value: "0"
210-
- name: MYSQL_HOST
220+
- name: PG_HOST
211221
value: "datamate-database"
212-
- name: MYSQL_PORT
213-
value: "3306"
214-
- name: MYSQL_USER
215-
value: "root"
216-
- name: MYSQL_PASSWORD
217-
value: *dbPass
218-
- name: MYSQL_DATABASE
222+
- name: PG_PORT
223+
value: "5432"
224+
- name: PG_USER
225+
value: "postgres"
226+
- name: PG_PASSWORD
227+
valueFrom:
228+
secretKeyRef:
229+
name: datamate-conf
230+
key: DB_PASSWORD
231+
- name: PG_DATABASE
219232
value: "datamate"
220233
- name: RAY_enable_autoscaler_v2
221234
value: "1"
@@ -259,15 +272,18 @@ ray-cluster:
259272
value: "0"
260273
- name: RAY_TQDM_PATCH_PRINT
261274
value: "0"
262-
- name: MYSQL_HOST
275+
- name: PG_HOST
263276
value: "datamate-database"
264-
- name: MYSQL_PORT
265-
value: "3306"
266-
- name: MYSQL_USER
267-
value: "root"
268-
- name: MYSQL_PASSWORD
269-
value: *dbPass
270-
- name: MYSQL_DATABASE
277+
- name: PG_PORT
278+
value: "5432"
279+
- name: PG_USER
280+
value: "postgres"
281+
- name: PG_PASSWORD
282+
valueFrom:
283+
secretKeyRef:
284+
name: datamate-conf
285+
key: DB_PASSWORD
286+
- name: PG_DATABASE
271287
value: "datamate"
272288
resources:
273289
limits:
@@ -308,15 +324,18 @@ ray-cluster:
308324
value: "0"
309325
- name: RAY_TQDM_PATCH_PRINT
310326
value: "0"
311-
- name: MYSQL_HOST
327+
- name: PG_HOST
312328
value: "datamate-database"
313-
- name: MYSQL_PORT
314-
value: "3306"
315-
- name: MYSQL_USER
316-
value: "root"
317-
- name: MYSQL_PASSWORD
318-
value: *dbPass
319-
- name: MYSQL_DATABASE
329+
- name: PG_PORT
330+
value: "5432"
331+
- name: PG_USER
332+
value: "postgres"
333+
- name: PG_PASSWORD
334+
valueFrom:
335+
secretKeyRef:
336+
name: datamate-conf
337+
key: DB_PASSWORD
338+
- name: PG_DATABASE
320339
value: "datamate"
321340
- name: POD_NAME
322341
valueFrom:

scripts/images/database/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ COPY scripts/images/database/postgresql.cnf /etc/postgresql/postgresql.conf
1414

1515
COPY scripts/db/ /docker-entrypoint-initdb.d/
1616

17-
USER postgres
1817
CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]

scripts/images/frontend/Dockerfile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,23 @@ RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi && \
99

1010
FROM nginx:1.29 AS runner
1111

12-
COPY --from=builder /app/dist /opt/frontend
13-
COPY scripts/images/frontend/backend.conf /etc/nginx/conf.d/backend.conf
12+
RUN --mount=type=cache,target=/var/cache/apt \
13+
--mount=type=cache,target=/var/lib/apt \
14+
apt update \
15+
&& apt install -y dos2unix
1416

15-
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
17+
COPY --from=builder /app/dist /opt/frontend/statics
18+
COPY scripts/images/frontend/routes.inc /opt/frontend/routes.inc
19+
COPY scripts/images/frontend/http_backend.conf /opt/frontend/http_backend.conf
20+
COPY scripts/images/frontend/https_backend.conf /opt/frontend/https_backend.conf
21+
22+
COPY scripts/images/frontend/start.sh /opt/frontend/start.sh
23+
24+
RUN dos2unix /opt/frontend/start.sh \
25+
&& chmod +x /opt/frontend/start.sh \
26+
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
1627
&& rm -f /etc/nginx/conf.d/default.conf
1728

18-
EXPOSE 80
29+
EXPOSE 3000
1930

20-
CMD ["nginx", "-g", "daemon off;"]
31+
CMD ["/opt/frontend/start.sh"]

scripts/images/frontend/backend.conf

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
server {
2+
listen 3000;
3+
server_name 0.0.0.0;
4+
5+
access_log /var/log/datamate/frontend/access.log main;
6+
error_log /var/log/datamate/frontend/error.log notice;
7+
8+
client_max_body_size 1024M;
9+
10+
add_header Set-Cookie "NEXT_LOCALE=zh";
11+
12+
include /etc/nginx/conf.d/routes.inc;
13+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
server {
2+
listen 3000 ssl;
3+
server_name 0.0.0.0;
4+
5+
access_log /var/log/datamate/frontend/access.log main;
6+
error_log /var/log/datamate/frontend/error.log notice;
7+
8+
client_max_body_size 1024M;
9+
10+
ssl_certificate /etc/nginx/cert/server.crt;
11+
ssl_certificate_key /etc/nginx/cert/server.key;
12+
13+
error_page 497 https://$host$request_uri;
14+
15+
add_header Set-Cookie "NEXT_LOCALE=zh";
16+
17+
include /etc/nginx/conf.d/routes.inc;
18+
}

0 commit comments

Comments
 (0)