Skip to content

Comments

Release 20251226#1

Merged
Aliothmoon merged 5 commits intomasterfrom
dev
Dec 25, 2025
Merged

Release 20251226#1
Aliothmoon merged 5 commits intomasterfrom
dev

Conversation

@Aliothmoon
Copy link
Collaborator

@Aliothmoon Aliothmoon commented Dec 25, 2025

Summary by Sourcery

为基于 Docker 的部署准备应用,并通过 GitHub Actions 实现镜像的自动构建与发布。

Build:

  • 将 Next.js 的输出切换为 standalone 以支持 Docker 部署,并移除图像优化相关配置。
  • 新增一个 Dockerfile,用于在容器中使用 Bun 运行构建后的 Next.js 应用。

CI:

  • 新增一个 GitHub Actions 工作流,在推送、打标签以及手动触发时构建并推送多架构 Docker 镜像到 GitHub Container Registry,替代之前的 Next.js 工作流。
Original summary in English

Summary by Sourcery

Prepare the application for Docker-based deployment and automate building and publishing images via GitHub Actions.

Build:

  • Switch Next.js output to standalone to support Docker deployment and remove image optimization configuration.
  • Add a Dockerfile to run the built Next.js app with Bun in a container.

CI:

  • Add a GitHub Actions workflow to build and push multi-architecture Docker images to GitHub Container Registry on pushes, tags, and manual runs, replacing the previous Next.js workflow.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了两个问题,并给出了一些更高层次的反馈:

  • 这个 Dockerfile 假设构建上下文中已经存在预先构建好的 .next/standalone.next/static;建议改为多阶段构建,在镜像内部运行 bun installbun run build,这样 docker build 就可以在隔离环境中独立工作,并且对本地构建步骤的依赖更小、更不脆弱。
  • image-release workflow 会为每个分支构建镜像(且在非 PR 情况下推送镜像),这可能会产生大量标签并导致镜像仓库变得很嘈杂;你可以考虑把推送/打标签逻辑限制在 main/release 等主分支上,其他分支只进行构建而不推送。
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The Dockerfile assumes a pre-built `.next/standalone` and `.next/static` in the build context; consider switching to a multi-stage build that runs `bun install` and `bun run build` inside the image so `docker build` works in isolation and is less fragile to local build steps.
- The image-release workflow builds (and for non-PRs pushes) images for every branch, which may generate a lot of tags and registry noise; you may want to restrict the push/tagging logic to main/release branches and keep other branches as build-only.

## Individual Comments

### Comment 1
<location> `Dockerfile:18` </location>
<code_context>
+ENV PORT=3000
+ENV HOSTNAME="0.0.0.0"
+
+CMD ["bun", "run", "server.js"]
\ No newline at end of file
</code_context>

<issue_to_address>
**issue (bug_risk):** 使用 Bun 而不是 Node 来运行 Next.js 的 standalone 服务器,可能会导致运行时不兼容问题。

`.next/standalone` 构建是专门为 Node.js 运行时定制的,而 `server.js` 通常依赖于 Node 特定的 API 和模块解析行为。Bun 并不能完全做到无缝替代(尤其是对原生依赖和某些 Node API),因此在运行时可能会失败。为避免这个风险,建议使用官方的 Node 镜像(例如 `node:20-alpine`)并通过 `node server.js` 启动;或者只有在验证该应用以及所有依赖在 Bun 的 standalone 模式下都能正常运行之后,才在这里使用 Bun。
</issue_to_address>

### Comment 2
<location> `.github/workflows/image-release.yml:3-10` </location>
<code_context>
+name: Build and Push Docker Image
+
+on:
+  push:
+    branches:
+      - '**'
+    tags:
+      - 'v*'
</code_context>

<issue_to_address>
**suggestion:** 为每个分支推送镜像会增加镜像仓库的噪音并消耗更多资源。

在 `branches: ['**']` 的配置下,只要是非 PR 的分支推送,就会构建并推送一个镜像,因此每个 feature/WIP 分支都会发布镜像到 GHCR,增加构建时间以及镜像仓库/存储的使用量。可以考虑把推送限制到默认分支和打标签的场景(例如 `branches: [main]`),同时如果需要的话,其他分支仍然可以只进行构建而不推送。

```suggestion
on:
  push:
    branches:
      - main
    tags:
      - 'v*'
  pull_request:
  workflow_dispatch:
```
</issue_to_address>

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,请考虑分享一下 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码评审。
Original comment in English

