-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yml
39 lines (36 loc) · 1.43 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
version: 0.2
env:
git-credential-helper: yes
phases:
install:
runtime-versions:
python: 3.8
commands:
- jq --version || yum install jq -y
- export ACCOUNT_ID=`aws sts get-caller-identity | jq -r .Account`
- echo ACCOUNT ID $ACCOUNT_ID - Region $AWS_REGION
- export DKR_ACCT_URL="${ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com"
- echo $DKR_ACCT_URL
- aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $DKR_ACCT_URL
- if [ -z ${CODEBUILD_BUILD_NUMBER+x} ]; then export TAG=$(date +%s); else export TAG=$CODEBUILD_BUILD_NUMBER; fi
- echo Tag ${TAG} - Account ID $ACCOUNT_ID
- export TAG_URL="${DKR_ACCT_URL}/${ECR_REPO_NAME}:${TAG}"
pre_build:
commands:
- pip --version || curl -s https://bootstrap.pypa.io/get-pip.py | python
- pip install --upgrade -r requirements.txt
- pip install --upgrade -r requirements_dev.txt
build:
commands:
- docker build -t ${TAG_URL} .
- docker push ${TAG_URL} |tee push.log && echo ${TAG_URL} > image_url.txt
- export IMAGE_SHA=`grep digest push.log | awk '{print $3}'`
- echo "repo_name^ ${ECR_REPO_NAME}" > build_info.yml
- echo "image_tag^ ${IMAGE_SHA}" >> build_info.yml
- echo "service_name^ ${SERVICE_NAME}" >> build_info.yml
- sed 's/\^/\:/g' -i build_info.yml
artifacts:
name: ImageId
files:
- image_url.txt
- build_info.yml