使用docker-compose使用github/action-doctl@v2部署到digitalocean?

发布于 2025-02-05 20:58:45 字数 1743 浏览 3 评论 0原文

我有一个docker-compose.yml包含前端,admin_frontend,后端,nginx映像。每当我推到GitHub Master分支时,我都想实现这一目标,然后自动构建Docker-Compose中定义的所有Docker映像(因为我在其中有相同的设置等)。之后,将图像推到我的Digitalocean容器注册表中 - 因此最后我可以在液滴上运行新的部署应用程序。

这是我的工作流文件的一部分 - 但是似乎它没有构建/(或推动我的docker -compose)。

name: deploy app to digital ocean droplet

on:
  push:
    branches:
      - master
jobs:
  main-fe_build:
  admin-fe_build:
  main-be_build:
  main-fe_test:
  build_and_push:
    name: Build & Push
    needs: main-fe_test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout the repo
        uses: actions/checkout@v2
        
      - name: Create env file
        run: |
          touch .env
          echo "${{ secrets.SERVER_ENV_PROD }}" > .env
          cat .env
          
      - name: Build image
        run: docker compose -f docker-compose.yml build
        
      - name: Install doctl
        uses: digitalocean/action-doctl@v2
        with:
          token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
          
      - name: Log in to DO Container Registry
        run: doctl registry login --expiry-seconds 600
        
      - name: Push image to DO Container Registry
        run: docker compose -f docker-compose.yml push
        
      - name: Deploy Stack
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          key: ${{ secrets.SSHKEY }}
          port: ${{ secrets.PORT }}
          script: |
            cd /root/apps/myapp
            ls

附加了有关工作流程的屏幕截图。如您所见,构建/推动图像为0s:

”在此处输入图像描述

I’ve a docker-compose.yml containing frontend, admin_frontend, backend, nginx images. I'd like to achieve that whenever I push to my github master branch then automatically build all the docker images defined in my docker-compose (as I have same settings etc. in there) file. After that push the images to my DigitalOcean Container Registry - so finally I can run the fresh deployed app on my droplet.

It's a part from my workflow file - but it seems like it doesn't build/(or push) the images from my docker-compose.

name: deploy app to digital ocean droplet

on:
  push:
    branches:
      - master
jobs:
  main-fe_build:
  admin-fe_build:
  main-be_build:
  main-fe_test:
  build_and_push:
    name: Build & Push
    needs: main-fe_test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout the repo
        uses: actions/checkout@v2
        
      - name: Create env file
        run: |
          touch .env
          echo "${{ secrets.SERVER_ENV_PROD }}" > .env
          cat .env
          
      - name: Build image
        run: docker compose -f docker-compose.yml build
        
      - name: Install doctl
        uses: digitalocean/action-doctl@v2
        with:
          token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
          
      - name: Log in to DO Container Registry
        run: doctl registry login --expiry-seconds 600
        
      - name: Push image to DO Container Registry
        run: docker compose -f docker-compose.yml push
        
      - name: Deploy Stack
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          key: ${{ secrets.SSHKEY }}
          port: ${{ secrets.PORT }}
          script: |
            cd /root/apps/myapp
            ls

Attached a screenshot about the workflow. As you see build/push images took 0s:

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨落成白 2025-02-12 20:58:45

您似乎在文件中没有任何Deploy指令。而不是这些:

  admin-fe_build:
  main-be_build:
  main-fe_test:
  build_and_push:

您需要一个部署:,然后是目标…

You do not seem to have any deploy directive in the file. Instead of these:

  admin-fe_build:
  main-be_build:
  main-fe_test:
  build_and_push:

you would want to have a deploy: followed by targets…

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文