Execute sandboxed code on Discord
Create a language request.
- Copy
.env.example
to.envrc
and fill in the values. - Install sqlx-cli via
cargo
. - Run
sqlx db create
to create the database. - Run
sqlx migrate run
to create the database schema. - Run
cargo run
to start the bot. (optionally usecargo make dev
to run with hot reloading)
If you're developing a new language and don't want to run the bot, you can run the tcp server with cargo run --bin tcp
and connect with nc localhost 8080
.
The .env file requirements are the same except DISCORD_TOKEN can be any random string.
You have to install gVisor as a runtime for docker to provide an additional isolation boundary between the containers and the host kernel.
# source https://gvisor.dev/docs/user_guide/install/#install-latest
(
set -e
ARCH=$(uname -m)
URL=https://storage.googleapis.com/gvisor/releases/release/latest/${ARCH}
wget ${URL}/runsc ${URL}/runsc.sha512 \
${URL}/containerd-shim-runsc-v1 ${URL}/containerd-shim-runsc-v1.sha512
sha512sum -c runsc.sha512 \
-c containerd-shim-runsc-v1.sha512
rm -f *.sha512
chmod a+rx runsc containerd-shim-runsc-v1
sudo mv runsc containerd-shim-runsc-v1 /usr/local/bin
sudo /usr/local/bin/runsc install
sudo systemctl reload docker
)