forked from betuah/lks-course-order
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
52 lines (47 loc) · 1.76 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
version: 0.2
run as: root
env:
variables:
ECR_REGION: us-east-1
CONTAINER_NAME: lks-order-container
IMAGE_REPO: lks-order-image
phases:
install:
runtime-versions:
docker: 20
nodejs: 16
pre_build:
commands:
- echo "Installing dependencies and login into ECR"
- aws ecr get-login-password --region $ECR_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$ECR_REGION.amazonaws.com
- ECR_REPO=$AWS_ACCOUNT_ID.dkr.ecr.$ECR_REGION.amazonaws.com/$IMAGE_REPO
- echo AWS_ACCESS_KEY=${AWS_ACCESS_KEY} >> .env.production
- echo AWS_SECRET_KEY=${AWS_SECRET_KEY} >> .env.production
- echo AWS_DYNAMODB_TABLE_PROD=${AWS_DYNAMODB_TABLE_PROD} >> .env.production
- echo AWS_REGION=${AWS_REGION} >> .env.production
- echo AWS_ACCESS_KEY=${AWS_ACCESS_KEY} >> .env.testing
- echo AWS_SECRET_KEY=${AWS_SECRET_KEY} >> .env.testing
- echo AWS_DYNAMODB_TABLE_TEST=${AWS_DYNAMODB_TABLE_TEST} >> .env.testing
- echo AWS_REGION=${AWS_REGION} >> .env.testing
- cat .env.testing
- cat .env.production
build:
commands:
- echo "Run unit testing and build docker image"
- npm install
- npm run test
- docker build -t $AWS_ACCOUNT_ID.dkr.ecr.$ECR_REGION.amazonaws.com/$IMAGE_REPO:$IMAGE_TAG -f Dockerfile .
post_build:
commands:
- echo "Push image to ECR"
- docker push $AWS_ACCOUNT_ID.dkr.ecr.$ECR_REGION.amazonaws.com/$IMAGE_REPO:$IMAGE_TAG
- printf '[{"name":"%s","imageUri":"%s"}]' $CONTAINER_NAME $ECR_REPO:$IMAGE_TAG > imagedefinitions.json
- echo "Build Complete"
reports:
test-report:
files: 'report/test-result.xml'
file-format: JUnitXml
artifacts:
files:
- imagedefinitions.json
- Dockerrun.aws.json