Hey - I've found 2 issues, and left some high level feedback:

  • The Dockerfile assumes a pre-built .next/standalone and .next/static in the build context; consider switching to a multi-stage build that runs bun install and bun run build inside the image so docker build works in isolation and is less fragile to local build steps.
  • The image-release workflow builds (and for non-PRs pushes) images for every branch, which may generate a lot of tags and registry noise; you may want to restrict the push/tagging logic to main/release branches and keep other branches as build-only.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The Dockerfile assumes a pre-built `.next/standalone` and `.next/static` in the build context; consider switching to a multi-stage build that runs `bun install` and `bun run build` inside the image so `docker build` works in isolation and is less fragile to local build steps.
- The image-release workflow builds (and for non-PRs pushes) images for every branch, which may generate a lot of tags and registry noise; you may want to restrict the push/tagging logic to main/release branches and keep other branches as build-only.

## Individual Comments

### Comment 1
<location> `Dockerfile:18` </location>
<code_context>
+ENV PORT=3000
+ENV HOSTNAME="0.0.0.0"
+
+CMD ["bun", "run", "server.js"]
\ No newline at end of file
</code_context>

<issue_to_address>
**issue (bug_risk):** Running the Next.js standalone server with Bun instead of Node may cause runtime incompatibilities.

The `.next/standalone` build is tailored for a Node.js runtime, and `server.js` typically relies on Node-specific APIs and resolution behavior. Bun is not fully drop-in compatible (notably for native dependencies and some Node APIs), so this may fail at runtime. To avoid this risk, prefer an official Node image (e.g. `node:20-alpine`) with `node server.js`, or only use Bun here after validating this app and all its dependencies under Bun in standalone mode.
</issue_to_address>

### Comment 2
<location> `.github/workflows/image-release.yml:3-10` </location>
<code_context>
+name: Build and Push Docker Image
+
+on:
+  push:
+    branches:
+      - '**'
+    tags:
+      - 'v*'
</code_context>

<issue_to_address>
**suggestion:** Pushing images for every branch can increase registry noise and resource usage.

With `branches: ['**']`, any non-PR branch push will build and push an image, so every feature/WIP branch will publish to GHCR, increasing build time and registry/storage usage. Consider limiting pushes to the default branch and tags (e.g. `branches: [main]`) while still allowing non-pushing builds on other branches if desired.

```suggestion
on:
  push:
    branches:
      - main
    tags:
      - 'v*'
  pull_request:
  workflow_dispatch:
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

ENV PORT=3000
ENV HOSTNAME="0.0.0.0"

CMD ["bun", "run", "server.js"] No newline at end of file
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): 使用 Bun 而不是 Node 来运行 Next.js 的 standalone 服务器,可能会导致运行时不兼容问题。

.next/standalone 构建是专门为 Node.js 运行时定制的,而 server.js 通常依赖于 Node 特定的 API 和模块解析行为。Bun 并不能完全做到无缝替代(尤其是对原生依赖和某些 Node API),因此在运行时可能会失败。为避免这个风险,建议使用官方的 Node 镜像(例如 node:20-alpine)并通过 node server.js 启动;或者只有在验证该应用以及所有依赖在 Bun 的 standalone 模式下都能正常运行之后,才在这里使用 Bun。

Original comment in English

issue (bug_risk): Running the Next.js standalone server with Bun instead of Node may cause runtime incompatibilities.

The .next/standalone build is tailored for a Node.js runtime, and server.js typically relies on Node-specific APIs and resolution behavior. Bun is not fully drop-in compatible (notably for native dependencies and some Node APIs), so this may fail at runtime. To avoid this risk, prefer an official Node image (e.g. node:20-alpine) with node server.js, or only use Bun here after validating this app and all its dependencies under Bun in standalone mode.

Comment on lines +3 to +10
on:
push:
branches:
- '**'
tags:
- 'v*'
pull_request:
workflow_dispatch:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: 为每个分支推送镜像会增加镜像仓库的噪音并消耗更多资源。

branches: ['**'] 的配置下,只要是非 PR 的分支推送,就会构建并推送一个镜像,因此每个 feature/WIP 分支都会发布镜像到 GHCR,增加构建时间以及镜像仓库/存储的使用量。可以考虑把推送限制到默认分支和打标签的场景(例如 branches: [main]),同时如果需要的话,其他分支仍然可以只进行构建而不推送。

Suggested change
on:
push:
branches:
- '**'
tags:
- 'v*'
pull_request:
workflow_dispatch:
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
workflow_dispatch:
Original comment in English

suggestion: Pushing images for every branch can increase registry noise and resource usage.

With branches: ['**'], any non-PR branch push will build and push an image, so every feature/WIP branch will publish to GHCR, increasing build time and registry/storage usage. Consider limiting pushes to the default branch and tags (e.g. branches: [main]) while still allowing non-pushing builds on other branches if desired.

Suggested change
on:
push:
branches:
- '**'
tags:
- 'v*'
pull_request:
workflow_dispatch:
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
workflow_dispatch:

@Aliothmoon Aliothmoon merged commit c55788d into master Dec 25, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant