From 5806a1fcb56cdce5c625aa0a25a8ad0561ea7da8 Mon Sep 17 00:00:00 2001 From: KokerZhou Date: Mon, 20 Jul 2026 19:47:42 +0800 Subject: [PATCH] ci: publish multi-arch ChatLab CLI image --- .github/docker/chatlab-cli.Dockerfile | 26 ++++++++++++++ .github/workflows/release.yml | 52 +++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 .github/docker/chatlab-cli.Dockerfile diff --git a/.github/docker/chatlab-cli.Dockerfile b/.github/docker/chatlab-cli.Dockerfile new file mode 100644 index 00000000..f884c74f --- /dev/null +++ b/.github/docker/chatlab-cli.Dockerfile @@ -0,0 +1,26 @@ +# syntax=docker/dockerfile:1 + +FROM node:24-bookworm-slim + +ARG CHATLAB_VERSION + +RUN test -n "$CHATLAB_VERSION" \ + && apt-get update \ + && apt-get install --yes --no-install-recommends g++ make python3 \ + && npm install --global --omit=dev "chatlab-cli@${CHATLAB_VERSION}" \ + && npm cache clean --force \ + && apt-get purge --yes --auto-remove g++ make python3 \ + && rm -rf /var/lib/apt/lists/* + +ENV CHATLAB_DATA_DIR=/data + +RUN install -d -o node -g node /data + +WORKDIR /data + +USER node + +EXPOSE 3110 + +ENTRYPOINT ["chatlab"] +CMD ["start", "--no-open", "--host", "0.0.0.0"] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a5f3a4c..4ff2a932 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -554,6 +554,58 @@ jobs: working-directory: apps/cli run: npm publish --ignore-scripts --provenance --tag ${{ needs.prepare_release.outputs.npm_tag }} + publish-docker: + needs: [prepare_release, release, publish-cli] + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout image definition + uses: actions/checkout@v5 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: Log in to GHCR + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + + - name: Docker metadata + id: meta + uses: docker/metadata-action@v6 + with: + images: ghcr.io/${{ github.repository_owner }}/chatlab-cli + tags: | + type=raw,value=${{ needs.prepare_release.outputs.version_tag }} + type=raw,value=latest,enable=${{ needs.prepare_release.outputs.npm_tag == 'latest' }} + labels: | + org.opencontainers.image.source=https://github.com/${{ github.repository }} + org.opencontainers.image.version=${{ needs.prepare_release.outputs.version_tag }} + org.opencontainers.image.revision=${{ github.sha }} + + - name: Build and push + uses: docker/build-push-action@v7 + with: + context: . + file: .github/docker/chatlab-cli.Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + build-args: | + CHATLAB_VERSION=${{ needs.prepare_release.outputs.version }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha,scope=chatlab-cli + cache-to: type=gha,mode=max,scope=chatlab-cli + cleanup-r2: needs: [prepare_release, release] if: needs.prepare_release.outputs.is_prerelease == 'false'