forked from alexei-led/pumba
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
52 lines (50 loc) · 2.18 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
version: 0.2
env:
variables:
REPO_NAME: pumba
parameter-store:
GITHUB_TOKEN: PRIVATE_GITHUB_TOKEN
CODECOV_TOKEN: PUMBA_CODECOV_TOKEN
phases:
install:
commands:
# start Docker daemon
- echo "==> starting Docker daemon ..."
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay&
- timeout -t 15 sh -c "until docker info; do echo .; sleep 1; done"
# enrich CODEBUILD variables from git
- chmod +x ./hack/*.sh
- . ./hack/codebuild_extra.sh
# export additional variables
- export FULL_REPO_NAME=${CODEBUILD_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${REPO_NAME}
- export VERSION=$(cat VERSION)
pre_build:
commands:
# loggin to ECR
- echo "==> logging in to Amazon ECR ..."
- $(aws ecr get-login --no-include-email --region $AWS_REGION)
# restore build cache
- echo "==> restoring build cache ..."
- docker pull ${FULL_REPO_NAME}/builder:${CODEBUILD_GIT_BRANCH} || true
- docker pull ${FULL_REPO_NAME}/build-and-test:${CODEBUILD_GIT_BRANCH} || true
- docker pull ${FULL_REPO_NAME}/github-release:${CODEBUILD_GIT_BRANCH} || true
- docker pull ${FULL_REPO_NAME}:${CODEBUILD_GIT_BRANCH} || true
build:
commands:
- echo "==> running multi-stage ..."
- ./hack/codebuild_build.sh
post_build:
commands:
# upload test coverage
- echo "==> uploading code coverage"
- docker run -i --rm -e CI_BUILD_URL=${CODEBUILD_BUILD_URL} -e CI_BUILD_ID=${CODEBUILD_BUILD_ID} ${FULL_REPO_NAME}/build-and-test:${CODEBUILD_GIT_BRANCH}
# push final image
- echo "==> pushing final image ..."
- docker push ${FULL_REPO_NAME}:${CODEBUILD_GIT_BRANCH}
# store build cache
- echo "=> storing build cache ..."
- docker push ${FULL_REPO_NAME}/builder:${CODEBUILD_GIT_BRANCH}
- docker push ${FULL_REPO_NAME}/build-and-test:${CODEBUILD_GIT_BRANCH}
- docker push ${FULL_REPO_NAME}/github-release:${CODEBUILD_GIT_BRANCH}
# for master push versioned image too
- if [ "${CODEBUILD_GIT_BRANCH}" == "master" ]; then docker push ${FULL_REPO_NAME}:${VERSION}; fi