Home > OS >  Git Hub action is failing when running
Git Hub action is failing when running

Time:08-27

My application consists with two project such as client and server. The client is a react application and the server is a spring boot based java backend project. Both contain separate docker files and in the root folder, I have combined both using docker-compose.yaml file. It works fine in the local machine and now I want to deploy the whole application in AWS. I am trying to deploy the images to AWS using Git Hub Action. It is as follows.

name: Deploy to AWS ECR

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the "master" branch
  push:
    branches: [ master ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v3

      # Runs a single command using the runners shell
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1

      # Runs a set of commands using the runners shell
      - name: Login to Amazon ECR
        id: login-ecr
        uses: aws-actions/amazon-ecr-login@v1

      - name: Build, tag, and push image to Amazon ECR
        env:
          ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
          ECR_REPOSITORY: snake_ecr
          IMAGE_TAG: latest
        run: |
          docker-compose up --build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
          docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

my project structure is as follows,

|
|-client\Dockerfile
|-server\Dockerfile
|-docker-compose.yml

When running 'Build, tag, and push image to Amazon ECR' area the script it gives the following error,

Run docker-compose up --build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
  docker-compose up --build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
  docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
  shell: /usr/bin/bash -e {0}
  env:
    AWS_DEFAULT_REGION: us-east-1
    AWS_REGION: us-east-1
    AWS_ACCESS_KEY_ID: ***
    AWS_SECRET_ACCESS_KEY: ***
    ECR_REGISTRY: ***.dkr.ecr.us-east-1.amazonaws.com
    ECR_REPOSITORY: snake_ecr
    IMAGE_TAG: latest
[1644] Failed to execute script docker-compose
Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 81, in main
  File "compose/cli/main.py", line 203, in perform_command
  File "compose/metrics/decorator.py", line 18, in wrapper
  File "compose/cli/main.py", line 1140, in up
  File "compose/cli/main.py", line 1300, in timeout_from_opts
ValueError: invalid literal for int() with base 10: '***.dkr.ecr.us-east-1.amazonaws.com/snake_ecr:latest'

Can anybody help me to solve this issue?

CodePudding user response:

Are you sure that docker-compose is installed on the ubuntu-latest image you are using to run the actions? I usually use an extra image for that like specified here: https://github.com/marketplace/actions/build-and-push-docker-images#git-context

name: Build and push
uses: docker/build-push-action@v3
with:
  push: true
  tags: user/app:latest

Then you might need to specify your docker images individually, because it's not working with docker-compose.

  • Related