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