diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index a5a6680cd..29fd6fd44 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -13,6 +13,9 @@ on: jobs: build-and-push: 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 @@ -40,7 +43,7 @@ jobs: elif [ "${{ github.ref }}" == "refs/heads/main-fix" ]; then echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:main-fix" >> $GITHUB_OUTPUT elif [ "${{ github.ref }}" == "refs/heads/refactor" ]; then # 新增 refactor 分支处理 - echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:refactor" >> $GITHUB_OUTPUT + echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:refactor,${{ secrets.DOCKERHUB_USERNAME }}/maimbot:refactor$(date -u +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT fi - name: Build and Push Docker Image @@ -52,4 +55,7 @@ jobs: tags: ${{ steps.tags.outputs.tags }} push: true cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:buildcache - cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:buildcache,mode=max \ No newline at end of file + cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maimbot: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 index fe96ac033..838e2b993 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM python:3.13.2-slim-bookworm +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ # 工作目录 WORKDIR /MaiMBot @@ -9,9 +10,9 @@ COPY requirements.txt . COPY maim_message /maim_message # 安装依赖 -RUN pip install --upgrade pip -RUN pip install -e /maim_message -RUN pip install --upgrade -r requirements.txt +RUN uv pip install --system --upgrade pip +RUN uv pip install --system -e /maim_message +RUN uv pip install --system -r requirements.txt # 复制项目代码 COPY . .