From 22913a5bdfbd3fd91094451406c6d2b407e6f960 Mon Sep 17 00:00:00 2001 From: infinitycat Date: Mon, 7 Jul 2025 11:30:55 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0docker-compose.ym?= =?UTF-8?q?l=E5=92=8CGitHub=E5=B7=A5=E4=BD=9C=E6=B5=81=EF=BC=8C=E7=A7=BB?= =?UTF-8?q?=E9=99=A4sqlite-web=E6=9C=8D=E5=8A=A1=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4chat2db=E7=AB=AF=E5=8F=A3=EF=BC=8C=E4=BC=98=E5=8C=96Do?= =?UTF-8?q?cker=E9=95=9C=E5=83=8F=E6=9E=84=E5=BB=BA=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=EF=BC=8C=E5=90=88=E5=B9=B6AMD64=E5=92=8CARM64=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E6=AD=A5=E9=AA=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-image.yml | 142 ++++++----------------------- docker-compose.yml | 26 ++++-- 2 files changed, 43 insertions(+), 125 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index f9b5e6658..9b736e9d8 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -12,35 +12,17 @@ on: - "*.*.*" - "*.*.*-*" +# Workflow's jobs jobs: - build-amd64: - name: Build AMD64 Image + docker: runs-on: ubuntu-latest - env: - DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USERNAME }} steps: - - name: Checkout code + - name: Check out git repository uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Clone maim_message - run: git clone https://github.com/MaiM-with-u/maim_message maim_message - - - name: Clone lpmm - run: git clone https://github.com/MaiM-with-u/MaiMBot-LPMM.git MaiMBot-LPMM - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - buildkitd-flags: --debug - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - + # Generate metadata for Docker images - name: Docker meta id: meta uses: docker/metadata-action@v5 @@ -55,120 +37,50 @@ jobs: type=semver,pattern={{major}} type=sha - - name: Build and Push AMD64 Docker Image - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile - platforms: linux/amd64 - tags: ${{ secrets.DOCKERHUB_USERNAME }}/maibot:amd64-${{ github.sha }} - push: true - cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:amd64-buildcache - cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:amd64-buildcache,mode=max - labels: ${{ steps.meta.outputs.labels }} - provenance: true - sbom: true - build-args: | - BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') - VCS_REF=${{ github.sha }} - outputs: type=image,push=true + # Outputting basic information + - name: Print basic information + run: | + echo "Generated tags: ${{ steps.meta.outputs.tags }}" + echo "Generated labels: ${{ steps.meta.outputs.labels }}" - build-arm64: - name: Build ARM64 Image - runs-on: ubuntu-latest - env: - DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USERNAME }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 + # Clone required dependencies + - name: Clone maim_message + run: git clone https://github.com/MaiM-with-u/maim_message maim_message + + - name: Clone lpmm + run: git clone https://github.com/MaiM-with-u/MaiMBot-LPMM.git MaiMBot-LPMM - name: Set up QEMU uses: docker/setup-qemu-action@v3 - - - name: Clone maim_message - run: git clone https://github.com/MaiM-with-u/maim_message maim_message - - - name: Clone lpmm - run: git clone https://github.com/MaiM-with-u/MaiMBot-LPMM.git MaiMBot-LPMM + with: + platforms: amd64,arm64 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: buildkitd-flags: --debug - - name: Login to Docker Hub + # Log in docker hub + - name: Log in to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ secrets.DOCKERHUB_USERNAME }}/maibot - tags: | - type=ref,event=branch - type=ref,event=tag - type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha - - - name: Build and Push ARM64 Docker Image + # Packaging and sending to Docker + - name: Build and push uses: docker/build-push-action@v5 with: context: . - file: ./Dockerfile - platforms: linux/arm64 - tags: ${{ secrets.DOCKERHUB_USERNAME }}/maibot:arm64-${{ github.sha }} push: true - cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:arm64-buildcache - cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:arm64-buildcache,mode=max + platforms: linux/amd64,linux/arm64/v8 + tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + file: ./Dockerfile + cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:buildcache + cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:buildcache,mode=max provenance: true sbom: true build-args: | BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') - VCS_REF=${{ github.sha }} - outputs: type=image,push=true - - create-manifest: - name: Create Multi-Arch Manifest - runs-on: ubuntu-latest - needs: - - build-amd64 - - build-arm64 - steps: - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ secrets.DOCKERHUB_USERNAME }}/maibot - tags: | - type=ref,event=branch - type=ref,event=tag - type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha - - - name: Create and Push Manifest - run: | - # 为每个标签创建多架构镜像 - for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' '); do - echo "Creating manifest for $tag" - docker buildx imagetools create -t $tag \ - ${{ secrets.DOCKERHUB_USERNAME }}/maibot:amd64-${{ github.sha }} \ - ${{ secrets.DOCKERHUB_USERNAME }}/maibot:arm64-${{ github.sha }} - done \ No newline at end of file + VCS_REF=${{ github.sha }} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b2ce0a31e..a85b00748 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,6 @@ services: restart: always networks: - maim_bot - core: container_name: maim-bot-core #### prod #### @@ -40,7 +39,6 @@ services: restart: always networks: - maim_bot - napcat: environment: - NAPCAT_UID=1000 @@ -57,20 +55,28 @@ services: image: mlikiowa/napcat-docker:latest networks: - maim_bot - - sqlite-web: - image: coleifer/sqlite-web - container_name: sqlite-web + # sqlite-web: + # image: coleifer/sqlite-web + # container_name: sqlite-web + # restart: always + # ports: + # - "8120:8080" + # volumes: + # - ./data/MaiMBot:/data/MaiMBot + # environment: + # - SQLITE_DATABASE=MaiMBot/MaiBot.db # 你的数据库文件 + # networks: + # - maim_bot + chat2db: + image: chat2db/chat2db:latest + container_name: maim-bot-chat2db restart: always ports: - - "8120:8080" + - "10824:10824" volumes: - ./data/MaiMBot:/data/MaiMBot - environment: - - SQLITE_DATABASE=MaiMBot/MaiBot.db # 你的数据库文件 networks: - maim_bot - networks: maim_bot: driver: bridge From 0d5721d7864568179760626e71f6d7cf7c0b6331 Mon Sep 17 00:00:00 2001 From: infinitycat Date: Mon, 7 Jul 2025 11:37:29 +0800 Subject: [PATCH 2/4] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96docker=E7=9A=84wo?= =?UTF-8?q?rkflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-image.yml | 176 +++++++++++++++++++++-------- 1 file changed, 129 insertions(+), 47 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 9b736e9d8..26dab7c04 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -14,14 +14,134 @@ on: # Workflow's jobs jobs: - docker: + build-amd64: + name: Build AMD64 Image runs-on: ubuntu-latest + outputs: + digest: ${{ steps.build.outputs.digest }} steps: - name: Check out git repository uses: actions/checkout@v4 with: fetch-depth: 0 + # Clone required dependencies + - name: Clone maim_message + run: git clone https://github.com/MaiM-with-u/maim_message maim_message + + - name: Clone lpmm + run: git clone https://github.com/MaiM-with-u/MaiMBot-LPMM.git MaiMBot-LPMM + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + buildkitd-flags: --debug + + # Log in docker hub + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Generate metadata for Docker images + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/maibot + + # Build and push AMD64 image by digest + - name: Build and push AMD64 + id: build + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64 + labels: ${{ steps.meta.outputs.labels }} + file: ./Dockerfile + cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:amd64-buildcache + cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:amd64-buildcache,mode=max + outputs: type=image,name=${{ secrets.DOCKERHUB_USERNAME }}/maibot,push-by-digest=true,name-canonical=true,push=true + build-args: | + BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') + VCS_REF=${{ github.sha }} + + build-arm64: + name: Build ARM64 Image + runs-on: ubuntu-latest + outputs: + digest: ${{ steps.build.outputs.digest }} + steps: + - name: Check out git repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Clone required dependencies + - name: Clone maim_message + run: git clone https://github.com/MaiM-with-u/maim_message maim_message + + - name: Clone lpmm + run: git clone https://github.com/MaiM-with-u/MaiMBot-LPMM.git MaiMBot-LPMM + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + buildkitd-flags: --debug + + # Log in docker hub + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Generate metadata for Docker images + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/maibot + + # Build and push ARM64 image by digest + - name: Build and push ARM64 + id: build + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/arm64/v8 + labels: ${{ steps.meta.outputs.labels }} + file: ./Dockerfile + cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:arm64-buildcache + cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:arm64-buildcache,mode=max + outputs: type=image,name=${{ secrets.DOCKERHUB_USERNAME }}/maibot,push-by-digest=true,name-canonical=true,push=true + build-args: | + BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') + VCS_REF=${{ github.sha }} + + create-manifest: + name: Create Multi-Arch Manifest + runs-on: ubuntu-latest + needs: + - build-amd64 + - build-arm64 + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Log in docker hub + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + # Generate metadata for Docker images - name: Docker meta id: meta @@ -37,50 +157,12 @@ jobs: type=semver,pattern={{major}} type=sha - # Outputting basic information - - name: Print basic information + - name: Create and Push Manifest run: | - echo "Generated tags: ${{ steps.meta.outputs.tags }}" - echo "Generated labels: ${{ steps.meta.outputs.labels }}" - - # Clone required dependencies - - name: Clone maim_message - run: git clone https://github.com/MaiM-with-u/maim_message maim_message - - - name: Clone lpmm - run: git clone https://github.com/MaiM-with-u/MaiMBot-LPMM.git MaiMBot-LPMM - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: amd64,arm64 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - buildkitd-flags: --debug - - # Log in docker hub - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - # Packaging and sending to Docker - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - push: true - platforms: linux/amd64,linux/arm64/v8 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - file: ./Dockerfile - cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:buildcache - cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:buildcache,mode=max - provenance: true - sbom: true - build-args: | - BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') - VCS_REF=${{ github.sha }} \ No newline at end of file + # 为每个标签创建多架构镜像 + for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' '); do + echo "Creating manifest for $tag" + docker buildx imagetools create -t $tag \ + ${{ secrets.DOCKERHUB_USERNAME }}/maibot@${{ needs.build-amd64.outputs.digest }} \ + ${{ secrets.DOCKERHUB_USERNAME }}/maibot@${{ needs.build-arm64.outputs.digest }} + done \ No newline at end of file From b31892374c8f6958857f5dfbc16b3021132f6b94 Mon Sep 17 00:00:00 2001 From: infinitycat Date: Mon, 7 Jul 2025 12:21:36 +0800 Subject: [PATCH 3/4] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96tag=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 26dab7c04..47fdf5b7f 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -155,7 +155,7 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - type=sha + type=sha,prefix=${{ github.ref_name }}-,enable=${{ github.ref_type == 'branch' }} - name: Create and Push Manifest run: | From a0b4037a2668fb979a12e088b808a2558ad66033 Mon Sep 17 00:00:00 2001 From: infinitycat Date: Mon, 7 Jul 2025 20:03:53 +0800 Subject: [PATCH 4/4] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96docker-compose.ya?= =?UTF-8?q?ml,=E6=96=B0=E5=A2=9Echat2db=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=B7=A5=E5=85=B7=EF=BC=88=E5=8F=AF=E9=80=89?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 4 +++- docker-compose.yml | 36 ++++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.dockerignore b/.dockerignore index fac1bf99a..e1f125bd5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,4 +4,6 @@ __pycache__ *.pyd .DS_Store mongodb -napcat \ No newline at end of file +napcat +docs/ +.github/ \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index a85b00748..bcc8a57a8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -55,28 +55,32 @@ services: image: mlikiowa/napcat-docker:latest networks: - maim_bot - # sqlite-web: - # image: coleifer/sqlite-web - # container_name: sqlite-web - # restart: always - # ports: - # - "8120:8080" - # volumes: - # - ./data/MaiMBot:/data/MaiMBot - # environment: - # - SQLITE_DATABASE=MaiMBot/MaiBot.db # 你的数据库文件 - # networks: - # - maim_bot - chat2db: - image: chat2db/chat2db:latest - container_name: maim-bot-chat2db + sqlite-web: + # 注意:coleifer/sqlite-web 镜像不支持arm64 + image: coleifer/sqlite-web + container_name: sqlite-web restart: always ports: - - "10824:10824" + - "8120:8080" volumes: - ./data/MaiMBot:/data/MaiMBot + environment: + - SQLITE_DATABASE=MaiMBot/MaiBot.db # 你的数据库文件 networks: - maim_bot + + # chat2db占用相对较高但是功能强大 + # 内存占用约600m,内存充足推荐选此 + # chat2db: + # image: chat2db/chat2db:latest + # container_name: maim-bot-chat2db + # restart: always + # ports: + # - "10824:10824" + # volumes: + # - ./data/MaiMBot:/data/MaiMBot + # networks: + # - maim_bot networks: maim_bot: driver: bridge