diff --git a/.github/workflows/build_beta_docker_image.yml b/.github/workflows/build_beta_docker_image.yml new file mode 100644 index 0000000..e8f4dc8 --- /dev/null +++ b/.github/workflows/build_beta_docker_image.yml @@ -0,0 +1,54 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - beta + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=beta + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=sha,prefix= + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/build_docker_image.yml b/.github/workflows/build_docker_image.yml index 62032ef..3b607dc 100644 --- a/.github/workflows/build_docker_image.yml +++ b/.github/workflows/build_docker_image.yml @@ -4,9 +4,6 @@ on: push: branches: - master - pull_request: - branches: - - master workflow_dispatch: env: @@ -37,6 +34,7 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | + type=raw,value=latest type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} diff --git a/docker-compose-beta.yml b/docker-compose-beta.yml new file mode 100755 index 0000000..65e1d88 --- /dev/null +++ b/docker-compose-beta.yml @@ -0,0 +1,33 @@ +services: + reverse-proxy: + image: traefik:v3.1 + command: + - "--providers.docker" + - "--providers.docker.exposedbydefault=false" + - "--entrypoints.web.address=:80" + ports: + - 127.0.0.1:36694:80 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + networks: + - web + + newsanalyze-service: + image: ghcr.io/hpware/news-analyze:beta + networks: + - web + labels: + - "traefik.enable=true" + - "traefik.http.routers.newsanalyze.rule=Host(`news.yuanhau.com`)" + - "traefik.http.services.newsanalyze.loadbalancer.server.port=3000" + - "com.centurylinklabs.watchtower.enable=true" + restart: unless-stopped + env_file: + - path: ./.env + required: true + deploy: + mode: replicated + replicas: 2 + +networks: + web: diff --git a/docker-compose.yml b/docker-compose.yml index d523976..c7f4e57 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ services: - web newsanalyze-service: - image: ghcr.io/hpware/news-analyze:master + image: ghcr.io/hpware/news-analyze:latest networks: - web labels: