From fdc0553cfb365724e1fd2851bfb40069d70238df Mon Sep 17 00:00:00 2001 From: Johnny Date: Sat, 19 Apr 2025 23:10:32 +0800 Subject: [PATCH] chore: move frontend build to action --- .../workflows/build-and-push-canary-image.yml | 15 +++++++++++++++ scripts/Dockerfile | 16 ++-------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-and-push-canary-image.yml b/.github/workflows/build-and-push-canary-image.yml index 1070f8501..460aa4919 100644 --- a/.github/workflows/build-and-push-canary-image.yml +++ b/.github/workflows/build-and-push-canary-image.yml @@ -57,6 +57,21 @@ jobs: username: ${{ github.actor }} password: ${{ github.token }} + # Frontend build. + - uses: pnpm/action-setup@v4.1.0 + with: + version: 10 + - uses: actions/setup-node@v4 + with: + node-version: "22" + cache: pnpm + cache-dependency-path: "web/pnpm-lock.yaml" + - run: pnpm install + working-directory: web + - name: Run frontend build + run: pnpm release + working-directory: web + - name: Build and Push id: docker_build uses: docker/build-push-action@v6 diff --git a/scripts/Dockerfile b/scripts/Dockerfile index 4f7945831..ccb21bcd6 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -1,21 +1,9 @@ -# Build frontend dist. -FROM node:20-alpine AS frontend -WORKDIR /frontend-build - -COPY . . - -WORKDIR /frontend-build/web - -RUN npm install -g pnpm -RUN pnpm i --frozen-lockfile -RUN pnpm build - -# Build backend exec file. FROM golang:1.24-alpine AS backend WORKDIR /backend-build COPY . . -COPY --from=frontend /frontend-build/web/dist /backend-build/server/router/frontend/dist +# Please build frontend first, so that the static files are available. +# Refer to `pnpm release` in package.json for the build command. RUN go build -o memos ./bin/memos/main.go