AWS CodeBuild docker-compose

  aws-codebuild, docker, docker-compose

I’m using docker-compose to create 2 docker containers on os Linux 2 as follows:

docker-compose -f docker-compose.dev.yml up --build -d  

The docker-compose.dev.yml file is:

version: '3'

services:

  client:
    container_name: client
    build:
      context: frontend   
    restart: always
    ports:
      - "80:80"
      - "443:443"
    links:
      - express
    volumes:
      - /home/ec2-user/.caddy:/root/.caddy

  express:
    container_name: express
    build: ./express
    environment:
      - NODE_ENV=development
    restart: always

Running the above docker compose works fine on an ec2. Now I’m trying to use CodeBuild for this task. The buildspec.yml:

version: 0.2
phases:
  
  build:
    commands:
      - echo $CODEBUILD_SRC_DIR
      - echo start docker compose for DEV
      - docker-compose -f docker-compose.dev.yml up --build -d  
artifacts:
  files:
    - '**/*'

In the aws CodeBuild console, I get this error:

[Container] 2021/07/19 10:59:03 Running command docker-compose -f docker-compose.dev.yml up --build -d
Creating network "src_default" with the default driver
Building express
Cannot locate specified Dockerfile: Dockerfile

[Container] 2021/07/19 10:59:07 Command did not exit successfully docker-compose -f docker-compose.dev.yml up --build -d exit status 1
[Container] 2021/07/19 10:59:07 Phase complete: BUILD State: FAILED
[Container] 2021/07/19 10:59:07 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: docker-compose -f docker-compose.dev.yml up --build -d. Reason: exit status 1

What might be the issue?

Thanks

Source: Docker Questions

LEAVE A COMMENT