From eb4da92d13e592707ef32ba93deec723d8cc9dcc Mon Sep 17 00:00:00 2001 From: fly6516 Date: Mon, 3 Mar 2025 23:38:47 +0800 Subject: [PATCH] fix: use origin method to compile --- Dockerfile.cn | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Dockerfile.cn b/Dockerfile.cn index 0db1fb3..dd89670 100644 --- a/Dockerfile.cn +++ b/Dockerfile.cn @@ -1,10 +1,6 @@ # syntax=docker.io/docker/dockerfile:1 FROM node:22-alpine AS base -# 全局配置淘宝镜像源 -RUN npm config set registry https://registry.npmmirror.com && \ - sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirror.nju.edu.cn/alpine#g' /etc/apk/repositories - FROM base AS deps RUN sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirror.nju.edu.cn/alpine#g' /etc/apk/repositories && \ apk add --no-cache libc6-compat @@ -14,7 +10,6 @@ COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* bun.lock* .npmrc # 统一配置所有包管理器使用淘宝源 RUN \ - echo "开始安装依赖..." && \ if [ -f yarn.lock ]; then \ yarn config set registry https://registry.npmmirror.com && \ yarn --frozen-lockfile; \ @@ -44,18 +39,22 @@ ENV NEXT_TELEMETRY_DISABLED=1 # 合并构建命令 RUN \ if [ -f yarn.lock ]; then yarn run build; \ - elif [ -f package-lock.json ]; then npm run build; \ - elif [ -f pnpm-lock.yaml ]; then pnpm run build; \ - elif [ -f bun.lock ]; then bun run build; \ - fi + elif [ -f package-lock.json ]; then npm run build; \ + elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ + elif [ -f bun.lock ]; then \ + apk add --no-cache curl bash && \ + curl -fsSL https://bun.sh/install | bash && \ + export BUN_INSTALL="$HOME/.bun" && \ + export PATH="$BUN_INSTALL/bin:$PATH" && \ + bun run build; \ + else echo "Lockfile not found." && exit 1; \ + fi FROM base AS runner WORKDIR /app RUN sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirror.nju.edu.cn/alpine#g' /etc/apk/repositories && \ - apk add --no-cache curl && \ - addgroup --system --gid 1001 nodejs && \ - adduser --system --uid 1001 nextjs + apk add --no-cache curl ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1