From 421f64ff111dcea0a8f2fdfc6acbea483dc15518 Mon Sep 17 00:00:00 2001 From: Nathan Date: Fri, 4 Jul 2025 15:12:14 +0800 Subject: [PATCH] chore: build web docker image --- .dockerignore | 39 ++++++++++++++ .github/workflows/web_docker.yml | 87 ++++++++++++++++++++++++++++++++ Dockerfile | 17 +++++++ 3 files changed, 143 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/web_docker.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..65b0377a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,39 @@ +# Git +.git +.gitignore +.github + +# Node +node_modules +npm-debug.log +yarn-error.log + +# Build outputs +dist +build +.next +.nuxt + +# Testing +cypress +__mocks__ +coverage +.nyc_output + +# Development +.vscode +.idea +*.log +.env.local +.env.development +.env.test + +# Documentation +*.md +LICENSE +doc + +# Docker +Dockerfile +.dockerignore +docker-compose*.yml \ No newline at end of file diff --git a/.github/workflows/web_docker.yml b/.github/workflows/web_docker.yml new file mode 100644 index 00000000..9bd68740 --- /dev/null +++ b/.github/workflows/web_docker.yml @@ -0,0 +1,87 @@ +name: AppFlowy Web image build and push +on: + workflow_dispatch: + inputs: + version: + description: 'AppFlowy Web version' + required: true +env: + IMAGE_NAME: ${{ secrets.DOCKER_HUB_USERNAME }}/appflowy_web +jobs: + build: + runs-on: ubuntu-24.04 + strategy: + matrix: + platform: + - linux/amd64 + - linux/arm64 + steps: + - name: Prepare + run: | + PLATFORM=${{ matrix.platform }} + VERSION=${{ github.event.inputs.version }} + IMAGE_TAG=${VERSION#v} + echo "PLATFORM_PAIR=${PLATFORM//\//-}" >> $GITHUB_ENV + echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV + + - name: Check out the repository + uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + id: build + uses: docker/build-push-action@v6 + with: + platforms: ${{ matrix.platform }} + tags: | + ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}-${{ env.PLATFORM_PAIR }} + ${{ env.IMAGE_NAME }}:latest-${{ env.PLATFORM_PAIR }} + build-args: VERSION=${{ github.event.inputs.version }} + context: . + provenance: false + push: true + merge: + runs-on: ubuntu-24.04 + needs: + - build + steps: + - name: Prepare + run: | + VERSION=${{ github.event.inputs.version }} + IMAGE_TAG=${VERSION#v} + echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Create and push manifest + uses: Noelware/docker-manifest-action@0.4.3 + with: + inputs: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} + images: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}-linux-amd64,${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}-linux-arm64 + push: true + + - name: Create and push manifest + uses: Noelware/docker-manifest-action@0.4.3 + with: + inputs: ${{ env.IMAGE_NAME }}:latest + images: ${{ env.IMAGE_NAME }}:latest-linux-amd64,${{ env.IMAGE_NAME }}:latest-linux-arm64 + push: true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..8b5864c9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +# syntax=docker/dockerfile:1 +FROM node:20.12.0 AS builder + +WORKDIR /app + +ARG VERSION=main + +RUN npm install -g pnpm@8.5.0 +RUN pnpm install + +COPY . . + +RUN sed -i 's|https://test.appflowy.cloud||g' src/components/main/app.hooks.ts +RUN pnpm run build + +FROM nginx:alpine +COPY --from=builder /app/dist /usr/share/nginx/html/ \ No newline at end of file