From 59363fcf0cee7a89b647fbb6481cbc481ea9085d Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Wed, 23 Oct 2024 14:49:58 +0800 Subject: [PATCH 1/3] perf: remvoe qemu --- .github/workflows/Deploy.yml | 9 ++++++--- Dockerfile | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/Deploy.yml b/.github/workflows/Deploy.yml index 76be8c1..36cbcae 100644 --- a/.github/workflows/Deploy.yml +++ b/.github/workflows/Deploy.yml @@ -18,11 +18,10 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + driver-opts: network=host - name: Login to Docker Hub uses: docker/login-action@v3 @@ -56,6 +55,10 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:cache + cache-to: type=inline + build-args: | + BUILDKIT_INLINE_CACHE=1 changelog: name: Generate Changelog diff --git a/Dockerfile b/Dockerfile index 776669f..3e51729 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,20 @@ -FROM oven/bun:1 AS base +FROM --platform=$BUILDPLATFORM oven/bun:1 as base # Stage 1: Install dependencies FROM base AS deps WORKDIR /app COPY package.json bun.lockb ./ -RUN bun install --frozen-lockfile +RUN --mount=type=cache,target=/root/.bun bun install --frozen-lockfile # Stage 2: Build the application FROM base AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . -RUN bun run build +RUN --mount=type=cache,target=/root/.bun bun run build # Stage 3: Production image -FROM oven/bun:1-alpine AS runner +FROM --platform=$TARGETPLATFORM oven/bun:1-alpine AS runner WORKDIR /app ENV NODE_ENV=production COPY --from=builder /app/public ./public From 7e182ed6eb4d0e7b7570c82504d5d602c572bd68 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Wed, 23 Oct 2024 14:53:41 +0800 Subject: [PATCH 2/3] fix: docker build cache --- .github/workflows/Deploy.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Deploy.yml b/.github/workflows/Deploy.yml index 36cbcae..67b0929 100644 --- a/.github/workflows/Deploy.yml +++ b/.github/workflows/Deploy.yml @@ -18,6 +18,10 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + # 移除 QEMU 设置步骤,因为我们不再需要模拟 + # - name: Set up QEMU + # uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: @@ -57,8 +61,6 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:cache cache-to: type=inline - build-args: | - BUILDKIT_INLINE_CACHE=1 changelog: name: Generate Changelog From c5e33b08b6c29446a93a85a028014a88d2446d5e Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Wed, 23 Oct 2024 15:23:19 +0800 Subject: [PATCH 3/3] fix: buildkit warning --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3e51729..9be7c19 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=$BUILDPLATFORM oven/bun:1 as base +FROM --platform=$BUILDPLATFORM oven/bun:1 AS base # Stage 1: Install dependencies FROM base AS deps @@ -14,7 +14,7 @@ COPY . . RUN --mount=type=cache,target=/root/.bun bun run build # Stage 3: Production image -FROM --platform=$TARGETPLATFORM oven/bun:1-alpine AS runner +FROM oven/bun:1-alpine AS runner WORKDIR /app ENV NODE_ENV=production COPY --from=builder /app/public ./public