modified buildspec

This commit is contained in:
Darren McGhee 2020-04-20 12:08:34 +01:00
parent cbd2de4ec6
commit b0e57c1fa4
2 changed files with 22 additions and 5 deletions

View file

@ -6,14 +6,19 @@ phases:
java: openjdk8
pre_build:
commands:
- echo Nothing to do in prebuild
- AWS_ACC=$(echo $CODEBUILD_BUILD_ARN | cut -d':' -f5)
- REPOSITORY_URI=$AWS_ACC.dkr.ecr.$AWS_REGION.amazonaws.com
build:
commands:
- echo Build started on `date`
- mvn package
- docker build . -t $REPOSITORY_URI/${REPO}:latest
- echo Build completed on `date`
post_build:
commands:
- echo Build completed on `date`
- $(aws ecr get-login --region $AWS_REGION --no-include-email)
- aws ecr describe-repositories --registry-id ${AWS_ACC} --repository-name ${REPO}
- docker push $REPOSITORY_URI/${REPO}:latest
artifacts:
files:
- target/spring-petclinic-2.2.0.BUILD-SNAPSHOT.jar

View file

@ -30,8 +30,13 @@ Resources:
Type: OAUTH
Environment:
ComputeType: BUILD_GENERAL1_SMALL
Image: aws/codebuild/standard:latest
Image: aws/codebuild/standard:3.0
Type: LINUX_CONTAINER
PrivilegedMode: True
EnvironmentVariables:
- Name: REPO
Type: PLAINTEXT
Value: !Ref ECRRepository
LogsConfig:
CloudWatchLogs:
GroupName: !Ref LogGroup
@ -67,5 +72,12 @@ Resources:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
- ecr:GetAuthorizationToken
- PolicyName: ecr
PolicyDocument:
Version: 2012-10-17
Statement:
- Resource: !GetAtt ECRRepository.Arn
Effect: Allow
Action:
- ecr:*