Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Y80
bmm
Repository navigation
Code
Issues
2
(2)
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
bmm
/
Dockerfile
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
48 lines (37 loc) · 1.64 KB
main
Breadcrumbs
bmm
/
Dockerfile
Copy path
Top
File metadata and controls
Code
Blame
48 lines (37 loc) · 1.64 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Next 配置 output: standalone 可以减少镜像大小,因为它只会把用到的依赖打包到 .next/standalone/node_modules 下
# 但是还有一些重要依赖不会被打包,比如 zx、drizzle-kit 等,它们只有手动执行相关 scripts 才会被用到,不属于 Next 应用的一部分
# 已经尝试使用 COPY 手动复制这些依赖,但是很麻烦而且不好维护
# 所以还是使用普通的 output 模式,通过手动删除不必要的文件,可控制镜像大小仅增加 ~300Mb
FROM node:24-alpine AS base
RUN corepack enable && pnpm -v
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json pnpm-lock.yaml .npmrc .
RUN pnpm install --frozen-lockfile
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# docker 构建镜像时不需要预先配置数据库,所以不需要执行 db-init 脚本,这里直接 next build 就行
# 忽略构建错误,因为在 Github Action 中构建时,全是静态的类型检查会导致一些错误
RUN export IGNORE_BUILD_ERRORS=true && pnpm next build && pnpm prune --prod
# 清理一些体积较大的、运行时不需要的文件
RUN rm -rf doc .next/cache .next/trace \
node_modules/.pnpm/@types+* \
node_modules/.pnpm/caniuse* \
node_modules/.pnpm/@ant-design+icons* \
node_modules/.pnpm/vite* \
node_modules/.pnpm/typescript@* \
node_modules/.pnpm/eslint*
RUN find node_modules/.pnpm/ -type f -name "*.ts" -delete
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# zx 依赖 bash
RUN apk add bash
COPY --from=builder /app .
EXPOSE 3000
CMD ["pnpm", "run", "start"]
You can’t perform that action at this time.