Prepare new deployment infrastructure
This commit is contained in:
parent
b4636c46ae
commit
5883cc67c7
|
@ -2,13 +2,11 @@ version: 2
|
|||
jobs:
|
||||
build_and_deploy:
|
||||
docker:
|
||||
- image: docker:18.09
|
||||
- image: alpine
|
||||
steps:
|
||||
- checkout
|
||||
- setup_remote_docker
|
||||
- run: apk add --no-cache --no-progress bash curl make nodejs
|
||||
- run: curl https://cli-assets.heroku.com/install.sh | sh
|
||||
- run: make deploy
|
||||
- run: apk add --no-cache --no-progress bash openssh
|
||||
- run: scripts/deploy.bash
|
||||
workflows:
|
||||
version: 2
|
||||
ci:
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<link rel="stylesheet" href="/css/index.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Riju: online playground for every programming language</h1>
|
||||
<h1>Riju: <i>fast</i> online playground for every programming language</h1>
|
||||
<i>Pick your favorite language to get started:</i>
|
||||
<div class="grid">
|
||||
<% for (const [id, {name}] of Object.entries(langs)) { %>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
systemctl start riju
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
systemctl start riju
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
systemctl stop riju
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
systemctl stop riju
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
tmpdir="$(mktemp -d)"
|
||||
keyfile="${tmpdir}/id"
|
||||
|
||||
if [[ -n "$DEPLOY_KEY" ]]; then
|
||||
printf '%s\n' "$DEPLOY_KEY" | base64 -d > "$keyfile"
|
||||
elif [[ -f "$HOME/.ssh/id_rsa_riju_deploy" ]]; then
|
||||
cp "$HOME/.ssh/id_rsa_riju_deploy" "$keyfile"
|
||||
else
|
||||
echo 'deploy.bash: you must set $DEPLOY_KEY' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ssh -o IdentitiesOnly=yes -i "${keyfile}" deploy@209.141.54.122 /usr/bin/riju-install
|
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import errno
|
||||
import os
|
||||
import re
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
for pid in (
|
||||
subprocess.run(["pgrep", "-x", "riju-install"], check=True, stdout=subprocess.PIPE)
|
||||
.stdout.decode()
|
||||
.splitlines()
|
||||
):
|
||||
print(f"Found existing process {pid}, trying to kill ...", file=sys.stderr)
|
||||
pid = int(pid)
|
||||
os.kill(pid, signal.SIGTERM)
|
||||
while True:
|
||||
time.sleep(0.01)
|
||||
try:
|
||||
os.kill(pid, 0)
|
||||
except OSError as e:
|
||||
if e.errno == errno.ESRCH:
|
||||
break
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
os.chdir(tmpdir.name)
|
||||
subprocess.run(
|
||||
[
|
||||
"git",
|
||||
"clone",
|
||||
"https://github.com/raxod502/riju.git",
|
||||
"--single-branch",
|
||||
"--depth=1",
|
||||
"--no-tags",
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
os.chdir("riju")
|
||||
subprocess.run(["make", "image-prod"], check=True)
|
||||
subprocess.run(["docker", "system", "prune", "-f"], check=True)
|
||||
subprocess.run(["systemctl", "restart", "riju"], check=True)
|
|
@ -2,7 +2,7 @@
|
|||
Description=Riju online coding sandbox
|
||||
|
||||
[Service]
|
||||
ExecStart=docker run -p 0.0.0.0:6119 riju
|
||||
ExecStart=docker run --rm -p 0.0.0.0:80:6119 riju:prod
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
Loading…
Reference in New Issue