1

I don't have much experience with Docker (meaning I only know a few things about writing a Dockerfile and about the concepts involved in Docker). I want to make up a Docker image for CodeBuild to build my application, however I am not sure how CodeCommit will get the code from CodeCommit into my docker image.

I followed this tutorial about extending CodeBuild with custom Docker images but I still can't understand the process of getting code from git into the container.

Could you help me out with some advice, please?

1

I guess You are using CodePipeline and CodeBuild can get input artifact (zip file). Next step is to copy the code inside container image during build process using:

COPY {from} {to}

in Dockerfile.

2
  • So is this correctly understood: CodeBuild clones the repository, in which the dockerfile resides at top level and runs docker build. Inside the dockerfile we retrieve the source code by calling 'COPY . /app' where, in this case, we access current directory with dot [.], and copy it to '/app'? I ask because many of the sites I hit when searching seems to have 'git clone' logic inside dockerfile which surprises me.
    – Hervian
    Jan 29 '18 at 15:14
  • @Hervian yes, you are right.
    – CallMeLaNN
    Apr 3 '18 at 9:30
1

Codebuild fetch code from codecommit and it will be available for us on $CODEBUILD_SRC_DIR folder. Now if you want to copy code to Docker container while running docker build then make sure you will be correct directory ($CODEBUILD_SRC_DIR) and have use COPY command with '.' like below :

COPY ./test /test

If you don't give dot (.) then it definitely show error something like below COPY failed: stat /var/lib/docker/tmp/docker-builder095648372/test: no such file or directory

Hopefully helpful for new AWS users.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.