---
# System prepended metadata

title: api.sdc.pelagos.systems

---

provision an ec2 instance and login

set hostname
```bash=
sudo hostnamectl set-hostname api.sdc.pelagos.systems
```

install dependencies
```bash=

# node repo
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -

# yarn repo
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

# packages
sudo apt-get update
sudo apt-get install -y \
  certbot \
  nginx \
  nodejs \
  yarn


sudo npm install pm2@latest -g
```

install certs
```bash=
if [ ! -f /etc/nginx/sites-available/certbot.conf ] || [ -e /etc/nginx/sites-enabled/default ]; then
  test -d /etc/nginx/sites-available || sudo mkdir -p /etc/nginx/sites-available;
  test -d /etc/nginx/sites-enabled || sudo mkdir -p /etc/nginx/sites-enabled;
  sudo curl -sLo /etc/nginx/sites-available/certbot.conf --url https://raw.githubusercontent.com/Manta-Network/rubberneck/main/static/etc/nginx/sites-available/certbot.conf;
  sudo ln -sfr /etc/nginx/sites-available/certbot.conf /etc/nginx/sites-enabled/certbot.conf;
  test -e /etc/nginx/sites-enabled/default && sudo rm /etc/nginx/sites-enabled/default;
  sudo systemctl restart nginx;
fi
sudo certbot certificates &> /dev/null;
sudo curl -sLo /etc/letsencrypt/renewal-hooks/deploy/concat-privkey+fullchain.sh https://gist.githubusercontent.com/grenade/6c1d4fb5d3756042803dc4c569624c46/raw/concat-privkey+fullchain.sh;
sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/concat-privkey+fullchain.sh;

sudo /etc/letsencrypt/renewal-hooks/deploy/concat-privkey+fullchain.sh;
sudo curl -sLo /etc/ssl/dst-root-x3.pem --url https://gist.githubusercontent.com/grenade/6c1d4fb5d3756042803dc4c569624c46/raw/dst-root-x3.pem;
sudo ln -sfr /etc/ssl/dst-root-x3.pem /etc/ssl/ca.pem;
ls -ahl /etc/ssl;
mkdir -p ${HOME}/.postgresql
curl -sLo ${HOME}/.postgresql/root.crt --url https://gist.githubusercontent.com/grenade/6c1d4fb5d3756042803dc4c569624c46/raw/dst-root-x3.pem;
sudo cp /etc/letsencrypt/live/$(hostname -f)/fullchain.pem ${HOME}/.postgresql/postgresql.crt
sudo cp /etc/letsencrypt/live/$(hostname -f)/privkey.pem ${HOME}/.postgresql/postgresql.key
sudo chown -R ${USER}:${USER} ${HOME}/.postgresql
ls -ahl ${HOME}/.postgresql
```

configure nginx
```bash=
for fqdn in sdc.pelagos.systems api.sdc.pelagos.systems; do
  sudo curl \
    --location \
    --output /etc/nginx/sites-available/${fqdn}.conf \
    --url https://gist.githubusercontent.com/grenade/25275efdbb430077d429582f69e93b3d/raw/${fqdn}.conf
  sudo ln -sfr /etc/nginx/sites-available/${fqdn}.conf /etc/nginx/sites-enabled/${fqdn}.conf
done
sudo systemctl daemon-reload
sudo systemctl restart nginx.service
```


publish backend
```bash=
rsync -a \
  ${HOME}/git/Manta-Network/hack_payout_backend \
  ubuntu@api.remunerate.manta.network:/home/ubuntu/api-sdc
```

publish frontend
```bash=
rsync -a \
  ${HOME}/git/Manta-Network/hack_payout_frontend \
  ubuntu@remunerate.manta.network:/home/ubuntu/web-sdc
```

commit changes
```bash=
```


https://gist.githubusercontent.com/grenade/25275efdbb430077d429582f69e93b3d/raw/api.sdc.pelagos.systems.conf
