Update Dockerfile

This commit is contained in:
zzx-coder 2026-05-13 22:14:05 +08:00
parent 2471344b5f
commit d03d01d20f
1 changed files with 30 additions and 6 deletions

View File

@ -1,10 +1,34 @@
FROM node:18-alpine
FROM crpi-1x701qgqjia2gdeu.cn-chengdu.personal.cr.aliyuncs.com/gitlink-help-center/gitlink-help-center:node-20-alpine
LABEL maintainer="yuankaifneg <2894340009@qq.com>"
WORKDIR /gitlink_help_center
# 设置为root用户以安装系统依赖
USER root
COPY ./ /gitlink_help_center/
RUN yarn install
RUN npm run build -- --locale zh-cn
# 安装必要的系统依赖
RUN yum install -y \
git \
python3 \
make \
gcc-c++ \
bash && \
yum clean all
# 设置工作目录
WORKDIR /app
# 优先复制package.json和package-lock.json以利用Docker缓存
COPY package.json package-lock.json ./
# 安装依赖忽略peer依赖冲突
RUN npm install --legacy-peer-deps
# 复制项目文件
COPY . .
# 构建应用
RUN npm run build
# 暴露端口
EXPOSE 3000
# 设置环境变量
ENV NODE_ENV=production
ENV PORT=3000
# 健康检查
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# 启动应用
CMD ["npm", "run", "serve"]