-
Notifications
You must be signed in to change notification settings - Fork 183
Expand file tree
/
Copy pathbuildspec.yaml
More file actions
36 lines (35 loc) · 1.94 KB
/
buildspec.yaml
File metadata and controls
36 lines (35 loc) · 1.94 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
version: 0.2
env:
variables:
NODE_EXPORTER_VERSION: "v1.9.0"
PROCFS_EXPORTER_VERSION: "v0.16.0"
exported-variables:
- NODE_EXPORTER_VERSION
- PROCFS_EXPORTER_VERSION
- GOLANG_VERSION
phases:
pre_build:
commands:
- export TAG="node-exporter${NODE_EXPORTER_VERSION}-procs${PROCFS_EXPORTER_VERSION}"
- echo "TAG=$TAG"
- export REPO_COUNT="$(aws ecr describe-repositories | grep repositoryName | grep \"${ECR_REPOSITORY_NAME}\" | wc -l)"
- if [ "$REPO_COUNT" == 0 ]; then aws ecr create-repository --repository-name ${ECR_REPOSITORY_NAME}; else echo "Repository ${ECR_REPOSITORY_NAME} already exists"; fi
build:
commands:
- export REPO_URI="$(aws ecr describe-repositories | grep repositoryUri | grep /${ECR_REPOSITORY_NAME}\" | cut -d '"' -f 4)"
- echo "REPO_URI=$REPO_URI"
- echo "Building ${REPO_URI}:${TAG} ..."
- cd 4.validation_and_observability/3.efa-node-exporter && docker image build --build-arg NODE_EXPORTER_VERSION=$NODE_EXPORTER_VERSION --build-arg PROCFS_EXPORTER_VERSION=$PROCFS_EXPORTER_VERSION -t ${REPO_URI}:${TAG} -f ./Dockerfile .
post_build:
commands:
- export ECR_URI=${REPO_URI%"/${ECR_REPOSITORY_NAME}"}
- echo "Logging in to ECR_URI $ECR_URI"
- aws ecr get-login-password | docker login --username AWS --password-stdin ${ECR_URI}
- docker image push ${REPO_URI}:${TAG}
- docker image tag ${REPO_URI}:${TAG} ${REPO_URI}:latest
- docker image push ${REPO_URI}:latest
- aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
- docker image tag ${REPO_URI}:${TAG} public.ecr.aws/hpc-cloud/${ECR_REPOSITORY_NAME}:${TAG}
- docker image tag ${REPO_URI}:${TAG} public.ecr.aws/hpc-cloud/${ECR_REPOSITORY_NAME}:latest
- docker push public.ecr.aws/hpc-cloud/${ECR_REPOSITORY_NAME}:${TAG}
- docker push public.ecr.aws/hpc-cloud/${ECR_REPOSITORY_NAME}:latest