-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildspec.yml
More file actions
40 lines (36 loc) · 1.51 KB
/
buildspec.yml
File metadata and controls
40 lines (36 loc) · 1.51 KB
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
version: 0.2
phases:
pre_build:
commands:
- echo Working with $REPOSITORY_URI
- echo Logging in to Amazon ECR...
- aws ecr get-login-password --region eu-north-1 | docker login --username AWS --password-stdin $REPOSITORY_URI
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- BUILD_TAG=${COMMIT_HASH:=latest}
build:
commands:
- echo Building image with tag $BUILD_TAG
- echo Build started on `date`
- echo Building the Java Docker image...
- cd java_timetracking
- docker build -t $REPOSITORY_URI/javaapp:latest .
- docker tag $REPOSITORY_URI/javaapp:latest $REPOSITORY_URI/javaapp
- cd ..
- echo Building the React Docker image...
- cd react_timetracking
- docker build -t $REPOSITORY_URI/reactapp:latest .
- docker tag $REPOSITORY_URI/reactapp:latest $REPOSITORY_URI/reactapp
- cd ..
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI/javaapp:latest
- docker push $REPOSITORY_URI/javaapp:$BUILD_TAG
- docker push $REPOSITORY_URI/reactapp:latest
- docker push $REPOSITORY_URI/reactapp:$BUILD_TAG
- echo Writing image definitions file...
- printf '[{"name":"java-container","imageUri":"%s"},{"name":"react-container","imageUri":"%s"}]' $REPOSITORY_URI/javaapp:$BUILD_TAG $REPOSITORY_URI/reactapp:$BUILD_TAG > imagedefinitions.json
artifacts:
files:
- imagedefinitions.json