-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildspec.yml
More file actions
25 lines (24 loc) · 849 Bytes
/
buildspec.yml
File metadata and controls
25 lines (24 loc) · 849 Bytes
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
version: 0.2
phases:
pre_build:
commands:
- docker --version
- echo Logging in Docker Hubs ...
- docker login --username $DOCKER_USER --password $DOCKER_PASS
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
- docker pull $REPO_URL:cache
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker build --cache-from $REPO_URL:cache -t $REPO_URL:latest .
- docker build -t $REPO_URL:latest .
- docker tag $REPO_URL:latest $REPO_URL:$IMAGE_TAG
- docker tag $REPO_URL:latest $REPO_URL:cache
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
- docker push $REPO_URL:cache
- docker push $REPO_URL:$IMAGE_TAG