ci: node 24 + per-platform jobs (linux-amd64, linux-arm64, win64)
- Dockerfile/Dockerfile.windows: node 20 → 24 - 3 parallel jobs: linux/amd64, linux/arm64 (buildx, -arch tags), win64 (windows-latest native Windows containers, :next-windows) - winarm64 dropped (no official Windows ARM64 node base image)
This commit is contained in:
1 parent
cc90c93673
commit
1cfc61ff45
3 files changed
+52
-40
No files matched your search
@@ -11,27 +11,20 @@ env:
|
|||||||
IMAGE_NAME: ${{ github.repository }}
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
linux-amd64:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
- uses: docker/setup-buildx-action@v3
|
||||||
|
- uses: docker/login-action@v3
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Login to GHCR
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Metadata
|
||||||
- name: Extract metadata (tags, labels)
|
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
@@ -39,49 +32,68 @@ jobs:
|
|||||||
tags: |
|
tags: |
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
type=sha,prefix=git-
|
type=sha,prefix=git-
|
||||||
|
- name: Build & push linux/amd64
|
||||||
- name: Build and push (linux/amd64 + linux/arm64)
|
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64, linux/arm64
|
platforms: linux/amd64
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}-amd64
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha,scope=amd64
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max,scope=amd64
|
||||||
|
|
||||||
# Windows 容器镜像(windowsservercore):需要在 Windows runner 上
|
linux-arm64:
|
||||||
# 切换 Windows 容器引擎后原生 docker build(buildx 不支持交叉构建 Windows 容器)
|
runs-on: ubuntu-latest
|
||||||
windows:
|
|
||||||
runs-on: windows-latest
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
- uses: docker/setup-buildx-action@v3
|
||||||
|
- uses: docker/login-action@v3
|
||||||
- name: Login to GHCR
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Metadata
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=sha,prefix=git-
|
||||||
|
- name: Build & push linux/arm64
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/arm64
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}-arm64
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha,scope=arm64
|
||||||
|
cache-to: type=gha,mode=max,scope=arm64
|
||||||
|
|
||||||
- name: Switch Docker to Windows containers
|
win64:
|
||||||
shell: pwsh
|
runs-on: windows-latest
|
||||||
run: |
|
permissions:
|
||||||
& "$env:ProgramFiles\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine
|
contents: read
|
||||||
|
packages: write
|
||||||
- name: Build Windows image
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
# windows-latest runner 原生以 Windows 容器模式运行 Docker Engine
|
||||||
|
- name: Build Windows image (amd64)
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
docker build -f Dockerfile.windows -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:next-windows .
|
docker build -f Dockerfile.windows -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:next-windows .
|
||||||
|
|
||||||
- name: Push Windows image
|
- name: Push Windows image
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@
|
|||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
# ---- 构建阶段 ----
|
# ---- 构建阶段 ----
|
||||||
FROM node:20-windowsservercore-ltsc2022 AS builder
|
FROM node:24-windowsservercore-ltsc2022 AS builder
|
||||||
WORKDIR C:/app
|
WORKDIR C:/app
|
||||||
ENV DOCKER=1
|
ENV DOCKER=1
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ COPY . .
|
|||||||
RUN bun run build
|
RUN bun run build
|
||||||
|
|
||||||
# ---- 运行阶段 ----
|
# ---- 运行阶段 ----
|
||||||
FROM node:20-windowsservercore-ltsc2022
|
FROM node:24-windowsservercore-ltsc2022
|
||||||
WORKDIR C:/app
|
WORKDIR C:/app
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -3,7 +3,7 @@
|
|||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
# ---- 构建阶段 ----
|
# ---- 构建阶段 ----
|
||||||
FROM node:20-alpine AS builder
|
FROM node:24-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV DOCKER=1
|
ENV DOCKER=1
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ COPY . .
|
|||||||
RUN bun run build
|
RUN bun run build
|
||||||
|
|
||||||
# ---- 运行阶段 ----
|
# ---- 运行阶段 ----
|
||||||
FROM node:20-alpine AS runner
|
FROM node:24-alpine AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user