Personal log of what I did to set up an aws instance that watches the git repo.
- Log on to aws, launch a new t2.micro instance using aws-linux.
- Log on to the instance
- set up docker:
Then log out and log back in.
sudo yum update -y sudo amazon-linux-extras install docker sudo service docker start sudo usermod -a -G docker ec2-user
- Clone lean
sudo yum install -y git git clone https://github.com/EdAyers/lean.git cd lean git checkout widget
- Build the lean emscripten. An alternative is to pull the archive from the github action. But I thought it would be good to have it all done locally.
mkdir -p build/emscripten cd build/release docker run -dit --name emscripten -v $(pwd):/src edayers/emscripten bash docker exec -it -w /src/build/emscripten emscripten emconfigure cmake /src/src -DCMAKE_BUILD_TYPE=Emscripten -DLEAN_EMSCRIPTEN_BUILD=Main docker exec -it -w /src/build/emscripten -e NODE_OPTIONS="--max-old-space-size=4096" emscripten emmake make
- Build lean
sudo yum groupinstall "Development Tools" sudo yum install gmp-devel mkdir -p build/release cd build/release cmake ../../src make
- Install elan
sudo amazon-linux-extras install python3 curl https://raw.githubusercontent.com/Kha/elan/master/elan-init.sh -sSf | bash -s -- --default-toolchain none -y elan toolchain link local $(pwd)/lean
- build the lean-web-editor
Install node
git clone https://github.com/EdAyers/lean-web-editor.git git checkout widget cd lean-web-editor elan override set local npm i mkdir dist cp ~/lean/build/emscripten/shell/lean_js_* ./dist ./mk_library.py npm run build
- Give the instance a public IP address. Go to the EC2 console. Go to 'elastic IPs'. Click allocate IP address. Use Amazon's pool of IPv4 addresses, hit the allocate button. Click on the newly made IP address and click 'associate', then associate it with the EC2 instance you made. Now your instance has a public IP address but you still need to open up the ports.
- Open the ports. Go to 'security groups' tab,create a security group. Then add a load of 'inbound rules':
Then you make it so that the EC2 instance is a member of this security group.Type Protocol Port range Source HTTP TCP 80 0.0.0.0/0 HTTP TCP 80 ::/0 SSH TCP 22 0.0.0.0/0 SSH TCP 22 ::/0 HTTPS TCP 443 0.0.0.0/0 HTTPS TCP 443 ::/0 - Set up the domain name. I went to my domain registrar and made an 'A record' pointing
demo.edayers.com
to the IP address made by the previous step. - set up apache webserver.
- Set up HTTPS and "let's encrypt" Install certbot with some convoluted installer magic. `` sudo wget -r --no-parent -A 'epel-release-.rpm' http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/ sudo rpm -Uvh dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-.rpm sudo yum-config-manager --enable epel* sudo yum repolist all
Replace `Listen 80` in `/etc/httpd/conf/httpd.conf` with
<VirtualHost *:80> DocumentRoot "/var/www/html" ServerName "example.com" ServerAlias "www.example.com"
sudo systemctl restart httpd sudo yum install -y certbot python2-certbot-apache sudo certbot
Then follow the instructions.
Finally add a cron job so that it automatically renews. Add this to `/etc/crontab`
39 1,13 * * * root certbot renew --no-self-upgrade
then run
sudo systemctl restart crond
14. Copy the contents of dist to `/var/www/html`.
```
cp ./dist/* /var/www/html
```
1. [ ] make a chron job that checks the github repos and rebuilds, redeploys everything.