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/8] 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/8] 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/8] 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 From e1a2a2dfe1265e6c1c915fc1da4a62377652d851 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Wed, 23 Oct 2024 16:42:49 +0800 Subject: [PATCH 4/8] perf: remove remote cache --- .github/workflows/Deploy.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/Deploy.yml b/.github/workflows/Deploy.yml index 67b0929..3f7969b 100644 --- a/.github/workflows/Deploy.yml +++ b/.github/workflows/Deploy.yml @@ -18,10 +18,6 @@ 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: @@ -59,8 +55,6 @@ 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 changelog: name: Generate Changelog From 0cfebd9773b9f5a7c0ea8a885e73e699b705d73b Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Wed, 23 Oct 2024 17:28:15 +0800 Subject: [PATCH 5/8] perf: remove cache mount --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9be7c19..e739a9a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,14 +4,14 @@ FROM --platform=$BUILDPLATFORM oven/bun:1 AS base FROM base AS deps WORKDIR /app COPY package.json bun.lockb ./ -RUN --mount=type=cache,target=/root/.bun bun install --frozen-lockfile +RUN 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 --mount=type=cache,target=/root/.bun bun run build +RUN bun run build # Stage 3: Production image FROM oven/bun:1-alpine AS runner From f2211a418c91d2ef5cf7d4da1c5fb1026788fdc6 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Thu, 24 Oct 2024 10:41:29 +0800 Subject: [PATCH 6/8] feat: use antfu/changelogithub --- .github/workflows/Deploy.yml | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/.github/workflows/Deploy.yml b/.github/workflows/Deploy.yml index 3f7969b..9d58d2b 100644 --- a/.github/workflows/Deploy.yml +++ b/.github/workflows/Deploy.yml @@ -56,30 +56,19 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - changelog: - name: Generate Changelog + release: runs-on: ubuntu-latest - needs: build-and-push - outputs: - release_body: ${{ steps.git-cliff.outputs.content }} steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Generate a changelog - uses: orhun/git-cliff-action@v4 - id: git-cliff + + - name: Set node + uses: actions/setup-node@v4 with: - config: git-cliff-config/cliff.toml - args: -vv --latest --strip 'footer' + registry-url: https://registry.npmjs.org/ + node-version: lts/* + + - run: npx changelogithub env: - OUTPUT: CHANGES.md - - name: Release - uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') - with: - body: ${{ steps.git-cliff.outputs.content }} - token: ${{ secrets.GITHUB_TOKEN }} - env: - GITHUB_REPOSITORY: ${{ github.repository }} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From 7656bbe319fb8ea25f2f7536e3697a0f70752708 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Thu, 24 Oct 2024 12:00:27 +0800 Subject: [PATCH 7/8] feat: add version tag --- app/[locale]/(main)/footer.tsx | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/[locale]/(main)/footer.tsx b/app/[locale]/(main)/footer.tsx index 7d2fb36..ce8334e 100644 --- a/app/[locale]/(main)/footer.tsx +++ b/app/[locale]/(main)/footer.tsx @@ -1,7 +1,9 @@ +import pack from "@/package.json"; import { useTranslations } from "next-intl"; export default function Footer() { const t = useTranslations("Footer"); + const version = pack.version; return (