generated from Conatus-Team/TemplateRepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
36 lines (34 loc) · 1.62 KB
/
buildspec.yml
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
version: 0.2
paths:
# Maven 패키지 설치 장소
- '/root/.m2/**/*'
phases:
install:
runtime-versions:
java: corretto11
commands:
- aws configure set aws_access_key_id $KEY_ID --profile $EKS_PROFILE
- aws configure set aws_secret_access_key $SECRET_KEY --profile $EKS_PROFILE
pre_build:
commands:
- echo Logging in to Amazon ECR...
- $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)
# - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin DOCKER_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
build:
commands:
- echo Build started on `date`
- echo Building the source code using maven
- mvn clean package -DskipTests -Dspring-boot.run.profiles=$PROFILE
- echo Building the Docker image...
- docker build --build-arg PROFILE=$PROFILE -t $IMAGE_REPO_NAME:$IMAGE_TAG .
- docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker image...
- docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
- aws eks --region $AWS_DEFAULT_REGION update-kubeconfig --name $EKS_CLUSTER --profile $EKS_PROFILE
- kubectl apply -n $EKS_NAMESPACE -f kubernetes/deployment.yml
- kubectl apply -n $EKS_NAMESPACE -f kubernetes/service.yml
- kubectl -n $EKS_NAMESPACE scale deploy $EKS_DEPLOY --replicas=0
- kubectl -n $EKS_NAMESPACE scale deploy $EKS_DEPLOY --replicas=1