fix: use origin method to compile

This commit is contained in:
fly6516 2025-03-03 23:38:47 +08:00
parent 17160193d6
commit eb4da92d13

View File

@ -1,10 +1,6 @@
# syntax=docker.io/docker/dockerfile:1 # syntax=docker.io/docker/dockerfile:1
FROM node:22-alpine AS base 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 FROM base AS deps
RUN sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirror.nju.edu.cn/alpine#g' /etc/apk/repositories && \ 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 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 \ RUN \
echo "开始安装依赖..." && \
if [ -f yarn.lock ]; then \ if [ -f yarn.lock ]; then \
yarn config set registry https://registry.npmmirror.com && \ yarn config set registry https://registry.npmmirror.com && \
yarn --frozen-lockfile; \ yarn --frozen-lockfile; \
@ -45,17 +40,21 @@ ENV NEXT_TELEMETRY_DISABLED=1
RUN \ RUN \
if [ -f yarn.lock ]; then yarn run build; \ if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \ elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then pnpm run build; \ elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
elif [ -f bun.lock ]; then bun 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 fi
FROM base AS runner FROM base AS runner
WORKDIR /app WORKDIR /app
RUN sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirror.nju.edu.cn/alpine#g' /etc/apk/repositories && \ 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 && \ apk add --no-cache curl
addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
ENV NODE_ENV=production ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1