From 5a8c9348b72728f66a9c1585a0a7b75dc0461620 Mon Sep 17 00:00:00 2001 From: infinitycat Date: Wed, 9 Apr 2025 10:02:00 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat(docker):=20=E6=96=B0=E5=A2=9EDockerfil?= =?UTF-8?q?e,=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-image.yml | 49 ++++++++++++++++++++++++++++++ Dockerfile | 14 +++++++++ 2 files changed, 63 insertions(+) create mode 100644 .github/workflows/docker-image.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..154a5be --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,49 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + env: + DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USERNAME }} + DATE_TAG: $(date -u +'%Y-%m-%dT%H-%M-%S') + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Clone maim_message + run: git clone https://github.com/MaiM-with-u/maim_message maim_message + + - name: Determine Image Tags + id: tags + run: | + echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot-adapter:latest,${{ secrets.DOCKERHUB_USERNAME }}/maimbot-adapter:$(date -u +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT + + - name: Build and Push Docker Image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.tags.outputs.tags }} + push: true + cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maimbot-adapter:buildcache + cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maimbot-adapter:buildcache,mode=max + labels: | + org.opencontainers.image.created=${{ steps.tags.outputs.date_tag }} + org.opencontainers.image.revision=${{ github.sha }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..64edece --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM python:3.13.2-slim +LABEL authors="infinitycat233" + +# Copy uv and maim_message +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ +COPY maim_message /maim_message +COPY requirements.txt /requirements.txt + +# Install requirements +RUN uv pip install --system --upgrade pip +RUN uv pip install --system -e /maim_message +RUN uv pip install --system -r /requirements.txt + +ENTRYPOINT ["python", "main.py"] \ No newline at end of file From fff728a2825b778eb1b045c6e4213ffdf67e0bcc Mon Sep 17 00:00:00 2001 From: infinitycat Date: Wed, 9 Apr 2025 11:09:57 +0800 Subject: [PATCH 2/5] =?UTF-8?q?pref(workflow):=20=E4=BF=AE=E6=94=B9tag?= =?UTF-8?q?=E4=B8=BAdev?= 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 154a5be..d015f47 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -32,7 +32,7 @@ jobs: - name: Determine Image Tags id: tags run: | - echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot-adapter:latest,${{ secrets.DOCKERHUB_USERNAME }}/maimbot-adapter:$(date -u +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT + echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot-adapter:dev,${{ secrets.DOCKERHUB_USERNAME }}/maimbot-adapter:dev-$(date -u +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT - name: Build and Push Docker Image uses: docker/build-push-action@v5 From ead2bb17a165c17e1207261ae3b567d4ca1a8a1d Mon Sep 17 00:00:00 2001 From: infinitycat Date: Wed, 9 Apr 2025 11:15:26 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix(requirements):=20=E7=BC=BA=E5=B0=91toml?= =?UTF-8?q?=E7=9A=84=E8=BD=AF=E4=BB=B6=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d623d4b..41e8eb1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,5 @@ asyncio requests maim_message loguru -pillow \ No newline at end of file +pillow +tomli \ No newline at end of file From 61551004ddcbcd5e59cbf6de1ae542a16e5dd2cd Mon Sep 17 00:00:00 2001 From: infinitycat Date: Wed, 9 Apr 2025 11:26:22 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix(Dockerfile):=20=E4=BF=AE=E6=AD=A3docker?= =?UTF-8?q?file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index 64edece..c2c879b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,8 @@ RUN uv pip install --system --upgrade pip RUN uv pip install --system -e /maim_message RUN uv pip install --system -r /requirements.txt +WORKDIR /adapters + +COPY . . + ENTRYPOINT ["python", "main.py"] \ No newline at end of file From b5a52262050f4f84307634872720cfd635f58fd9 Mon Sep 17 00:00:00 2001 From: infinitycat Date: Wed, 9 Apr 2025 11:35:25 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix(Dockerfile):=20=E4=BF=AE=E6=AD=A3docker?= =?UTF-8?q?file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index c2c879b..7dee666 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,4 +15,6 @@ WORKDIR /adapters COPY . . +EXPOSE 8095 + ENTRYPOINT ["python", "main.py"] \ No newline at end of file