使用docker-compose使用github/action-doctl@v2部署到digitalocean?
我有一个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:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎在文件中没有任何
Deploy
指令。而不是这些:您需要一个
部署:
,然后是目标…You do not seem to have any
deploy
directive in the file. Instead of these:you would want to have a
deploy:
followed by targets…