This repository has been archived by the owner on Aug 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
AWS Deployment
Arkadiusz Żmudzin edited this page Mar 10, 2020
·
33 revisions
This is a guide to deploy our vapor instance to AWS for making the CI/CD pipeline streamlined.
Steps
- Create AWS account
- Select free tier
- Sign into console
- Choose AMI:
- Ubuntu Server 16.04 LTS (HVM), SSD Volume Type
- Choose the 64-bit (x86) option
- Instance Type:
- Choose the t2.micro Instance Type
- Configure Instance
- Default settings
- Add Storage
- Chance Size to: 20 GiB
- Add Tags
- Default settings (no tags)
- Configure Security Groups
- Add a rule: override the default ssh with "myIP/32"
- Review
- Just launch the instance
-
Tags Create a new key pair and name it "username-desktop"
-
Add billing alerts
sudo su
apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get install htop -y
apt-get install unattended-upgrades -y && dpkg-reconfigure -plow unattended-upgrades
apt-get install ntp -y && ntpq -p && service ntp restart
reboot
sudo apt-get install clang libicu-dev libcurl4-openssl-dev lldb git wget unzip -y
sudo apt-get install swift vapor
echo "export PATH=/swift-4.2/usr/bin:\"\${PATH}\"" >> ~/.bashrc
source ~/.bashrc
- clone olWebsite to ~/
- run our custom deploy
We had an issue that port 80 was not accessible from remote because of misconfiguration of iptables
, even when you allow to access your server from every host on every port in EC2 Security Group setup.
To fix that, you need to call this command
sudo iptables -A IN_public_allow -p tcp -m tcp --dport 80 -m conntrack --ctstate NEW -j ACCEPT
- Build new version image
sudo docker build -t oneleif-api:latest -f web.Dockerfile --build-arg env=production .
- Stop previous working version
sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c3788b91c762 oneleif-api "/bin/sh -c './Run s…" 5 minutes ago Up 5 minutes 0.0.0.0:80->80/tcp oneleif-api
sudo docker stop oneleif-api
- Remove old container
sudo docker rm oneleif-api
- Create a new container and start it
sudo docker create -p 80:80 --name oneleif-api oneleif-api
sudo docker start oneleif-api
That's all :)
In order to see the logs of the running container execute this command:
sudo docker logs oneleif-api
Note: if you want to see the logs in real-time, add the -f
option, then Ctrl+C to exit
References:
- prereqs: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connection-prereqs.html
- setup putty: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html
- vapor guide: https://medium.com/swiftybeaver-blog/deployment-of-a-vapor-app-to-aws-ec2-f577eaa6c38c
- vapor install: https://docs.vapor.codes/3.0/install/ubuntu/
- vapor + react: https://www.vaporforums.io/viewThread/25
- vapor nginx: https://docs.vapor.codes/4.0/deploy/nginx/