-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
58 lines (53 loc) · 2.68 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
version: 0.2
env:
variables:
ENVIRONMENT: "dev"
IMAGE_NAME: "dev-swsoc-docker-lambda-base"
phases:
pre_build:
commands:
- |
echo Logging in to Amazon ECR...
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/w5r9l1c8
if git describe --tags --exact-match > /dev/null 2>&1; then
echo "This is a tag push event"
ENVIRONMENT="prod"
IMAGE_NAME="swsoc-docker-lambda-base"
GIT_TAG=`git describe --tags --exact-match`
elif [[ "${CDK_ENVIRONMENT}" == "PRODUCTION" ]]; then
echo "This is a production environment"
ENVIRONMENT="prod"
IMAGE_NAME="swsoc-docker-lambda-base"
GIT_TAG=`date -u +"%Y%m%d%H%M%S"`
else
echo "This is a development environment"
GIT_TAG=`date -u +"%Y%m%d%H%M%S"`
fi
build:
commands:
- |
echo Build started on `date`
echo Building the Docker image...
docker build -t ${IMAGE_NAME}:${ENVIRONMENT}-${GIT_TAG} .
docker tag ${IMAGE_NAME}:${ENVIRONMENT}-${GIT_TAG} public.ecr.aws/w5r9l1c8/${IMAGE_NAME}:${ENVIRONMENT}-${GIT_TAG}
docker tag ${IMAGE_NAME}:${ENVIRONMENT}-${GIT_TAG} public.ecr.aws/w5r9l1c8/${IMAGE_NAME}:latest
curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64 && chmod +x container-structure-test-linux-amd64 && sudo mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test
sudo yum install python3-pip -y
sudo yum install make graphviz -y
pip3 install -r requirements.txt
make html
echo CST Testing
container-structure-test test --image ${IMAGE_NAME}:${ENVIRONMENT}-${GIT_TAG} --config cst_config.yaml
echo Pushing the Docker image...
docker push public.ecr.aws/w5r9l1c8/${IMAGE_NAME}:${ENVIRONMENT}-${GIT_TAG}
docker push public.ecr.aws/w5r9l1c8/${IMAGE_NAME}:latest
PUBLIC_ECR_REPO=public.ecr.aws/w5r9l1c8/${IMAGE_NAME}:${ENVIRONMENT}-${GIT_TAG}
echo Starting aws_processing_lambda CodeBuild project...
aws codebuild start-build --project-name build_sdc_aws_processing_lambda \
--environment-variables-override name=CDK_ENVIRONMENT,value=$CDK_ENVIRONMENT,type=PLAINTEXT \
--environment-variables-override name=ENVIRONMENT,value=$ENVIRONMENT,type=PLAINTEXT \
--environment-variables-override name=GIT_TAG,value=$GIT_TAG,type=PLAINTEXT \
--environment-variables-override name=PUBLIC_ECR_REPO,value=$PUBLIC_ECR_REPO,type=PLAINTEXT
post_build:
commands:
- echo Build completed on `date`