Gitlab Docker Deployment to AWS ec2

HI Team,

Actually I have a Reppository in micro services project and we need to deploy the code as a docker container using docker-compose in an AWS ec2.

I have used the below script to do that

image: gitlab/dind:latest
services:

  • docker:dind
    before_script:
  • docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    stages:
  • build
  • deploy
    build:
    stage: build
    script:
    • docker build -t $CI_REGISTRY/$CI_PROJECT_PATH:latest .
    • docker push $CI_REGISTRY/$CI_PROJECT_PATH:latest
      tags:
    • docker
      deploy:
      stage: deploy
      script:
    Login to deployment server using SSH
    • mkdir -p ~/.ssh
    • echo “$DEPLOY_SERVER_PRIVATE_KEY” | tr -d ‘\r’ > ~/.ssh/id_rsa
    • chmod 600 ~/.ssh/id_rsa
    • ‘which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )’
    • eval “$(ssh-agent -s)”
    • ssh-add ~/.ssh/id_rsa
    • ssh-keyscan -H $DEPLOYMENT_SERVER_IP >> ~/.ssh/known_hosts
    Pull the registry to deployment server and recereate the docker service
    • ssh $DEPLOYMENT_SERVER_USERNAME@$DEPLOYMENT_SERVER_IP docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    • ssh $DEPLOYMENT_SERVER_USERNAME@$DEPLOYMENT_SERVER_IP docker pull $CI_REGISTRY/$CI_PROJECT_PATH:latest
    • ssh $DEPLOYMENT_SERVER_USERNAME@$DEPLOYMENT_SERVER_IP docker-compose -f $DOCKER_COMPOSE_FILE_PATH/$DOCKER_COMPOSE_FILE_NAME up -d $CI_PROJECT_NAME
      only:
    • master
      tags:
    • docker

I have even passed all the required variables in Environment variables ,Even the script is working fine till the last line , it is failing in the last line regarding DOCKER_COMPOSE_FILE_PATH ,for which i tried different paths , usually docker-compose file is in root path.

I can even see the docker images pulling from git lab registry to my ec2 instance, But docker-compose up is failing with below error

.IOError: [Errno 2] No such file or directory

What should I give in DOCKER_FILE_PATH_ENVIRONMENT variable , Any help will be gretaly appreciated