diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..d015f47 --- /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: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 + 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..7dee666 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +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 + +WORKDIR /adapters + +COPY . . + +EXPOSE 8095 + +ENTRYPOINT ["python", "main.py"] \ No newline at end of file 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