-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuildspec.yml
32 lines (31 loc) · 1.34 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
version: 0.2
phases:
pre_build:
commands:
- echo Build started on `date`
- echo Entered the pre_build phase...
- echo Logging in to Amazon ECR...
- $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
- echo Logging in to docker hub...
- echo "$DOCKER_ACCESS_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
- echo Building the Docker image...
- chmod +x docker-entrypoint.sh
- docker build -t $CONTAINER_NAME:test -f docker/web/Dockerfile-prod .
build:
commands:
- echo not Testing the newly built Docker image...
post_build:
commands:
- IMAGE_TAG=commit-$CODEBUILD_RESOLVED_SOURCE_VERSION
- REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_NAME
- echo Tagging the successfully tested image as latest...
- docker tag $CONTAINER_NAME:test $REPOSITORY_URI:latest
- docker tag $CONTAINER_NAME:test $REPOSITORY_URI:$IMAGE_TAG
- echo Pushing the Docker image...
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- echo Build completed on `date`
- echo Writing image definitions file...
- printf '[{"name":"%s","imageUri":"%s"}]' $CONTAINER_NAME $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
artifacts:
files: imagedefinitions.json