GitHub actions and Docker-compose

Viewed 3080

guys! I need you help to run docker-compose build on github action. I have a docker-compose file and I can't understand how to build and deploy it in correct way besides of just copying docker-compose by ssh and run scripts there. There's docker/build-push-action@v2 but it's not working with docker-compose.yml.

1 Answers

This strongly depends where do you want to push your images. But for instance if you use Azure ACR you can use this action

on: [push]

name: AzureCLISample

jobs:

  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
    
    - name: Azure Login
      uses: azure/login@v1
      with:
        creds: ${{ secrets.AZURE_CREDENTIALS }}
    
    - name: Azure CLI script
      uses: azure/CLI@v1
      with:
        azcliversion: 2.0.72
        inlineScript: |
          az acr login --name <acrName>
          docker-compose up
          docker-compose push

And then just build and push your images. But this is an example. If you use ECR it would be similar I guess.

For DigitialOcean it would be like this:

steps:
      - uses: actions/checkout@v2
      - name: Build image
        run: docker-compose up

      - name: Install doctl                 # install the doctl on the runner
        uses: digitalocean/action-doctl@v2
        with:
            token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}

      - name: push image to digitalocean
        run: |
          doctl registry login
          docker-compose push

You can find more details about this here

Related