feat(docker): 安装 tzdata 并设置 TZ=Asia/Shanghai 以让 Node.js 使用上海时区

This commit is contained in:
2025-08-02 10:49:24 +08:00
parent bb25928a8e
commit 77030cc8fc
7 changed files with 47 additions and 21 deletions

View File

@@ -1,14 +1,13 @@
FROM node:20-alpine
# Set timezone to Asia/Shanghai FIRST
# This ensures that any native modules compiled during npm install are linked correctly.
RUN apk add --no-cache tzdata
ENV TZ=Asia/Shanghai
WORKDIR /usr/src/app
COPY package*.json ./
# Set timezone to Asia/Shanghai
RUN apk add --no-cache tzdata
ENV TZ=Asia/Shanghai
ENV NODE_ENV=production
RUN npm install
COPY . .
@@ -23,4 +22,4 @@ EXPOSE 25
# ENV DB_PASSWORD=...
# ENV DB_NAME=...
CMD [ "node", "app.js" ]
CMD [ "node", "app.js" ]