Leonid Akinin
Leonid Akinin

Reputation: 21

AWS CodeBuild - Unable to find DockerFile during build

Started playing with AWS CodeBuild.

Goal is to have a docker images as a final results with the nodejs, hapi and sample app running inside.

Currently i have an issue with: "unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /tmp/src049302811/src/Dockerfile: no such file or directory" Appears on BUILD stage.

Project details:

  1. S3 bucket used as a source
  2. ZIP file stored in respective S3 bucket contains buildspec.yml, package.json, sample *.js file and DockerFile.
  3. aws/codebuild/docker:1.12.1 is used as a build environment.

When i'm building an image using Docker installed on my laptop there is no issues so i can't understand which directory i need to specify to get rid off this error message.

Buildspec and DockerFile attached below.

Thanks for any comments.

buildspec.yml

version: 0.1

phases:
  pre_build:
    commands:
      - echo Logging in to Amazon ECR...
      - $(aws ecr get-login --region eu-west-1)
  build:
    commands:
      - echo Build started on `date`
      - echo Building the Docker image...          
      - docker build -t <CONTAINER_NAME> .
      - docker tag <CONTAINER_NAME>:latest <ID>.dkr.ecr.eu-west-1.amazonaws.com/<CONTAINER_NAME>:latest
  post_build:
    commands:
      - echo Build completed on `date`
      - echo Pushing the Docker image...
      - docker push <id>.eu-west-1.amazonaws.com/<image>:latest

DockerFile

FROM alpine:latest

RUN apk update && apk upgrade
RUN apk add nodejs
RUN rm -rf /var/cache/apk/*

COPY . /src
RUN cd /src; npm install hapi
EXPOSE 80
CMD ["node", "/src/server.js"]

Upvotes: 0

Views: 2902

Answers (2)

Leonid Akinin
Leonid Akinin

Reputation: 21

Ok, so the solution was simple. Issue was related to the Dockerfile name. It was not accepting DockerFile (with capital F, strange it was working locally) but Dockerfile (with lower-case f) worked perfectly.

Upvotes: 2

awsnitin
awsnitin

Reputation: 636

Can you validate that Dockerfile exists in the root of the directory? One way of doing this would be to run ls -altr as part of the pre-build phase in your buildspec (even before ecr login).

Upvotes: 0

Related Questions