-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yaml
39 lines (35 loc) · 1.26 KB
/
buildspec.yaml
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
---
version: 0.2
env:
secrets-manager:
DOCKER_PAT: "docker:pat"
phases:
pre_build:
commands:
- REPOSITORY_URI=542780149388.dkr.ecr.ap-southeast-1.amazonaws.com/ct-logbook-script
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
- echo Logging in to Amazon ECR...
- |-
aws ecr get-login-password --region $AWS_DEFAULT_REGION | \
docker login --username AWS --password-stdin \
542780149388.dkr.ecr.ap-southeast-1.amazonaws.com
build:
commands:
- echo Build started on `date`
- echo Login to Docker Hub
- docker login --username cocatrip --password $DOCKER_PAT
- echo Building the Docker image...
- docker build -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- echo updating lambda function...
- |-
aws lambda update-function-code --function-name ct-logbook-script-LF \
--region $AWS_DEFAULT_REGION \
--image-uri $REPOSITORY_URI:$IMAGE_TAG