forked from aws-samples/devsecops-cicd-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec-prod.yml
32 lines (32 loc) · 1.41 KB
/
buildspec-prod.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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
version: 0.2
phases:
install:
commands:
- echo "in the install phase"
- curl -sS -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.18.9/2020-11-02/bin/linux/amd64/kubectl
- chmod +x ./kubectl
- apt-get update && apt-get -y install jq python3-pip python3-dev && pip3 install --upgrade awscli
finally:
- echo "This always runs even if the login command fails"
pre_build:
commands:
- echo "inside pre_build stage"
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://0.0.0.0:2375 --storage-driver=overlay&
- timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
- echo "prod pre_build completed"
build:
commands:
- cd $CODEBUILD_SRC_DIR
- $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
post_build:
commands:
- echo "inside post_buil .. deploying build"
- bash -c "if [ /"$CODEBUILD_BUILD_SUCCEEDING/" == /"0/" ]; then exit 1; fi"
- aws eks update-kubeconfig --name $EKS_PROD_CLUSTER_NAME
- kubectl patch deployment wordpress-deployment -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"build\":\"prod-123456\"}}}}}}"
- printf '[{"name":"prod-deployment","imageUri":"%s"}]' $REPOSITORY_URI:$TAG > build.json
artifacts:
type: zip
files: '**/*'