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:
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…
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.