适配最新的食谱
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
# next.js
|
# next.js
|
||||||
/.next/
|
/.next/
|
||||||
/out/
|
/out/
|
||||||
|
.idea
|
||||||
|
|
||||||
# production
|
# production
|
||||||
/build
|
/build
|
||||||
|
|||||||
+24
-16
@@ -2,25 +2,33 @@ version: 43
|
|||||||
jobs:
|
jobs:
|
||||||
- name: 构建项目
|
- name: 构建项目
|
||||||
steps:
|
steps:
|
||||||
|
# 步骤1:从代码仓库拉取源代码
|
||||||
- type: CheckoutStep
|
- type: CheckoutStep
|
||||||
name: 拉取代码
|
name: 拉取代码
|
||||||
cloneCredential:
|
cloneCredential:
|
||||||
type: DefaultCredential
|
type: DefaultCredential # 使用默认凭证(当前用户权限)
|
||||||
withLfs: false
|
withLfs: false # 不拉取 LFS 大文件
|
||||||
withSubmodules: false
|
withSubmodules: false # 不拉取子模块
|
||||||
checkoutPath: '@project_path@'
|
checkoutPath: '@project_path@' # 检出到项目路径变量指定的位置
|
||||||
condition: SUCCESSFUL
|
condition: SUCCESSFUL # 当前置步骤成功时执行
|
||||||
optional: false
|
optional: false # 此步骤不可跳过
|
||||||
|
|
||||||
|
# 步骤2:构建并推送 Docker 镜像
|
||||||
- type: BuildImageStep
|
- type: BuildImageStep
|
||||||
name: 构建docker镜像
|
name: 构建docker镜像
|
||||||
buildPath: '@project_path@'
|
buildPath: '@project_path@' # 构建上下文路径(项目根目录)
|
||||||
output:
|
output:
|
||||||
type: RegistryOutput
|
type: RegistryOutput # 输出类型:推送到镜像仓库
|
||||||
tags: latest
|
tags: '@server@/recipe_tool/recipe_tool:latest' # 镜像标签格式:服务器地址/项目名/镜像名:版本
|
||||||
condition: SUCCESSFUL
|
registryLogins: # 镜像仓库登录配置
|
||||||
optional: false
|
- registryUrl: https://git.hanhan.ltd # 仓库地址(带协议)
|
||||||
jobExecutor: docker
|
userName: '@job_token@' # 用户名使用内置任务令牌
|
||||||
retryCondition: never
|
passwordSecret: docker-push # 密码使用自定义密钥(需提前在 Job Secrets 中创建)
|
||||||
maxRetries: 3
|
condition: SUCCESSFUL # 当前置步骤成功时执行
|
||||||
retryDelay: 30
|
optional: false # 此步骤不可跳过
|
||||||
timeout: 14400
|
|
||||||
|
jobExecutor: docker # 使用 Docker 执行器运行此任务
|
||||||
|
retryCondition: never # 失败时不自动重试
|
||||||
|
maxRetries: 3 # 最大重试次数(因 retryCondition: never 实际无效)
|
||||||
|
retryDelay: 30 # 重试间隔时间(秒)
|
||||||
|
timeout: 14400 # 任务超时时间(4小时)
|
||||||
+8
-6
@@ -7,17 +7,21 @@ WORKDIR /app
|
|||||||
# 国内镜像加速
|
# 国内镜像加速
|
||||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||||
|
|
||||||
|
# 安装 pnpm(不使用 corepack)
|
||||||
|
RUN npm install -g pnpm
|
||||||
|
|
||||||
COPY package.json pnpm-lock.yaml ./
|
COPY package.json pnpm-lock.yaml ./
|
||||||
|
|
||||||
# 国内源 + 快速启用 pnpm
|
# 设置国内镜像源
|
||||||
RUN corepack enable && \
|
RUN npm config set registry https://registry.npmmirror.com && \
|
||||||
npm config set registry https://registry.npmmirror.com && \
|
|
||||||
pnpm config set registry https://registry.npmmirror.com
|
pnpm config set registry https://registry.npmmirror.com
|
||||||
|
|
||||||
|
# 安装依赖
|
||||||
RUN pnpm install --frozen-lockfile
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# 构建项目
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
|
|
||||||
# Stage 2: Runner
|
# Stage 2: Runner
|
||||||
@@ -39,13 +43,11 @@ COPY --from=builder /app/public ./public
|
|||||||
COPY --from=builder /app/.next/standalone ./
|
COPY --from=builder /app/.next/standalone ./
|
||||||
COPY --from=builder /app/.next/static ./.next/static
|
COPY --from=builder /app/.next/static ./.next/static
|
||||||
|
|
||||||
# ===================== 修复权限错误 =====================
|
# 复制配置文件
|
||||||
# 复制项目根目录的配置文件
|
|
||||||
COPY --from=builder /app/config.json ./
|
COPY --from=builder /app/config.json ./
|
||||||
|
|
||||||
# 给 nextjs 用户授权整个目录
|
# 给 nextjs 用户授权整个目录
|
||||||
RUN chown -R nextjs:nodejs /app
|
RUN chown -R nextjs:nodejs /app
|
||||||
# ========================================================
|
|
||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user