CodeBuild
Developer Associate
- Fully managed build service, which compiles source code, runs simple tests, and can generate build artifacts for deployment
- To build a docker image for use in ECS, there are a number of different commands you’ll need to run
- To build the image, use
docker build -t <<dockerimagename>> . - After the build completes, tag the image so you can push it to the registry.
docker tag <<dockerimagename>>:latest <<registry/dockerimagename:latest>> - Then push teh build to the registry using “docker push «registry/dockerimagename:latest»”
- To build the image, use
- Buildspec.yml file explains to CodeBuild exactly how we want it to build our Docker images / whatever it’s building
- variables/paramters
- phases: hooks you can tie in commands with
- pre_build, build, post_build
- artifacts:
- You can also define commands directly into the CodeBuild configuration and forego the buildspec.yml file entirely (know this for exam!!)
- You also need to specify a Service Role for CodeBuild which gives it the ability to call into other AWS dependent services
- If your build fails, check the build logs within the CodeBuild console, or within CloudWatch
- If you get an error stating “The bucket you are attempting to access must be addressed using the specified endpoint”, it means the bucket is in a different region than the CodeBuild build project.