修复工作
This commit is contained in:
@@ -73,25 +73,19 @@ services:
|
|||||||
BACKEND_API_URL: http://localhost:${BACKEND_PORT}
|
BACKEND_API_URL: http://localhost:${BACKEND_PORT}
|
||||||
container_name: rtsp-frontend
|
container_name: rtsp-frontend
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
network_mode: "host"
|
||||||
- "${FRONTEND_PORT}:80"
|
|
||||||
depends_on:
|
depends_on:
|
||||||
backend:
|
backend:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
environment:
|
environment:
|
||||||
TZ: ${TZ}
|
TZ: ${TZ}
|
||||||
networks:
|
NGINX_PORT: ${FRONTEND_PORT}
|
||||||
- rtsp-network
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:80"]
|
test: ["CMD", "curl", "-f", "http://localhost:${FRONTEND_PORT}"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|
||||||
networks:
|
|
||||||
rtsp-network:
|
|
||||||
driver: bridge
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
redis-data:
|
redis-data:
|
||||||
backend-logs:
|
backend-logs:
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ RUN npm run build:prod
|
|||||||
# 运行阶段
|
# 运行阶段
|
||||||
FROM nginx:1.25-alpine
|
FROM nginx:1.25-alpine
|
||||||
|
|
||||||
# 安装curl用于健康检查
|
# 安装curl和envsubst用于健康检查和环境变量替换
|
||||||
RUN apk add --no-cache curl
|
RUN apk add --no-cache curl gettext
|
||||||
|
|
||||||
# 删除默认nginx配置
|
# 删除默认nginx配置
|
||||||
RUN rm -rf /etc/nginx/conf.d/*
|
RUN rm -rf /etc/nginx/conf.d/*
|
||||||
@@ -37,9 +37,5 @@ COPY --from=builder /app/dist /usr/share/nginx/html
|
|||||||
# 暴露端口
|
# 暴露端口
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
# 健康检查
|
# 使用envsubst替换环境变量,然后启动Nginx
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
|
CMD sh -c "envsubst '\$NGINX_PORT' < /etc/nginx/conf.d/default.conf > /tmp/nginx.conf && mv /tmp/nginx.conf /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
|
||||||
CMD curl -f http://localhost:80 || exit 1
|
|
||||||
|
|
||||||
# 启动Nginx
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen ${NGINX_PORT} default_server;
|
||||||
server_name localhost;
|
listen [::]:${NGINX_PORT} default_server;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
# 前端资源
|
# 前端资源
|
||||||
location / {
|
location / {
|
||||||
|
|||||||
Reference in New Issue
Block a user