File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ version : 0.2
2+
3+ env :
4+ variables :
5+ IMAGE_TAG : " latest" # Default value for the tag. Can be overridden.
6+
7+ phases :
8+ install :
9+ commands :
10+ - npm install
11+
12+ pre_build :
13+ commands :
14+ - echo "Extracting AWS Account ID from CODEBUILD_BUILD_ARN..."
15+ - export ACCOUNT_ID=$(echo $CODEBUILD_BUILD_ARN | cut -f5 -d ':')
16+ - export repository_name="hotel-app" # Set your repository name here
17+ - echo "Logging into Amazon ECR..."
18+ - aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
19+
20+ build :
21+ commands :
22+ - echo "Building the Docker image..."
23+ - docker build -t $repository_name:$IMAGE_TAG .
24+ - echo "Tagging the Docker image for ECR..."
25+ - docker tag $repository_name:$IMAGE_TAG $ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$repository_name:$IMAGE_TAG
26+ - echo "Pushing the Docker image to ECR..."
27+ - docker push $ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$repository_name:$IMAGE_TAG
28+
29+ post_build :
30+ commands :
31+ - echo Writing image definitions file...
32+ - printf '[{"name":"hotel-app","imageUri":"%s"}]' $ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$repository_name:$IMAGE_TAG > imagedefinitions.json
33+
34+ artifacts :
35+ files : imagedefinitions.json
You can’t perform that action at this time.
0 commit comments