From bdbd6bae88fb117eda4e81fe18b21800018cf8ac Mon Sep 17 00:00:00 2001 From: hibobmaster Date: Tue, 11 Apr 2023 08:48:52 +0800 Subject: [PATCH] fix action --- .github/workflows/docker-release.yml | 58 +++++++++++++++++++--------- Dockerfile | 9 ++--- 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 2859316..41de122 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -7,21 +7,26 @@ on: jobs: push_to_registry: - name: Push Docker image to Docker Hub + name: Push Docker image to registry runs-on: ubuntu-latest steps: - - - name: Check out the repo + - name: Check out the repo uses: actions/checkout@v3 - - - name: Log in to Docker Hub + + - name: Log in to Docker Hub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - - - name: Docker metadata + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker metadata id: meta uses: docker/metadata-action@v4 with: @@ -29,23 +34,40 @@ jobs: tags: | type=raw,value=latest type=ref,event=tag - - - - name: Set up QEMU + + - name: Set up QEMU uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - - - name: Build and push Docker image + + - name: Build and push Docker image(dockerhub) uses: docker/build-push-action@v4 with: context: . - platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file + cache-to: type=gha,mode=max + + - name: Docker metadata(ghcr) + id: meta2 + uses: docker/metadata-action@v4 + with: + images: ghcr.io/hibobmaster/matrixchatgptbot + tags: | + type=raw,value=latest + type=sha,format=long + + - name: Build and push Docker image(ghcr) + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta2.outputs.tags }} + labels: ${{ steps.meta2.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index afe6df6..eaff44d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,14 @@ FROM python:3.11-alpine as base FROM base as pybuilder -RUN sed -i 's|v3\.\d*|edge|' /etc/apk/repositories -RUN apk update && apk add olm-dev gcc musl-dev libmagic +# RUN sed -i 's|v3\.\d*|edge|' /etc/apk/repositories +RUN apk update && apk add --no-cache olm-dev gcc musl-dev libmagic libffi-dev COPY requirements.txt /requirements.txt -RUN pip3 install --user -r /requirements.txt && rm /requirements.txt +RUN pip install -U pip setuptools wheel && pip install --user -r /requirements.txt && rm /requirements.txt FROM base as runner -LABEL "org.opencontainers.image.source"="https://github.com/hibobmaster/matrix_chatgpt_bot" -RUN apk update && apk add olm-dev libmagic +RUN apk update && apk add --no-cache olm-dev libmagic libffi-dev COPY --from=pybuilder /root/.local /usr/local COPY . /app