From 5223a30c690d79f7c3e3f3e443162748ea2139f6 Mon Sep 17 00:00:00 2001 From: fallensigh Date: Mon, 24 Aug 2026 00:19:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Docker=20=E6=97=B6=E5=8C=BA=E9=85=8D?= =?UTF-8?q?=E7=BD=AE(=E4=BF=9D=E7=95=99tzdata+ENV=20TZ)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 原 apk del tzdata 导致容器 UTC, 定时任务无法在 00:00 触发 - 保留 tzdata 并设置 ENV TZ=Asia/Shanghai (Go time 库依赖) Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- go/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/go/Dockerfile b/go/Dockerfile index 0598404..f217c41 100644 --- a/go/Dockerfile +++ b/go/Dockerfile @@ -12,10 +12,11 @@ RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o electric-mon # 阶段2: 最小运行镜像 FROM alpine:3.20 # 时区: 定时任务需按北京时间 00:00 触发 +# 保留 tzdata 并设置 TZ 环境变量 (Go time 库依赖它,apk del 会导致 UTC) +ENV TZ=Asia/Shanghai RUN apk add --no-cache tzdata \ && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && apk del tzdata + && echo "Asia/Shanghai" > /etc/timezone # 数据目录(历史记录 + 缓存挂载点) RUN mkdir -p /app/data WORKDIR /app