From 338730e48b3ec386cd0224a6e22138554eae415d Mon Sep 17 00:00:00 2001 From: leafmoes <44945631+leafmoes@users.noreply.github.com> Date: Tue, 5 Nov 2024 18:49:14 +0800 Subject: [PATCH] upd: publish to docker hub --- .github/workflows/docker-image.yml | 28 ++++++++++++++++++++++++++-- docker-compose.yml | 2 +- readme.md | 2 +- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 21c728d..686e716 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -11,6 +11,7 @@ on: env: GHCR_REPO: ghcr.io/leafmoes/ddg-chat + DOCKER_HUB_REPO: leafmoes/ddg-chat jobs: docker: @@ -31,8 +32,18 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GHCR_PAT }} + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Get short SHA + id: slug + run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)" - - name: Build and push + - name: Build and push to GitHub Container Registry uses: docker/build-push-action@v6 with: context: . @@ -41,6 +52,19 @@ jobs: push: true tags: | ${{ env.GHCR_REPO }}:latest - ${{ env.GHCR_REPO }}:${{ github.sha }} + ${{ env.GHCR_REPO }}:${{ steps.slug.outputs.sha7 }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build and push to Docker Hub + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + file: Dockerfile + push: true + tags: | + ${{ env.DOCKER_HUB_REPO }}:lates1314521t + ${{ env.DOCKER_HUB_REPO }}:${{ steps.slug.outputs.sha7 }} cache-from: type=gha cache-to: type=gha,mode=max diff --git a/docker-compose.yml b/docker-compose.yml index ccf1ac6..1bec92b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: ddg-chat: - image: ghcr.io/leafmoes/ddg-chat:latest + image: leafmoes/ddg-chat:latest container_name: ddg-chat restart: unless-stopped ports: diff --git a/readme.md b/readme.md index 5d40264..1d67d51 100644 --- a/readme.md +++ b/readme.md @@ -130,7 +130,7 @@ npm install 方法一:命令行构建 ```bash -docker run -it -d --name ddg-chat -p 8787:8787 ghcr.io/leafmoes/ddg-chat:latest +docker run -it -d --name ddg-chat -p 8787:8787 leafmoes/ddg-chat:latest ``` 方法二:使用 `docker-compose.yml` 文件构建