From ec840a66477423463e444eb82e30883130a0c25a Mon Sep 17 00:00:00 2001 From: hibobmaster <32976627+hibobmaster@users.noreply.github.com> Date: Thu, 6 Apr 2023 22:05:32 +0800 Subject: [PATCH] Add Docker CI --- .github/workflows/docker-release.yml | 51 ++++++++++++++++++++++++++++ Dockerfile | 6 ++-- 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/docker-release.yml diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml new file mode 100644 index 0000000..18e1252 --- /dev/null +++ b/.github/workflows/docker-release.yml @@ -0,0 +1,51 @@ +name: Publish Docker image + +on: + workflow_dispatch: + release: + types: [published] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - + name: Check out the repo + uses: actions/checkout@v3 + - + name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - + name: Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: hibobmaster/matrixchatgptbot + tags: | + type=raw,value=latest + type=ref,event=tag + + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - + name: Build and push Docker image + 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 + 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 diff --git a/Dockerfile b/Dockerfile index fbe1d73..d4755fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,13 @@ -FROM python:3.11-alpine as pybuilder +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 tzdata libmagic COPY requirements.txt /requirements.txt RUN pip3 install --user -r /requirements.txt && rm /requirements.txt -FROM python:3.11-alpine as runner +FROM base as runner LABEL "org.opencontainers.image.source"="https://github.com/hibobmaster/matrix_chatgpt_bot" RUN apk update && apk add olm-dev libmagic COPY --from=pybuilder /root/.local /usr/local