Skip to content

Commit 15908c6

Browse files
author
w7years
committed
🔧 chore(Dockerfile): add tzdata and set timezone to Asia/Shanghai
✨ feat(logger): update logrus formatter to include full timestamps
1 parent 06b71fa commit 15908c6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Dockerfile

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o proxy ./cmd/proxy
1616
FROM alpine:latest
1717

1818
# 安装证书
19-
RUN apk --no-cache add ca-certificates
19+
RUN apk --no-cache add ca-certificates tzdata
20+
21+
# 设置默认时区为上海
22+
ENV TZ=Asia/Shanghai
2023

2124
# 设置工作目录
2225
WORKDIR /app
@@ -36,6 +39,9 @@ ENV PORT=3002
3639
COPY entrypoint.sh /app/entrypoint.sh
3740
RUN chmod +x /app/entrypoint.sh
3841

42+
# 设置时区
43+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
44+
3945
EXPOSE $PORT
4046

4147
# 设置入口点

pkg/logger/logger.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ func InitLogger(config *config.Config) {
4242

4343
Logger = logrus.New()
4444
Logger.SetOutput(fileAndStdoutWriter)
45-
Logger.SetFormatter(&logrus.TextFormatter{})
45+
Logger.SetFormatter(&logrus.TextFormatter{
46+
TimestampFormat: "2006-01-02 15:04:05",
47+
FullTimestamp: true,
48+
})
4649
Logger.SetLevel(level)
4750
Logger.SetReportCaller(true)
4851

0 commit comments

Comments
 (0)