@@ -16,6 +16,12 @@ phases:
16
16
commands :
17
17
- echo Logging in to Docker Hub...
18
18
- 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}
19
25
20
26
build :
21
27
# This will build and push the docker image to ECR and package the
@@ -29,25 +35,17 @@ phases:
29
35
30
36
- cd $CODEBUILD_SRC_DIR
31
37
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"
36
42
37
43
- echo "Building Docker Image..."
38
44
- IMAGE_NAME=aiproxy
39
45
- IMAGE_TAG=${CODEBUILD_RESOLVED_SOURCE_VERSION:0:7} # short commit hash
40
46
- docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .
41
47
42
- - echo "Running Unit Tests..."
43
- - echo "This is where I would run my unit tests"
44
-
45
48
- 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
-
51
49
- docker tag ${IMAGE_NAME}:${IMAGE_TAG} ${ECR_REPOSITORY}:${IMAGE_TAG}
52
50
- docker tag ${IMAGE_NAME}:${IMAGE_TAG} ${ECR_REPOSITORY}:latest
53
51
- docker push ${ECR_REPOSITORY}:${IMAGE_TAG}
0 commit comments