This repository has been archived by the owner on Aug 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yml
36 lines (35 loc) · 1.66 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
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 Building the Docker image...
- chmod +x docker-entrypoint.sh
- docker build --build-arg RAILS_ENV=$INFRA_ENV --build-arg GITHUB_TOKEN=$GIT_PASSWORD -t $CONTAINER_NAME:test .
build:
commands:
- echo Testing the newly built Docker image...
- docker run --name test -d -e RAILS_ENV=test $CONTAINER_NAME:test /bin/bash -c "tail -f /dev/null"
- git config --global credential.helper store
- git config --global url."https://github.com/".insteadOf 'git@github.com:'
- echo "https://$GIT_USERNAME:$GIT_PASSWORD@github.com" > /root/.git-credentials
- docker exec test bundle install --with test --retry 3 --jobs 20
- docker rm -f test
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