chore: build web docker image

This commit is contained in:
Nathan
2025-07-04 15:12:14 +08:00
parent 2b5b7bb669
commit 421f64ff11
3 changed files with 143 additions and 0 deletions

39
.dockerignore Normal file
View File

@@ -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

87
.github/workflows/web_docker.yml vendored Normal file
View File

@@ -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

17
Dockerfile Normal file
View File

@@ -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/