Instructions on setting up ssh keys for AWS
Set up an AWS instance and download the corresponding private key, here we call it aws.pem
mv aws.pem ~/.ssh
chmod 400 ~/.ssh/aws.pem
eval `ssh-agent -s`
for starting ssh-agent
ssh-add ~/.ssh/aws.pem
to add the private key
Connect by ssh ubuntu@....aws.net
(Optional) Use no-ip
service to use DNS to connect instead
(Optional) Add step 4 and 5 to ~/.bashrc
or ~/.zshrc
to load keys upon booting
Instructions on setting up remote git repo in AWS
mkdir my_project.git && cd my_project.git
git init --bare
mkdir ../my_project
cd hooks && touch post-receive
Add the followings into post-receive
#! bin/sh
GIT_WORK_TREE=~ /my_project git checkout -f
# Can add more scripts to run in aws after receiving git push
chmod +x post-receive
git remote add aws ubuntu@....aws.net
git config --global remote.aws.receivepack "git receive-pack"
Push by git push aws
Instructions on setting up auto deploy in AWS after git push
Install pm2
by npm i -g pm2
Append the following to post-receive
npm install \
&& npm run build \
&& (pm2 delete ' my-app' || true) \
&& pm2 start npm --name ' my-app' -- start
(Optional) View real-time log from local by ssh ubuntu@....aws.net "tail -f ~/my_project/log.log" | ccze
(ccze
is installed by apt
).
Sample POST Configuration
{
"apiKey" : ,
"config" : [{
"start" : " 2018-11-16" ,
"end" : " 2018-11-20" ,
"per" : 60
}
]
}