-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildspec.yml
More file actions
43 lines (36 loc) · 1.47 KB
/
buildspec.yml
File metadata and controls
43 lines (36 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
version: 0.2
env:
variables:
KUBECONFIG: "/root/.kube/config" # Use this to set kubeconfig path globally
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 361769582717.dkr.ecr.ap-south-1.amazonaws.com
- REPOSITORY_URI=361769582717.dkr.ecr.ap-south-1.amazonaws.com/eks-nodejs-repo
- IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- echo Updating kubeconfig...
- mkdir -p ~/.kube
- aws eks update-kubeconfig --region ap-south-1 --name nodejs-eks-cluster
build:
commands:
- echo Building the Docker image...
- docker build -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- echo Pushing Docker image to ECR...
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- echo Writing imagedefinitions.json...
- printf '[{"name":"nodejs-app","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
- echo Verifying cluster access...
- kubectl get svc || echo "kubectl get svc failed"
- echo Deploying to EKS...
- kubectl apply -f deploy/deployment.yaml --validate=false
- kubectl apply -f deploy/service.yaml --validate=false
artifacts:
files:
- imagedefinitions.json
- deploy/deployment.yaml
- deploy/service.yaml