-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
79 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [14.x, 16.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm ci | ||
- run: npm run build --if-present | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 使用 Node.js 官方镜像作为构建环境 | ||
FROM node:alpine as builder | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 复制 package.json 和 package-lock.json (或 yarn.lock) | ||
COPY package*.json ./ | ||
# 如果使用yarn,并有yarn.lock文件,也可以复制 | ||
# COPY package.json yarn.lock ./ | ||
|
||
# 安装项目依赖 | ||
RUN npm install | ||
# 如果使用 yarn,可以用 RUN yarn install 代替 | ||
|
||
# 复制项目文件到工作目录 | ||
COPY . . | ||
|
||
# 构建应用 | ||
RUN npm run build | ||
|
||
# 使用 Node.js 镜像运行应用 | ||
FROM node:alpine | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 只复制构建产出和package.json到新的镜像中 | ||
COPY --from=builder /app/.next ./.next | ||
COPY --from=builder /app/node_modules ./node_modules | ||
COPY --from=builder /app/package.json ./package.json | ||
|
||
# 暴露端口 | ||
EXPOSE 3000 | ||
|
||
# 启动 Next.js 应用 | ||
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters