commit the backend!!!! 🎉

This commit is contained in:
2020-06-10 11:38:57 -04:00
parent f810c0d393
commit 505e814d8c
9 changed files with 295 additions and 6 deletions
+16
View File
@@ -0,0 +1,16 @@
# /lib/systemd/system/y2k.service
[Unit]
Description=y2k websockets
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=root
ExecStart=/root/y2k/backend/server/socket.sh
[Install]
WantedBy=multi-user.target
+63
View File
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
# you probably shouldn't just run this! ;)
set -euxo pipefail
#### install basic requirements ####
apt-get -y update
apt-get -y dist-upgrade
apt-get -y --no-install-recommends install \
apt-transport-https \
ca-certificates \
gnupg-agent \
software-properties-common \
curl \
wget \
unzip
#### install papertrail logging ####
wget -qO - --header="X-Papertrail-Token: CHANGEMECHANGEMECHANGEME" \
https://papertrailapp.com/destinations/CHANGEME/setup.sh | bash
#### docker fixes ####
# sed -i 's/\(GRUB_CMDLINE_LINUX="\)"/\1cgroup_enable=memory swapaccount=1"/' /etc/default/grub
# update-grub
#### install Docker from official repository ####
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io
#### install websocketd ####
wget https://github.com/joewalnes/websocketd/releases/download/v0.3.1/websocketd-0.3.1-linux_amd64.zip
unzip websocketd-0.3.1-linux_amd64.zip
chmod +x websocketd
mv websocketd /usr/bin/
#### install cloudflared ####
wget https://bin.equinox.io/c/VdrWdbjqyF/cloudflared-stable-linux-amd64.deb
dpkg -i cloudflared-stable-linux-amd64.deb
cloudflared update
cloudflared tunnel login
cloudflared service install
systemctl enable cloudflared
systemctl start cloudflared
#### clone repository ####
git clone https://github.com/jakejarvis/y2k.git /root/y2k
#### pull Docker image ####
docker login
docker pull jakejarvis/y2k:latest
#### enable & start service ####
cp /root/y2k/backend/server/example.service /lib/systemd/system/y2k.service
systemctl daemon-reload
systemctl enable y2k
systemctl start y2k
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
/usr/bin/websocketd \
--port=80 \
--binary \
--header-ws="Sec-WebSocket-Protocol: binary" \
--origin=y2k.land,www.y2k.land,y2k.jakejarvis.workers.dev \
-- \
docker run \
--cpus 1 \
--memory 200m \
--network none \
--log-driver none \
--rm -i \
jakejarvis/y2k:latest
# NOTE: if not using Docker, the command is:
# /root/y2k/backend/bin/boot.rb /root/y2k/backend/hdd /usr/bin/qemu-system-i386