-
Notifications
You must be signed in to change notification settings - Fork 542
/
buildspec.yml
54 lines (53 loc) · 2.08 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
version: 0.2
env:
variables:
JAVA_HOME: "/usr/lib/jvm/java-8-openjdk-amd64"
DOCKER_REPO_USER: "ibuchh"
DOCKER_REPO_NAME: "petclinic-spinnaker-jenkins"
ECR_REPOSITORY_URI: "890123456789.dkr.ecr.us-east-1.amazonaws.com/petclinic"
parameter-store:
LOGIN_PASSWORD: /CodeBuild/dockerLoginPassword
LOGIN_USER: /CodeBuild/dockerLoginUser
phases:
install:
runtime-versions:
java: openjdk8
commands:
- echo Entered the install phase...
- apt-get update -y
- apt-get install -y maven
finally:
- echo This always runs even if the update or install command fails
pre_build:
commands:
- echo Entered the pre_build phase..
#- $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)
- docker login --username ibuchh --password $LOGIN_PASSWORD
- docker login –u $LOGIN_USER –p $LOGIN_PASSWORD
- IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- DOCKER_REPO_URL=$DOCKER_REPO_USER/$DOCKER_REPO_NAME
- mvn clean package
finally:
- echo This always runs even if the login command fails
build:
commands:
- echo build Docker image on `date`
- curr_working_dir=`pwd`
#- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
- docker build -t $DOCKER_REPO_NAME:$IMAGE_TAG .
- docker build -t $DOCKER_REPO_NAME:latest .
- docker tag $DOCKER_REPO_NAME:$IMAGE_TAG $DOCKER_REPO_URL:$IMAGE_TAG
- docker tag $DOCKER_REPO_NAME:latest $DOCKER_REPO_URL:latest
post_build:
commands:
- echo build Docker image complete `date`
- echo push latest Docker images to Dokcer Hub ...
- docker push $DOCKER_REPO_URL:$IMAGE_TAG
- docker push $DOCKER_REPO_URL:latest
- export IMAGE_NAME='petclinic'
- export IMAGE_URI=$DOCKER_REPO_URL:$IMAGE_TAG
- "printf '[{\"name\":\"%s\",\"imageUri\":\"%s\"}]' \"$IMAGE_NAME\" \"$IMAGE_URI\" > imagedefinitions.json"
#- printf '[{"name":"$IMAGE_NAME","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > taskdefinition.json
artifacts:
files:
- imagedefinitions.json