Skip to content

Commit 1b2f202

Browse files
login to ecr earlier and use lint script
1 parent 2d1f845 commit 1b2f202

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

cicd/3-app/aiproxy/buildspec.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ phases:
1616
commands:
1717
- echo Logging in to Docker Hub...
1818
- echo $DOCKER_HUB_PAT | docker login -u $DOCKER_HUB_USERNAME --password-stdin
19+
20+
- echo "Logging in to AWS ECR..."
21+
- ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
22+
- AWS_REGION=us-east-1
23+
- ECR_REGISTRY="${ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com"
24+
- aws ecr get-login-password --region ${AWS_REGION} | docker login --username AWS --password-stdin ${ECR_REGISTRY}
1925

2026
build:
2127
# This will build and push the docker image to ECR and package the
@@ -29,25 +35,17 @@ phases:
2935

3036
- cd $CODEBUILD_SRC_DIR
3137

32-
- echo "Validating Cloudformation Templates..."
33-
- cfn-lint cicd/1-setup/*.template.yml
34-
- cfn-lint cicd/2-cicd/*.template.yml
35-
- cfn-lint cicd/3-app/aiproxy/template.yml
38+
- ./ci-lint.sh
39+
40+
- echo "Running Unit Tests..."
41+
- echo "This is where I would run my unit tests"
3642

3743
- echo "Building Docker Image..."
3844
- IMAGE_NAME=aiproxy
3945
- IMAGE_TAG=${CODEBUILD_RESOLVED_SOURCE_VERSION:0:7} # short commit hash
4046
- docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .
4147

42-
- echo "Running Unit Tests..."
43-
- echo "This is where I would run my unit tests"
44-
4548
- echo "Pushing Docker Image to ECR..."
46-
- ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
47-
- AWS_REGION=us-east-1
48-
- ECR_REGISTRY="${ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com"
49-
- aws ecr get-login-password --region ${AWS_REGION} | docker login --username AWS --password-stdin ${ECR_REGISTRY}
50-
5149
- docker tag ${IMAGE_NAME}:${IMAGE_TAG} ${ECR_REPOSITORY}:${IMAGE_TAG}
5250
- docker tag ${IMAGE_NAME}:${IMAGE_TAG} ${ECR_REPOSITORY}:latest
5351
- docker push ${ECR_REPOSITORY}:${IMAGE_TAG}

0 commit comments

Comments
 (0)