-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipeline.yaml
46 lines (37 loc) · 1.57 KB
/
azure-pipeline.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
40
41
42
43
44
45
46
pool:
vmImage: ubuntu-18.04
trigger:
- master
stages:
- stage: Prepare
jobs:
- job: BuildAndDeploy
steps:
- bash: |
set -e
# Setup Environment
export AWS_ACCESS_KEY_ID="$(AWS_ACCESS_KEY_ID_ENCRYPTED)"
export AWS_SECRET_ACCESS_KEY="$(AWS_SECRET_ACCESS_KEY_ENCRYPTED)"
export GIT_COMMIT="$(Build.SourceVersion)"
REGISTRY="$(CDK_DEPLOY_ACCOUNT).dkr.ecr.ap-southeast-2.amazonaws.com"
IMAGE_REPOSITORY="$REGISTRY/container-meetup-application"
# Install AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
# Install CDK
sudo npm install -g aws-cdk --allow-root
# Install CDK app for deploying environment and application infrastructure
cd infra
npm install
# Deploy environment infrastructure changes
cdk deploy --require-approval never "container-meetup-environment"
# Build and publish container
cd ..
docker build -t aspnetapp .
docker tag aspnetapp "$IMAGE_REPOSITORY:$GIT_COMMIT"
aws ecr get-login-password | docker login -u AWS --password-stdin "https://$REGISTRY"
docker push "$IMAGE_REPOSITORY:$GIT_COMMIT"
# Deploy the application
cd infra
cdk deploy --require-approval never "container-meetup-application"