diff --git a/Dockerfile b/Dockerfile index a7a550f..9ff220d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,26 @@ -# 使用阿里云镜像 -FROM registry.cn-hangzhou.aliyuncs.com/library/node:18-alpine +# 使用官方Node.js镜像作为基础镜像 +FROM node:18-alpine LABEL maintainer="hejiayu " +# 设置工作目录 WORKDIR /gitlink_help_center -# 设置 npm 和 yarn 使用淘宝镜像 -RUN npm config set registry https://registry.npmmirror.com -RUN yarn config set registry https://registry.npmmirror.com +# 设置npm和yarn使用淘宝镜像源,加快依赖安装速度 +RUN npm config set registry https://registry.npmmirror.com && \ + yarn config set registry https://registry.npmmirror.com -COPY ./ /gitlink_help_center/ +# 复制项目文件 +COPY package.json yarn.lock ./ +RUN yarn install --frozen-lockfile -RUN yarn install -RUN npm run build -- --locale zh-cn +# 复制其余项目文件 +COPY . . + +# 构建项目 +RUN yarn build --locale zh-cn + +# 暴露端口 +EXPOSE 3000 + +# 启动命令 CMD ["npm", "run", "serve"] \ No newline at end of file