- 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 startingssh-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
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
- Install
pm2
bynpm 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 byapt
).
{
"apiKey": ,
"config": [{
"start": "2018-11-16",
"end": "2018-11-20",
"per": 60
}
]
}