From 1fe78f1de0bccfd894513e9bdc8bb1cafc2e83c9 Mon Sep 17 00:00:00 2001 From: Liz Date: Tue, 2 Dec 2025 17:07:11 +0800 Subject: [PATCH 1/2] Add CI to build image and push --- .github/workflows/docker-image.yml | 56 ++++++++++++++++++++++++++++++ README.md | 5 ++- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..9c9e91b --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,56 @@ +name: Docker Image CI + +on: + push: + branches: + - main + tags: + - 'v*' + pull_request: + branches: + - main + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=sha + + - name: Log in to registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/README.md b/README.md index 960e850..7a5df3e 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,10 @@ Then, you can simply use the address and port as the baseURL as you require (htt Read [the docker instrunctions here](https://github.com/RayBytes/ChatMock/blob/main/DOCKER.md) +## Continuous Integration + +Every push or pull request to `main` runs the workflow at `.github/workflows/docker-image.yml`, which builds the Docker image and (on pushes) publishes it to GitHub's container registry using the built-in `GITHUB_TOKEN`. The image is tagged for the branch, tag, and commit SHA, so you can pull `ghcr.io//ChatMock:main` (or whatever tag was built) directly after CI completes. If you prefer Docker Hub or another registry, update the `REGISTRY` or `IMAGE_NAME` env vars in the workflow file accordingly. + # Examples ### Python @@ -172,4 +176,3 @@ When the model returns a thinking summary, the model will send back thinking tag - From 8d10ede605c4d8d3fb616cca744aa1ebcf7ef36a Mon Sep 17 00:00:00 2001 From: Liz Date: Tue, 2 Dec 2025 17:10:52 +0800 Subject: [PATCH 2/2] Support both amd64 and arm64 --- .github/workflows/docker-image.yml | 6 +++++- README.md | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 9c9e91b..69fe2e2 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -5,7 +5,7 @@ on: branches: - main tags: - - 'v*' + - "v*" pull_request: branches: - main @@ -28,6 +28,9 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Extract Docker metadata id: meta uses: docker/metadata-action@v5 @@ -51,6 +54,7 @@ jobs: with: context: . file: ./Dockerfile + platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/README.md b/README.md index 7a5df3e..470430d 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Read [the docker instrunctions here](https://github.com/RayBytes/ChatMock/blob/m ## Continuous Integration -Every push or pull request to `main` runs the workflow at `.github/workflows/docker-image.yml`, which builds the Docker image and (on pushes) publishes it to GitHub's container registry using the built-in `GITHUB_TOKEN`. The image is tagged for the branch, tag, and commit SHA, so you can pull `ghcr.io//ChatMock:main` (or whatever tag was built) directly after CI completes. If you prefer Docker Hub or another registry, update the `REGISTRY` or `IMAGE_NAME` env vars in the workflow file accordingly. +Every push or pull request to `main` runs the workflow at `.github/workflows/docker-image.yml`, which builds multi-arch (linux/amd64 + linux/arm64) Docker images and (on pushes) publishes them to GitHub's container registry using the built-in `GITHUB_TOKEN`. The image is tagged for the branch, tag, and commit SHA, so you can pull `ghcr.io//ChatMock:main` (or whatever tag was built) directly after CI completes. If you prefer Docker Hub or another registry, update the `REGISTRY` or `IMAGE_NAME` env vars in the workflow file accordingly. # Examples @@ -175,4 +175,3 @@ When the model returns a thinking summary, the model will send back thinking tag [![Star History Chart](https://api.star-history.com/svg?repos=RayBytes/ChatMock&type=Timeline)](https://www.star-history.com/#RayBytes/ChatMock&Timeline) -