diff --git a/trading_assistant_api/common/logger/logger.go b/trading_assistant_api/common/logger/logger.go index 52e4bfa..877e3fc 100644 --- a/trading_assistant_api/common/logger/logger.go +++ b/trading_assistant_api/common/logger/logger.go @@ -72,7 +72,14 @@ func SetupTimezone(tz string) error { } loc, err := time.LoadLocation(tz) if err != nil { - return err + // fallback for alpine without tzdata + switch tz { + case "Asia/Shanghai", "PRC", "CST": + time.Local = time.FixedZone("CST", 8*3600) + return nil + default: + return err + } } time.Local = loc return nil diff --git a/trading_assistant_api/services/country/Dockerfile b/trading_assistant_api/services/country/Dockerfile index ca12f9e..57a3f59 100644 --- a/trading_assistant_api/services/country/Dockerfile +++ b/trading_assistant_api/services/country/Dockerfile @@ -12,7 +12,8 @@ RUN cd services/country && go mod download RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /workspace/bin/country-service ./services/country FROM alpine:3.19 -RUN adduser -D -u 10002 app +RUN apk add --no-cache tzdata && adduser -D -u 10002 app +ENV TZ=Asia/Shanghai USER app COPY --from=builder /workspace/bin/country-service /usr/local/bin/country-service EXPOSE 8081 diff --git a/trading_assistant_api/services/user/Dockerfile b/trading_assistant_api/services/user/Dockerfile index 56557e8..17ef49e 100644 --- a/trading_assistant_api/services/user/Dockerfile +++ b/trading_assistant_api/services/user/Dockerfile @@ -12,7 +12,8 @@ RUN cd services/user && go mod download RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /workspace/bin/user-service ./services/user FROM alpine:3.19 -RUN adduser -D -u 10001 app +RUN apk add --no-cache tzdata && adduser -D -u 10001 app +ENV TZ=Asia/Shanghai USER app COPY --from=builder /workspace/bin/user-service /usr/local/bin/user-service EXPOSE 8080