-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_instructions.txt
69 lines (57 loc) · 2.68 KB
/
build_instructions.txt
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# references:
#
# [1] simple dotnet web app
# https://dotnet.microsoft.com/learn/aspnet/hello-world-tutorial/
#
# [2] howto dockerize dotnet app
# https://docs.docker.com/engine/examples/dotnetcore/
# IMPORTANT: updated info re .NET 5
# https://stackoverflow.com/questions/64844197/docker-image-for-net-5
#
# [3] CDK ecs pattern ApplicationLoadBalancedServiceBase
# https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_ecs_patterns/ApplicationLoadBalancedServiceBase.html#aws_cdk.aws_ecs_patterns.ApplicationLoadBalancedServiceBase
#
# [4] typescript example of using ApplicationLoadBalancedServiceBase
# https://blog.kylegalbraith.com/2019/10/24/how-to-run-docker-containers-via-aws-elastic-container-service/
#
# notes:
# cdk --version 1.97.0+
# dotnet --version 5.0.202+
md ecs-ec2
cd ecs-ec2
cdk init --language python
source # (this activates venv)
python.exe -m pip install --upgrade pip
pip install aws-cdk.core aws_cdk.aws_ecs aws_cdk.aws_ecs_patterns
pip freeze > requirements.txt
# create github project
git remote add origin https://github.com/jrobbins-LiveData/ecs-ec2.git
git branch -M main
git push -u origin main
git add -A
git commit -m "initial commit"
git push
cd ecs_ec2
dotnet new webApp -o myWebApp --no-https
dotnet new gitignore
# added manually created Dockerfile and .dockerignore to myWebApp folder
#
# test locally
docker build -t mywebapp2 .
docker run -p 8080:80 mywebapp2
# open http://localhost:8080/ in your browser
#
cdk deploy
# NOTE: I tried to take advantage of free use of Graviton2 chips
# (until June 30th 2021)
# via instance_type=ec2.InstanceType('t4g.micro')
# but don't know how to specify that hardware platform or even if that is possible
# and after a ONE HOUR wait during deployment, saw this error!
# >> 45/53 | 3:02:14 PM | CREATE_FAILED | AWS::AutoScaling::AutoScalingGroup |
# >> myWebApp-cluster/myWebApp-scaling-group/ASG (myWebAppclustermyWebAppscalinggroupASG878D8358) Group did not stabilize.
# >> {current/minSize/maxSize} group size = {0/1/1}.
# >> Failed Scaling Activity: The architecture 'arm64' of the specified instance type does not match the architecture 'x86_64' of the specified AMI. Specify an instance type and an AMI that have matching architectures, and try again. You can use 'describe-instance-types' or 'describe-images' to discover the architecture of the instance type or AMI. Launching EC2 instance failed.
# Found info on official dotnet images: https://hub.docker.com/_/microsoft-dotnet-aspnet/
# and finally figured out what I needed:
# 1. Dockerfile changes to :5.0-buster-slim-arm64v8
# 2. ecs_ec2\ecs_ec2_stack.py ecs.Cluster.capacity also needs: machine_image=ecs.EcsOptimizedImage.amazon_linux2(ecs.AmiHardwareType.ARM)