diff --git a/Dockerfile b/Dockerfile index ea8ac03..4bab5c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,11 +17,14 @@ WORKDIR /app ENV NODE_ENV=production \ PYTHONDONTWRITEBYTECODE=1 \ - PYTHONUNBUFFERED=1 + PYTHONUNBUFFERED=1 \ + TZ=Asia/Shanghai -# Alpine 使用国内镜像,加速 apk 安装(python3/py3-pip) +# Alpine 使用国内镜像,加速 apk 安装(python3/py3-pip)并设置时区为 Asia/Shanghai(与宿主机保持一致) RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ - && apk add --no-cache python3 py3-pip + && apk add --no-cache python3 py3-pip tzdata \ + && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone COPY --from=build /app/node_modules ./node_modules COPY --from=build /app/dist ./dist diff --git a/backend/Dockerfile b/backend/Dockerfile index 7c69ae8..b84dee5 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -3,11 +3,16 @@ FROM docker.m.daocloud.io/library/python:3.11-slim WORKDIR /app ENV PYTHONDONTWRITEBYTECODE=1 \ - PYTHONUNBUFFERED=1 + PYTHONUNBUFFERED=1 \ + TZ=Asia/Shanghai COPY backend/requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt +RUN apt-get update && apt-get install -y --no-install-recommends tzdata \ + && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone \ + && pip install --no-cache-dir -r requirements.txt \ + && apt-get clean && rm -rf /var/lib/apt/lists/* COPY backend ./backend diff --git a/public/index.html b/public/index.html index 91132bb..c538ab4 100644 --- a/public/index.html +++ b/public/index.html @@ -808,7 +808,8 @@ async function checkHealth() { try { - const res = await fetch('/health', { cache: 'no-store' }); + // 通过 /api/ws-status 检测后端是否可用(同时避免某些部署环境未透出 /health) + const res = await fetch('/api/ws-status', { cache: 'no-store' }); if (!res.ok) throw new Error('status ' + res.status); const data = await res.json().catch(() => ({})); $('health-dot').style.background = '#22c55e';