fix: 修复时区问题 - FixedZone 兜底 + Dockerfile 复制完整 zoneinfo
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 4m56s
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 4m56s
1. ppanel.go: LoadLocation 失败时用 FixedZone("CST", +8h) 兜底
2. Dockerfile: 复制完整 /usr/share/zoneinfo 目录,确保 go-sql-driver 也能加载 Asia/Shanghai
Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
parent
bafb13cf06
commit
9912df9ac6
@ -28,7 +28,7 @@ FROM scratch
|
||||
|
||||
# Copy CA certificates and timezone data
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
|
||||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
||||
|
||||
@ -8,12 +8,13 @@ import (
|
||||
|
||||
func init() {
|
||||
// Ensure time.Local matches DSN loc=Asia/Shanghai.
|
||||
// In scratch Docker images, Go defaults to UTC even with TZ set,
|
||||
// causing time range queries to shift by 8 hours.
|
||||
// In scratch Docker images, LoadLocation may fail due to missing zoneinfo,
|
||||
// so fall back to FixedZone as a guaranteed alternative.
|
||||
loc, err := time.LoadLocation("Asia/Shanghai")
|
||||
if err == nil {
|
||||
time.Local = loc
|
||||
if err != nil {
|
||||
loc = time.FixedZone("CST", 8*3600)
|
||||
}
|
||||
time.Local = loc
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user