File tree Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,40 @@ module "ecs_release_pipeline" {
9393
9494Complete usage can be seen in the [ terraform-aws-ecs-web-app] ( https://github.com/cloudposse/terraform-aws-ecs-web-app/blob/master/main.tf ) module.
9595
96+ ## Example Buildspec
97+
98+ Here's an example ` buildspec.yaml ` . Stick this in the root of your project repository.
99+
100+ ``` yaml
101+ version : 0.2
102+ phases :
103+ pre_build :
104+ commands :
105+ - echo Logging in to Amazon ECR...
106+ - aws --version
107+ - eval $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)
108+ - REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME
109+ - IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
110+ build :
111+ commands :
112+ - echo Build started on `date`
113+ - echo Building the Docker image...
114+ - REPO_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME
115+ - docker pull $REPO_URI:latest || true
116+ - docker build --cache-from $REPO_URI:latest --tag $REPO_URI:latest --tag $REPO_URI:$IMAGE_TAG .
117+ post_build :
118+ commands :
119+ - echo Build completed on `date`
120+ - echo Pushing the Docker images...
121+ - REPO_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME
122+ - docker push $REPO_URI:latest
123+ - docker push $REPO_URI:$IMAGE_TAG
124+ - echo Writing image definitions file...
125+ - printf '[{"name":"%s","imageUri":"%s"}]' "$CONTAINER_NAME" "$REPO_URI:$IMAGE_TAG" | tee imagedefinitions.json
126+ artifacts :
127+ files : imagedefinitions.json
128+ ` ` `
129+
96130
97131
98132## Makefile Targets
Original file line number Diff line number Diff line change @@ -106,6 +106,40 @@ usage: |-
106106# Example usage
107107examples : |-
108108 Complete usage can be seen in the [terraform-aws-ecs-web-app](https://github.com/cloudposse/terraform-aws-ecs-web-app/blob/master/main.tf) module.
109+
110+ ## Example Buildspec
111+
112+ Here's an example `buildspec.yaml`. Stick this in the root of your project repository.
113+
114+ ```yaml
115+ version: 0.2
116+ phases:
117+ pre_build:
118+ commands:
119+ - echo Logging in to Amazon ECR...
120+ - aws --version
121+ - eval $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)
122+ - REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME
123+ - IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
124+ build:
125+ commands:
126+ - echo Build started on `date`
127+ - echo Building the Docker image...
128+ - REPO_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME
129+ - docker pull $REPO_URI:latest || true
130+ - docker build --cache-from $REPO_URI:latest --tag $REPO_URI:latest --tag $REPO_URI:$IMAGE_TAG .
131+ post_build:
132+ commands:
133+ - echo Build completed on `date`
134+ - echo Pushing the Docker images...
135+ - REPO_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REPO_NAME
136+ - docker push $REPO_URI:latest
137+ - docker push $REPO_URI:$IMAGE_TAG
138+ - echo Writing image definitions file...
139+ - printf '[{"name":"%s","imageUri":"%s"}]' "$CONTAINER_NAME" "$REPO_URI:$IMAGE_TAG" | tee imagedefinitions.json
140+ artifacts:
141+ files: imagedefinitions.json
142+ ```
109143
110144# How to get started quickly
111145# quickstart: |-
You can’t perform that action at this time.
0 commit comments