forked from dineshonjava/accounts-microservice-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
37 lines (35 loc) · 1.38 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
37
version: 0.2
env:
variables:
JAVA_HOME: "/usr/lib/jvm/java-8-openjdk-amd64"
AWS_DEFAULT_REGION: "us-east-1"
IMAGE_REPO_NAME: "accounts-microservice-server-repo"
IMAGE_TAG: "latest"
parameter-store:
AWS_ACCOUNT_ID: "/CodeBuild/AWS_ACCOUNT_ID"
AWS_ACCESS_KEY_ID: "/CodeBuild/AWS_ACCESS_KEY_ID"
AWS_SECRET_ACCESS_KEY: "/CodeBuild/AWS_SECRET_ACCESS_KEY"
LOGIN_PASSWORD: "/CodeBuild/dockerLoginPassword"
phases:
install:
commands:
- echo Entered the install phase and installing gradle..
- apt-get update -y
- apt-get install -y maven
pre_build:
commands:
- echo Entered the pre_build phase and logging into Amazon ECR..
- $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
build:
commands:
- echo Entered the build phase, Building the Project and Creating a JAR in build/libs using ./gradlew build
- echo Build started on `date`
- mvn clean install
post_build:
commands:
- echo Entered the post_build phase...
- echo Building the docker image..
- docker build -f Dockerfile -t $IMAGE_REPO_NAME .
- echo Pushing the docker image to the ECR..
- docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
- docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME