-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
36 lines (30 loc) · 1.16 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
version: 0.2
phases:
pre_build:
commands:
- echo "Connexion à Amazon ECR..."
- aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 267336880231.dkr.ecr.us-east-1.amazonaws.com
- REPOSITORY_URI=267336880231.dkr.ecr.us-east-1.amazonaws.com/lambdacinema
- IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
build:
commands:
- echo "Construction de l'image Docker..."
- docker build -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- echo "Build terminé le $(date)"
- echo "Push des images vers ECR..."
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- echo "Mise à jour de la fonction Lambda..."
- aws lambda update-function-code --function-name Lambdacinema --image-uri $REPOSITORY_URI:latest
- echo "Création de l'artifact imageDetail.json..."
- printf '{"ImageURI":"%s"}' $REPOSITORY_URI:$IMAGE_TAG > imageDetail.json
artifacts:
files:
- imageDetail.json
- appspec.yaml
cache:
paths:
- '/root/.m2/**/*'