From 3d024477f9d47df781c6c305b1f8a1ccbf5c937e Mon Sep 17 00:00:00 2001 From: lixin Date: Fri, 10 Jan 2025 14:44:51 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E6=9B=B4=E6=96=B0=20Docker=20?= =?UTF-8?q?=E9=95=9C=E5=83=8F=E5=B9=B6=E8=AE=BE=E7=BD=AE=20npm=20=E9=95=9C?= =?UTF-8?q?=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 Dockerfile 中的 Node.js 镜像从阿里云镜像更新为官方 Node.js 镜像 - 在构建和运行阶段添加 npm 镜像设置,使用国内镜像源 - 更新 .drone.yml 文件,将 Docker 插件镜像改为 plugins/docker --- .drone.yml | 2 +- Dockerfile | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 74f4dc2..1f7efeb 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4,7 +4,7 @@ name: default steps: - name: build - image: registry.cn-hangzhou.aliyuncs.com/library/docker:latest + image: plugins/docker settings: dockerfile: Dockerfile dry_run: true diff --git a/Dockerfile b/Dockerfile index 9cd3414..38f4ed6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,12 @@ # 构建阶段 -FROM registry.cn-hangzhou.aliyuncs.com/library/node:18-alpine AS builder +FROM node:18-alpine AS builder WORKDIR /app COPY package.json . COPY package-lock.json* . +# 设置npm镜像 RUN npm config set registry https://registry.npmmirror.com/ && \ npm install @@ -14,7 +15,7 @@ COPY . . RUN npm run build # 运行阶段 -FROM registry.cn-hangzhou.aliyuncs.com/library/node:18-alpine +FROM node:18-alpine WORKDIR /app @@ -22,6 +23,7 @@ COPY --from=builder /app/dist ./dist COPY --from=builder /app/package.json . COPY --from=builder /app/bootstrap.js . +# 设置npm镜像 RUN npm config set registry https://registry.npmmirror.com/ && \ npm install --production