Create buildspec.yml
This commit is contained in:
parent
53f2528094
commit
193e1797f6
1 changed files with 33 additions and 0 deletions
33
src/frontend/buildspec.yml
Normal file
33
src/frontend/buildspec.yml
Normal file
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
version: 0.2
|
||||
phases:
|
||||
install:
|
||||
commands:
|
||||
- curl -sS -o aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-07-26/bin/linux/amd64/aws-iam-authenticator
|
||||
- curl -sS -o kubectl https://amazon-eks.s3-us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/linux/amd64/kubectl
|
||||
- chmod +x ./kubectl ./aws-iam-authenticator
|
||||
- export PATH=$PWD/:$PATH
|
||||
- apt-get update && apt-get -y install jq python3-pip python3-dev && pip3 install --upgrade awscli
|
||||
pre_build:
|
||||
commands:
|
||||
- TAG="$REPOSITORY_NAME.$REPOSITORY_BRANCH.$ENVIRONMENT_NAME.$(date +%Y-%m-%d.%H.%M.%S).$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)"
|
||||
- sed -i 's@CONTAINER_IMAGE@'"$REPOSITORY_URI:$TAG"'@' hello-k8s.yml
|
||||
- $(aws ecr get-login --no-include-email)
|
||||
- export KUBECONFIG=$HOME/.kube/config
|
||||
build:
|
||||
commands:
|
||||
- docker build --tag $REPOSITORY_URI:$TAG .
|
||||
|
||||
post_build:
|
||||
commands:
|
||||
- docker push $REPOSITORY_URI:$TAG
|
||||
- CREDENTIALS=$(aws sts assume-role --role-arn $EKS_KUBECTL_ROLE_ARN --role-session-name codebuild-kubectl --duration-seconds 900)
|
||||
- export AWS_ACCESS_KEY_ID="$(echo ${CREDENTIALS} | jq -r '.Credentials.AccessKeyId')"
|
||||
- export AWS_SECRET_ACCESS_KEY="$(echo ${CREDENTIALS} | jq -r '.Credentials.SecretAccessKey')"
|
||||
- export AWS_SESSION_TOKEN="$(echo ${CREDENTIALS} | jq -r '.Credentials.SessionToken')"
|
||||
- export AWS_EXPIRATION=$(echo ${CREDENTIALS} | jq -r '.Credentials.Expiration')
|
||||
- aws eks update-kubeconfig --name $EKS_CLUSTER_NAME
|
||||
- kubectl apply -f hello-k8s.yml
|
||||
- printf '[{"name":"hello-k8s","imageUri":"%s"}]' $REPOSITORY_URI:$TAG > build.json
|
||||
artifacts:
|
||||
files: build.json
|
Loading…
Add table
Add a link
Reference in a new issue