-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yml
30 lines (29 loc) · 1.02 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
version: 0.2
phases:
install:
runtime-versions:
python: 3.11
pre_build:
commands:
- echo Logging in to Amazon ECR...
- echo "$(aws ecr get-login-password --region $AWS_DEFAULT_REGION)" | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
- REPOSITORY_URI=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${ECR_REPOSITORY}
- TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- echo Building image $REPOSITORY_URI:latest...
build:
commands:
- docker build -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$TAG
post_build:
commands:
- |
if [ "$CODEBUILD_BUILD_SUCCEEDING" == "1" ]; then
echo Pushing image to Amazon ECR...
docker push $REPOSITORY_URI:latest
docker push $REPOSITORY_URI:$TAG
else
echo Build failed. Not pushing image to Amazon ECR...
fi
artifacts:
name: $(date +%Y-%m-%d)
discard-paths: yes