forked from Vijaygawate/Blue-Green-Deployment-On-ECS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
55 lines (52 loc) · 1.85 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
55
version: 0.2
env:
variables:
AWS_REGION: ap-south-1 # checkfor specific region
AWS_ACCOUNT_ID: 281290702866
IMAGE_NAME: bluegreenrepo
phases:
install:
runtime-versions:
nodejs: 16
commands:
# - echo Installing Mocha...
# - npm install -g mocha (test)
pre_build:
commands:
- echo Installing source NPM dependencies...
- npm install
# - npm install unit.js
- echo Setting up docker
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 &
- timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
- echo Logging in to Amazon ECR...
- aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
build:
commands:
- echo Build started on `date`
- echo Compiling the Node.js code
# - mocha test.js
post_build:
commands:
- docker image build -t $IMAGE_NAME .
- docker image tag $IMAGE_NAME:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_NAME:latest
- echo image name = $IMAGE_NAME:latest
- echo image url = $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_NAME:latest
- docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_NAME:latest
- echo Writing image definitions file...
- printf '{"ImageURI":"'"$AWS_ACCOUNT_ID"'.dkr.ecr.'"$AWS_REGION"'.amazonaws.com/'"$IMAGE_NAME"':latest"}' > imageDetail.json
- cat imageDetail.json
- echo Build completed on `date`
artifacts:
files:
- 'image*.json'
- 'appspec.yml'
- 'taskdef.json'
secondary-artifacts:
DefinitionArtifact:
files:
- appspec.yml
- taskdef.json
ImageArtifact:
files:
- imageDetail.json