diff --git a/buildspec.yml b/buildspec.yml index 6faa2d19b..f6133c99b 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -3,17 +3,22 @@ version: 0.2 phases: install: runtime-versions: - java: corretto17 + 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 \ No newline at end of file diff --git a/ecr.yml b/ecr.yml index 5ef7adce7..8dcf607d2 100644 --- a/ecr.yml +++ b/ecr.yml @@ -5,7 +5,3 @@ Parameters: Type: String AllowedPattern: (?:[a-z0-9]+(?:[._-][a-z0-9]+)*/)*[a-z0-9]+(?:[._-][a-z0-9]+)* Resources: - ECRRepository: - Type: AWS::ECR::Repository - Properties: - RepositoryName: !Ref RepoName \ No newline at end of file