From 219364af97dae1ee962fc7b7cf45759cf5b578f6 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 02:27:31 +1300 Subject: [PATCH 01/18] packer-based lxc container building Fills the simple installation void --- .gitignore | 1 + container/install.sh | 4 +++ container/lxc.conf | 7 +++++ container/piston.pkr.hcl | 41 +++++++++++++++++++++++++ container/readme.md | 7 +++++ container/steps/000-wait-for-network.sh | 6 ++++ container/steps/001-dependencies.sh | 20 ++++++++++++ container/steps/100-python2.sh | 15 +++++++++ container/steps/110-python3.sh | 17 ++++++++++ container/steps/111-paradoc.sh | 7 +++++ container/steps/120-node.sh | 12 ++++++++ container/steps/121-typescript.sh | 6 ++++ container/steps/130-golang.sh | 11 +++++++ container/steps/140-php.sh | 12 ++++++++ container/steps/150-rust.sh | 10 ++++++ container/steps/160-swift.sh | 9 ++++++ container/steps/170-nasm.sh | 12 ++++++++ container/steps/180-java.sh | 9 ++++++ container/steps/190-jelly.sh | 9 ++++++ container/steps/200-julia.sh | 9 ++++++ container/steps/210-kotlin.sh | 10 ++++++ container/steps/220-elixar-erlang.sh | 19 ++++++++++++ container/steps/230-emacs.sh | 13 ++++++++ container/steps/240-lua.sh | 11 +++++++ container/steps/250-haskell.sh | 6 ++++ container/steps/260-deno.sh | 9 ++++++ container/steps/270-brainfuck.sh | 8 +++++ container/steps/280-crystal.sh | 9 ++++++ container/steps/290-d.sh | 11 +++++++ container/steps/300-zig.sh | 11 +++++++ container/steps/310-nim.sh | 12 ++++++++ container/steps/900-runner-users.sh | 11 +++++++ container/steps/910-cleanup.sh | 12 ++++++++ readme.md | 5 ++- 34 files changed, 370 insertions(+), 1 deletion(-) create mode 100755 container/install.sh create mode 100644 container/lxc.conf create mode 100644 container/piston.pkr.hcl create mode 100644 container/readme.md create mode 100644 container/steps/000-wait-for-network.sh create mode 100644 container/steps/001-dependencies.sh create mode 100644 container/steps/100-python2.sh create mode 100644 container/steps/110-python3.sh create mode 100644 container/steps/111-paradoc.sh create mode 100644 container/steps/120-node.sh create mode 100644 container/steps/121-typescript.sh create mode 100644 container/steps/130-golang.sh create mode 100644 container/steps/140-php.sh create mode 100644 container/steps/150-rust.sh create mode 100644 container/steps/160-swift.sh create mode 100644 container/steps/170-nasm.sh create mode 100644 container/steps/180-java.sh create mode 100644 container/steps/190-jelly.sh create mode 100644 container/steps/200-julia.sh create mode 100644 container/steps/210-kotlin.sh create mode 100644 container/steps/220-elixar-erlang.sh create mode 100644 container/steps/230-emacs.sh create mode 100644 container/steps/240-lua.sh create mode 100644 container/steps/250-haskell.sh create mode 100644 container/steps/260-deno.sh create mode 100644 container/steps/270-brainfuck.sh create mode 100644 container/steps/280-crystal.sh create mode 100644 container/steps/290-d.sh create mode 100644 container/steps/300-zig.sh create mode 100644 container/steps/310-nim.sh create mode 100644 container/steps/900-runner-users.sh create mode 100644 container/steps/910-cleanup.sh diff --git a/.gitignore b/.gitignore index 764c63f..0e31c49 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ api/api lxc/i lxc/lockfile +container/output-* \ No newline at end of file diff --git a/container/install.sh b/container/install.sh new file mode 100755 index 0000000..565b767 --- /dev/null +++ b/container/install.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +packer build piston.pkr.hcl +cd output-piston-bionic && mkdir -p /var/lib/lxc/piston && cd /var/lib/lxc/piston && cp "$OLDPWD/lxc-config" config && tar -xzf "$OLDPWD/rootfs.tar.gz" \ No newline at end of file diff --git a/container/lxc.conf b/container/lxc.conf new file mode 100644 index 0000000..be15450 --- /dev/null +++ b/container/lxc.conf @@ -0,0 +1,7 @@ +lxc.net.0.type = empty + +lxc.include = /usr/share/lxc/config/ubuntu.common.conf +lxc.arch = x86_64 + +lxc.rootfs.path = /var/lib/lxc/piston/rootfs +lxc.uts.name = piston \ No newline at end of file diff --git a/container/piston.pkr.hcl b/container/piston.pkr.hcl new file mode 100644 index 0000000..d3e10de --- /dev/null +++ b/container/piston.pkr.hcl @@ -0,0 +1,41 @@ +variable "make_threads" { + type = number + default = 8 +} + +variable "apt_mirror" { + type = string + default = "http://mirror.math.princeton.edu/pub/ubuntu" +} + +source "lxc" "piston-bionic" { + config_file = "lxc.conf" + attach_options = ["--clear-env"] + + # Base of Ubuntu Bionic (amd64) + template_name = "download" + template_parameters = [ + "--dist", "ubuntu", + "--release", "bionic", + "--arch", "amd64" + ] + +} + +build { + sources = ["source.lxc.piston-bionic"] + provisioner "shell" { + # Make sure /opt/.profile exists + inline = ["touch /opt/.profile"] + } + + provisioner "shell" { + scripts = fileset(".", "steps/*.sh") + execute_command = "chmod +x {{ .Path }}; . /opt/.profile; {{ .Vars }} bash {{ .Path }}" + environment_vars = [ + #"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + "MAKE_THREADS=${var.make_threads}", + "APT_MIRROR=${var.apt_mirror}" + ] + } +} diff --git a/container/readme.md b/container/readme.md new file mode 100644 index 0000000..1af19d5 --- /dev/null +++ b/container/readme.md @@ -0,0 +1,7 @@ +# LXC Container Build + +Requires: `lxc`, `lxc-net`, `packer` (Hashicorp Packer) + +To build: `packer build -var 'apt_mirror=[apt mirror]' -var 'make_threads=[-j flag]' piston.pkr.hcl` + +After roughly 30 minutes (on an i7-4790k), you should have an image built \ No newline at end of file diff --git a/container/steps/000-wait-for-network.sh b/container/steps/000-wait-for-network.sh new file mode 100644 index 0000000..7d9f9eb --- /dev/null +++ b/container/steps/000-wait-for-network.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +while ! ping -c 1 -W 1 1.1.1.1; do + echo "Waiting for 1.1.1.1 - network is down" + sleep 1 +done diff --git a/container/steps/001-dependencies.sh b/container/steps/001-dependencies.sh new file mode 100644 index 0000000..65272fd --- /dev/null +++ b/container/steps/001-dependencies.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# install all necessary piston dependencies +echo 'source /opt/.profile' >> /opt/.bashrc +echo 'export HOME=/opt' >> /opt/.profile +echo 'export TERM=linux' >> /opt/.profile +echo 'export PATH=$PATH:/opt/.local/bin' >> /opt/.profile +export HOME=/opt +export TERM=linux +sed -i 's/\/root/\/opt/' /etc/passwd +sed -i \ + 's~http://archive.ubuntu.com/ubuntu~'"$APT_MIRROR~" \ + /etc/apt/sources.list + + +apt-get update +apt-get install -y \ + nano wget build-essential pkg-config libxml2-dev \ + libsqlite3-dev mono-complete curl cmake libpython2.7-dev \ + ruby libtinfo-dev unzip git openssl libssl-dev sbcl libevent-dev libffi-dev \ No newline at end of file diff --git a/container/steps/100-python2.sh b/container/steps/100-python2.sh new file mode 100644 index 0000000..b307552 --- /dev/null +++ b/container/steps/100-python2.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# install python2 +# final binary: /opt/python2/Python-2.7.17/python +# get version: /opt/python2/Python-2.7.17/python -V +cd /opt && mkdir python2 && cd python2 +wget https://www.python.org/ftp/python/2.7.17/Python-2.7.17.tar.xz +unxz Python-2.7.17.tar.xz +tar -xf Python-2.7.17.tar +cd Python-2.7.17 +./configure +# open Modules/Setup and uncomment zlib line +make -j$MAKE_THREADS +echo 'export PATH=$PATH:/opt/python2/Python-2.7.17' >> /opt/.profile +source /opt/.profile \ No newline at end of file diff --git a/container/steps/110-python3.sh b/container/steps/110-python3.sh new file mode 100644 index 0000000..7455947 --- /dev/null +++ b/container/steps/110-python3.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# install python3 +# final binary: /opt/python3/Python-3.8.2/python +# get version: /opt/python3/Python-3.8.2/python -V +cd /opt && mkdir python3 && cd python3 +wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz +unxz Python-3.8.2.tar.xz +tar -xf Python-3.8.2.tar +cd Python-3.8.2 +./configure +make -j$MAKE_THREADS +ln -s python python3.8 +echo 'export PATH=$PATH:/opt/python3/Python-3.8.2' >> /opt/.profile +source /opt/.profile +curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py +python3.8 get-pip.py diff --git a/container/steps/111-paradoc.sh b/container/steps/111-paradoc.sh new file mode 100644 index 0000000..fdd8260 --- /dev/null +++ b/container/steps/111-paradoc.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# install paradoc +# this is not a binary, it is a python module +# therefore it cannot be run directly as it requires python3 to be installed +cd /opt && mkdir paradoc && cd paradoc +git clone https://github.com/betaveros/paradoc.git \ No newline at end of file diff --git a/container/steps/120-node.sh b/container/steps/120-node.sh new file mode 100644 index 0000000..636b5eb --- /dev/null +++ b/container/steps/120-node.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# install node.js +# final binary: /opt/nodejs/node-v12.16.1-linux-x64/bin/node +# get version: /opt/nodejs/node-v12.16.1-linux-x64/bin/node -v +cd /opt && mkdir nodejs && cd nodejs +wget https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.xz +unxz node-v12.16.1-linux-x64.tar.xz +tar -xf node-v12.16.1-linux-x64.tar +echo 'export PATH=$PATH:/opt/nodejs/node-v12.16.1-linux-x64/bin' >> /opt/.profile + +cat /opt/.profile \ No newline at end of file diff --git a/container/steps/121-typescript.sh b/container/steps/121-typescript.sh new file mode 100644 index 0000000..cae1b16 --- /dev/null +++ b/container/steps/121-typescript.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# install typescript +# final binary: /opt/nodejs/node-v12.16.1-linux-x64/bin/tsc +# get version: /opt/nodejs/node-v12.16.1-linux-x64/bin/tsc -v +/opt/nodejs/node-v12.16.1-linux-x64/bin/npm i -g typescript \ No newline at end of file diff --git a/container/steps/130-golang.sh b/container/steps/130-golang.sh new file mode 100644 index 0000000..ac8b92d --- /dev/null +++ b/container/steps/130-golang.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# install golang +# final binary: /opt/go/go/bin/go +# get version: /opt/go/go/bin/go version +cd /opt && mkdir go && cd go +wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz +tar -xzf go1.14.1.linux-amd64.tar.gz +echo 'export PATH=$PATH:/opt/go/go/bin' >> /opt/.profile +echo 'export GOROOT=/opt/go/go' >> /opt/.profile +echo 'export GOCACHE=/tmp' >> /opt/.profile diff --git a/container/steps/140-php.sh b/container/steps/140-php.sh new file mode 100644 index 0000000..ae99a30 --- /dev/null +++ b/container/steps/140-php.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# install php +# final binary: /usr/local/bin/php +# get version: /usr/local/bin/php -v +cd /opt && mkdir php && cd php +wget https://www.php.net/distributions/php-8.0.0.tar.gz +tar -xzf php-8.0.0.tar.gz +cd php-8.0.0 +./configure +make -j$MAKE_THREADS +make install \ No newline at end of file diff --git a/container/steps/150-rust.sh b/container/steps/150-rust.sh new file mode 100644 index 0000000..db3294a --- /dev/null +++ b/container/steps/150-rust.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# install rust +# final binary: /usr/local/bin/rustc +# get version: /usr/local/bin/rustc --version +cd /opt && mkdir rust && cd rust +wget https://static.rust-lang.org/dist/rust-1.49.0-x86_64-unknown-linux-gnu.tar.gz +tar -xzf rust-1.49.0-x86_64-unknown-linux-gnu.tar.gz +cd rust-1.49.0-x86_64-unknown-linux-gnu +./install.sh \ No newline at end of file diff --git a/container/steps/160-swift.sh b/container/steps/160-swift.sh new file mode 100644 index 0000000..801b099 --- /dev/null +++ b/container/steps/160-swift.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# install swift +# final binary: /opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin/swift +# get version: /opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin/swift --version +cd /opt && mkdir swift && cd swift +wget https://swift.org/builds/swift-5.1.5-release/ubuntu1804/swift-5.1.5-RELEASE/swift-5.1.5-RELEASE-ubuntu18.04.tar.gz +tar -xzf swift-5.1.5-RELEASE-ubuntu18.04.tar.gz +echo 'export PATH=$PATH:/opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin' >> /opt/.profile diff --git a/container/steps/170-nasm.sh b/container/steps/170-nasm.sh new file mode 100644 index 0000000..d96d828 --- /dev/null +++ b/container/steps/170-nasm.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# install nasm +# final binary: /opt/nasm/nasm-2.14.02/nasm +# get version: /opt/nasm/nasm-2.14.02/nasm -v +cd /opt && mkdir nasm && cd nasm +wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.gz +tar -xzf nasm-2.14.02.tar.gz +cd nasm-2.14.02 +./configure +make -j$MAKE_THREADS +echo 'export PATH=$PATH:/opt/nasm/nasm-2.14.02' >> /opt/.profile diff --git a/container/steps/180-java.sh b/container/steps/180-java.sh new file mode 100644 index 0000000..460c152 --- /dev/null +++ b/container/steps/180-java.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# install java +# final binary: /opt/java/jdk-14/bin/java +# get version: /opt/java/jdk-14/bin/java -version +cd /opt && mkdir java && cd java +wget https://download.java.net/java/GA/jdk14/076bab302c7b4508975440c56f6cc26a/36/GPL/openjdk-14_linux-x64_bin.tar.gz +tar -xzf openjdk-14_linux-x64_bin.tar.gz +echo 'export PATH=$PATH:/opt/java/jdk-14/bin' >> /opt/.profile diff --git a/container/steps/190-jelly.sh b/container/steps/190-jelly.sh new file mode 100644 index 0000000..98719d4 --- /dev/null +++ b/container/steps/190-jelly.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# install jelly +cd /opt && mkdir jelly && cd jelly +wget https://github.com/DennisMitchell/jellylanguage/archive/master.zip +unzip master.zip +cd jellylanguage-master +python3.8 -m pip install . +sed -i 's/\/usr\/local\/bin\/python3.8/\/opt\/python3\/Python-3.8.2\/python3.8/' /usr/local/bin/jelly diff --git a/container/steps/200-julia.sh b/container/steps/200-julia.sh new file mode 100644 index 0000000..c77c575 --- /dev/null +++ b/container/steps/200-julia.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# install julia +# final binary: /opt/julia/julia-1.5.0/bin/julia +# get version: /opt/julia/julia-1.5.0/bin/julia --version +cd /opt && mkdir julia && cd julia +wget https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.0-linux-x86_64.tar.gz +tar -xzf julia-1.5.0-linux-x86_64.tar.gz +echo 'export PATH=$PATH:/opt/julia/julia-1.5.0/bin' >> /opt/.profile diff --git a/container/steps/210-kotlin.sh b/container/steps/210-kotlin.sh new file mode 100644 index 0000000..5fa0ce0 --- /dev/null +++ b/container/steps/210-kotlin.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# install kotlin +# final binary: /opt/kotlinc/bin/kotlinc +# get version: /opt/kotlinc/bin/kotlinc -version +cd /opt +wget https://github.com/JetBrains/kotlin/releases/download/v1.4.10/kotlin-compiler-1.4.10.zip +unzip kotlin-compiler-1.4.10.zip +rm kotlin-compiler-1.4.10.zip +echo 'export PATH=$PATH:/opt/kotlinc/bin' >> /opt/.profile \ No newline at end of file diff --git a/container/steps/220-elixar-erlang.sh b/container/steps/220-elixar-erlang.sh new file mode 100644 index 0000000..985df1f --- /dev/null +++ b/container/steps/220-elixar-erlang.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +# install elixir and erlang +# final binary: /opt/elixir/bin/elixir +# get version: /opt/elixir/bin/elixir --version +# erlang +cd /opt && mkdir erlang && cd erlang +wget http://erlang.org/download/otp_src_23.0.tar.gz +gunzip -c otp_src_23.0.tar.gz | tar xf - +cd otp_src_23.0 && ./configure +make -j$MAKE_THREADS +echo 'export PATH=$PATH:/opt/erlang/otp_src_23.0/bin' >> /opt/.profile +source /opt/.profile +# elixir +cd /opt && mkdir elixir && cd elixir +wget https://github.com/elixir-lang/elixir/releases/download/v1.10.3/Precompiled.zip +mkdir elixir-1.10.3 && unzip Precompiled.zip -d elixir-1.10.3/ +echo 'export PATH=$PATH:/opt/elixir/elixir-1.10.3/bin' >> /opt/.profile + diff --git a/container/steps/230-emacs.sh b/container/steps/230-emacs.sh new file mode 100644 index 0000000..3b5e5e0 --- /dev/null +++ b/container/steps/230-emacs.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# install emacs +# final binary: /opt/emacs/emacs-26.3/src/emacs +# get version: /opt/emacs/emacs-26.3/src/emacs --version +cd /opt && mkdir emacs && cd emacs +wget https://mirrors.ocf.berkeley.edu/gnu/emacs/emacs-26.3.tar.xz +tar -xf emacs-26.3.tar.xz +rm emacs-26.3.tar.xz +cd emacs-26.3 +./configure --with-gnutls=no +make +echo 'export PATH=$PATH:/opt/emacs/emacs-26.3/src' >> /opt/.profile \ No newline at end of file diff --git a/container/steps/240-lua.sh b/container/steps/240-lua.sh new file mode 100644 index 0000000..23c9338 --- /dev/null +++ b/container/steps/240-lua.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# install lua +# final binary: /opt/lua/lua54/src/lua +# get version: /opt/lua/lua54/src/lua -v +cd /opt && mkdir lua && cd lua +wget https://sourceforge.net/projects/luabinaries/files/5.4.0/Docs%20and%20Sources/lua-5.4.0_Sources.tar.gz/download +tar -xzf download +cd lua54 +make -j$MAKE_THREADS +echo 'export PATH=$PATH:/opt/lua/lua54/src' >> /opt/.profile \ No newline at end of file diff --git a/container/steps/250-haskell.sh b/container/steps/250-haskell.sh new file mode 100644 index 0000000..17ef3f3 --- /dev/null +++ b/container/steps/250-haskell.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# install haskell +# final binary: /usr/bin/ghc +# get version: /usr/bin/ghc --version +apt install -y ghc diff --git a/container/steps/260-deno.sh b/container/steps/260-deno.sh new file mode 100644 index 0000000..23090cd --- /dev/null +++ b/container/steps/260-deno.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# install deno +# final binary: /opt/.deno/bin/deno +# get version: /opt/.deno/bin/deno --version +cd /opt && mkdir deno && cd deno +curl -fsSL https://deno.land/x/install/install.sh | sh +echo 'export DENO_INSTALL="/opt/.deno"' >> /opt/.profile +echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> /opt/.profile diff --git a/container/steps/270-brainfuck.sh b/container/steps/270-brainfuck.sh new file mode 100644 index 0000000..5e5cdaa --- /dev/null +++ b/container/steps/270-brainfuck.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# install brainfuck +cd /opt && mkdir bf && cd bf +git clone https://github.com/texus/Brainfuck-interpreter +cd Brainfuck-interpreter +echo 'export PATH=$PATH:/opt/bf/Brainfuck-interpreter' >> /opt/.profile +source /opt/.profile diff --git a/container/steps/280-crystal.sh b/container/steps/280-crystal.sh new file mode 100644 index 0000000..cba176d --- /dev/null +++ b/container/steps/280-crystal.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# install crystal +# final binary: /opt/crystal/crystal-0.35.1-1/bin/crystal +# get version: /opt/crystal/crystal-0.35.1-1/bin/crystal -v +cd /opt && mkdir crystal && cd crystal +wget https://github.com/crystal-lang/crystal/releases/download/0.35.1/crystal-0.35.1-1-linux-x86_64.tar.gz +tar -xzf crystal-0.35.1-1-linux-x86_64.tar.gz +echo 'export PATH="$PATH:/opt/crystal/crystal-0.35.1-1/bin:$PATH"' >> /opt/.profile diff --git a/container/steps/290-d.sh b/container/steps/290-d.sh new file mode 100644 index 0000000..133e54c --- /dev/null +++ b/container/steps/290-d.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# install d +# final binary: /opt/d/dmd2/linux/bin64/dmd +# get version: /opt/d/dmd2/linux/bin64/dmd --version +cd /opt && mkdir d && cd d +wget http://downloads.dlang.org/releases/2.x/2.095.0/dmd.2.095.0.linux.tar.xz +unxz dmd.2.095.0.linux.tar.xz +tar -xf dmd.2.095.0.linux.tar +echo 'export PATH=$PATH:/opt/d/dmd2/linux/bin64' >> /opt/.profile +source /opt/.profile diff --git a/container/steps/300-zig.sh b/container/steps/300-zig.sh new file mode 100644 index 0000000..96fd2fa --- /dev/null +++ b/container/steps/300-zig.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# install zig +# final binary: /opt/zig/zig +# get version: /opt/zig/zig version +cd /opt && mkdir zig && cd zig +wget https://ziglang.org/download/0.7.1/zig-linux-x86_64-0.7.1.tar.xz +tar -xf zig-linux-x86_64-0.7.1.tar.xz +mv zig-linux-x86_64-0.7.1 zig +rm zig-linux-x86_64-0.7.1.tar.xz +echo 'export PATH=$PATH:/opt/zig/zig' >> /opt/.profile diff --git a/container/steps/310-nim.sh b/container/steps/310-nim.sh new file mode 100644 index 0000000..6aa91bd --- /dev/null +++ b/container/steps/310-nim.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# install nim +# final binary: /opt/nim/bin/nim +# get version: /opt/nim/bin/nim -v +cd /opt && mkdir nim && cd nim +wget https://nim-lang.org/download/nim-1.4.0-linux_x64.tar.xz +unxz nim-1.4.0-linux_x64.tar.xz +tar -xf nim-1.4.0-linux_x64.tar +cd nim-1.4.0 +./install.sh /opt +echo 'export PATH=$PATH:/opt/nim/bin' >> /opt/.profile \ No newline at end of file diff --git a/container/steps/900-runner-users.sh b/container/steps/900-runner-users.sh new file mode 100644 index 0000000..f15545c --- /dev/null +++ b/container/steps/900-runner-users.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# create runnable users and apply limits +for i in {1..150}; do + useradd -M runner$i + usermod -d /tmp runner$i + echo "runner$i soft nproc 64" >> /etc/security/limits.conf + echo "runner$i hard nproc 64" >> /etc/security/limits.conf + echo "runner$i soft nofile 2048" >> /etc/security/limits.conf + echo "runner$i hard nofile 2048" >> /etc/security/limits.conf +done \ No newline at end of file diff --git a/container/steps/910-cleanup.sh b/container/steps/910-cleanup.sh new file mode 100644 index 0000000..09112cc --- /dev/null +++ b/container/steps/910-cleanup.sh @@ -0,0 +1,12 @@ +# remove any lingering write access to others +cd /opt +chown -R root: * +chmod -R o-w * + +# cleanup +rm -rf /home/ubuntu +chmod 777 /tmp + +# disable cron +systemctl stop cron +systemctl disable cron diff --git a/readme.md b/readme.md index 6515189..739bc4f 100644 --- a/readme.md +++ b/readme.md @@ -141,7 +141,10 @@ cd piston/lxc #### Installation (simple) -- Coming soon. +- `cd container && ./install.sh` +- Wait, it may take up to an hour. +- `cd ../lxc && ./start && cd ..` +- Good to go! #### Installation (advanced) From 7b3565a0671f4bf591fc526a2a17d4150acd15e1 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 13:19:24 +1300 Subject: [PATCH 02/18] Github Actions --- .github/workflows/lxc-build.yml | 38 +++++++++++++++++++++++++++++++++ readme.md | 18 +++++++++++----- 2 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/lxc-build.yml diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml new file mode 100644 index 0000000..ce931f5 --- /dev/null +++ b/.github/workflows/lxc-build.yml @@ -0,0 +1,38 @@ +--- + +name: LXC Build + +on: + push: + workflow_dispatch: + +jobs: + packer: + runs-on: ubuntu-latest + name: packer + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + # validate templates + - name: Validate Container + run: packer validate piston.pkr.hcl + working-directory: container + + # build container + - name: Build Artifact + run: packer build -var 'make_threads=32' piston.pkr.hcl + working-directory: container + + - name: Rename config + run: mv lxc-config config + working-directory: container + + # Upload container + - uses: actions/upload-artifact@v2 + with: + name: lxc-container + path: | + container/output-piston-bionic/config + container/output-piston-bionic/rootfs.tar.gz \ No newline at end of file diff --git a/readme.md b/readme.md index 739bc4f..8be5356 100644 --- a/readme.md +++ b/readme.md @@ -141,15 +141,23 @@ cd piston/lxc #### Installation (simple) -- `cd container && ./install.sh` +- `mkdir -p /var/lib/lxc/piston` +- `cd /var/lib/lxc/piston` +- `wget [latest container url] -o container.zip` +- `unzip container.zip` +- `tar xzf rootfs.tar.gz` +- `rm rootfs.tar.gz container.zip` +- Good to go! + + +#### Installation (advanced) + +- `cd ../container && ./install.sh` - Wait, it may take up to an hour. - `cd ../lxc && ./start && cd ..` - Good to go! -#### Installation (advanced) - -- See `var/install.txt` for how to create a new LXC container and install all of the required -software. +Alternatively, see `var/install.txt` for how to build the container manually #### CLI Usage - `cli/execute [language] [file path] [args]` From a331b623153da8c1c63b36ae184cb7bcdedc24e5 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 13:32:55 +1300 Subject: [PATCH 03/18] Install LXC in workflow --- .github/workflows/lxc-build.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml index ce931f5..a7c21a9 100644 --- a/.github/workflows/lxc-build.yml +++ b/.github/workflows/lxc-build.yml @@ -19,6 +19,14 @@ jobs: - name: Validate Container run: packer validate piston.pkr.hcl working-directory: container + + - name: Install LXC + run: | + apt install -y lxc lxc-templates debootstrap libvirt0 + echo "lxc.net.0.type = veth" > /etc/lxc/default.conf + echo "lxc.net.0.link = lxcbr0" >> /etc/lxc/default.conf + echo "lxc.net.0.flags = up" >> /etc/lxc/default.conf + systemctl start lxc-net # build container - name: Build Artifact From c6fc9fe4934b31a4b3792a346bdbb67f47fe4680 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 13:44:03 +1300 Subject: [PATCH 04/18] apt with sudo --- .github/workflows/lxc-build.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml index a7c21a9..e052bf6 100644 --- a/.github/workflows/lxc-build.yml +++ b/.github/workflows/lxc-build.yml @@ -20,12 +20,17 @@ jobs: run: packer validate piston.pkr.hcl working-directory: container - - name: Install LXC + - name: Install LXC and Packer run: | - apt install -y lxc lxc-templates debootstrap libvirt0 - echo "lxc.net.0.type = veth" > /etc/lxc/default.conf - echo "lxc.net.0.link = lxcbr0" >> /etc/lxc/default.conf - echo "lxc.net.0.flags = up" >> /etc/lxc/default.conf + curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - + sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" + sudo apt-get update -y + sudo apt install -y lxc lxc-templates debootstrap libvirt0 packer + echo "lxc.net.0.type = veth" > default.conf + echo "lxc.net.0.link = lxcbr0" >> default.conf + echo "lxc.net.0.flags = up" >> default.conf + sudo rm /etc/lxc/default.conf + sudo cp default.conf /etc/lxc systemctl start lxc-net # build container From ce5934252b3f53d9b445c0fabc9f79949a363263 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 13:45:43 +1300 Subject: [PATCH 05/18] packer comes preinstaller --- .github/workflows/lxc-build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml index e052bf6..c76b5f7 100644 --- a/.github/workflows/lxc-build.yml +++ b/.github/workflows/lxc-build.yml @@ -22,9 +22,6 @@ jobs: - name: Install LXC and Packer run: | - curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - - sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" - sudo apt-get update -y sudo apt install -y lxc lxc-templates debootstrap libvirt0 packer echo "lxc.net.0.type = veth" > default.conf echo "lxc.net.0.link = lxcbr0" >> default.conf From 15857f1c0a321938d8e829fdd1e8ddcbf69a0003 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 13:47:07 +1300 Subject: [PATCH 06/18] apt update.. --- .github/workflows/lxc-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml index c76b5f7..6b0d1ec 100644 --- a/.github/workflows/lxc-build.yml +++ b/.github/workflows/lxc-build.yml @@ -22,6 +22,7 @@ jobs: - name: Install LXC and Packer run: | + sudo apt update sudo apt install -y lxc lxc-templates debootstrap libvirt0 packer echo "lxc.net.0.type = veth" > default.conf echo "lxc.net.0.link = lxcbr0" >> default.conf From 4e60ab080b5b6d70737a5204091d150806675d35 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 13:50:15 +1300 Subject: [PATCH 07/18] systemctl needs sudo too! --- .github/workflows/lxc-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml index 6b0d1ec..80b32fe 100644 --- a/.github/workflows/lxc-build.yml +++ b/.github/workflows/lxc-build.yml @@ -29,11 +29,11 @@ jobs: echo "lxc.net.0.flags = up" >> default.conf sudo rm /etc/lxc/default.conf sudo cp default.conf /etc/lxc - systemctl start lxc-net + sudo systemctl start lxc-net # build container - name: Build Artifact - run: packer build -var 'make_threads=32' piston.pkr.hcl + run: packer build -var 'make_threads=32' -var 'apt_mirror=http://azure.archive.ubuntu.com/ubuntu' piston.pkr.hcl working-directory: container - name: Rename config From 208a3dcee824caaf3edc8f6638d707d91b8d3744 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 13:54:40 +1300 Subject: [PATCH 08/18] run packer as sudo --- .github/workflows/lxc-build.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml index 80b32fe..0c78541 100644 --- a/.github/workflows/lxc-build.yml +++ b/.github/workflows/lxc-build.yml @@ -33,9 +33,12 @@ jobs: # build container - name: Build Artifact - run: packer build -var 'make_threads=32' -var 'apt_mirror=http://azure.archive.ubuntu.com/ubuntu' piston.pkr.hcl + run: sudo packer build -var 'make_threads=32' -var 'apt_mirror=http://azure.archive.ubuntu.com/ubuntu' piston.pkr.hcl + working-directory: container + - name: chown everything + run: | + sudo chown -R runner:runner . working-directory: container - - name: Rename config run: mv lxc-config config working-directory: container From e03f7c17706e20dd1b757dee332e46adcc51a15a Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 22:20:08 +1300 Subject: [PATCH 09/18] distrobuilder --- .github/workflows/lxc-build.yml | 29 +- .gitignore | 3 +- container/build.sh | 6 + container/configure.py | 13 + container/install.sh | 4 - container/install_script.sh | 284 +++++++++++++++++++ container/lxc.conf | 7 - container/piston.pkr.hcl | 41 --- container/piston.yaml | 355 ++++++++++++++++++++++++ container/steps/000-wait-for-network.sh | 6 - container/steps/001-dependencies.sh | 20 -- container/steps/100-python2.sh | 15 - container/steps/110-python3.sh | 17 -- container/steps/111-paradoc.sh | 7 - container/steps/120-node.sh | 12 - container/steps/121-typescript.sh | 6 - container/steps/130-golang.sh | 11 - container/steps/140-php.sh | 12 - container/steps/150-rust.sh | 10 - container/steps/160-swift.sh | 9 - container/steps/170-nasm.sh | 12 - container/steps/180-java.sh | 9 - container/steps/190-jelly.sh | 9 - container/steps/200-julia.sh | 9 - container/steps/210-kotlin.sh | 10 - container/steps/220-elixar-erlang.sh | 19 -- container/steps/230-emacs.sh | 13 - container/steps/240-lua.sh | 11 - container/steps/250-haskell.sh | 6 - container/steps/260-deno.sh | 9 - container/steps/270-brainfuck.sh | 8 - container/steps/280-crystal.sh | 9 - container/steps/290-d.sh | 11 - container/steps/300-zig.sh | 11 - container/steps/310-nim.sh | 12 - container/steps/900-runner-users.sh | 11 - container/steps/910-cleanup.sh | 12 - 37 files changed, 667 insertions(+), 381 deletions(-) create mode 100755 container/build.sh create mode 100644 container/configure.py delete mode 100755 container/install.sh create mode 100644 container/install_script.sh delete mode 100644 container/lxc.conf delete mode 100644 container/piston.pkr.hcl create mode 100644 container/piston.yaml delete mode 100644 container/steps/000-wait-for-network.sh delete mode 100644 container/steps/001-dependencies.sh delete mode 100644 container/steps/100-python2.sh delete mode 100644 container/steps/110-python3.sh delete mode 100644 container/steps/111-paradoc.sh delete mode 100644 container/steps/120-node.sh delete mode 100644 container/steps/121-typescript.sh delete mode 100644 container/steps/130-golang.sh delete mode 100644 container/steps/140-php.sh delete mode 100644 container/steps/150-rust.sh delete mode 100644 container/steps/160-swift.sh delete mode 100644 container/steps/170-nasm.sh delete mode 100644 container/steps/180-java.sh delete mode 100644 container/steps/190-jelly.sh delete mode 100644 container/steps/200-julia.sh delete mode 100644 container/steps/210-kotlin.sh delete mode 100644 container/steps/220-elixar-erlang.sh delete mode 100644 container/steps/230-emacs.sh delete mode 100644 container/steps/240-lua.sh delete mode 100644 container/steps/250-haskell.sh delete mode 100644 container/steps/260-deno.sh delete mode 100644 container/steps/270-brainfuck.sh delete mode 100644 container/steps/280-crystal.sh delete mode 100644 container/steps/290-d.sh delete mode 100644 container/steps/300-zig.sh delete mode 100644 container/steps/310-nim.sh delete mode 100644 container/steps/900-runner-users.sh delete mode 100644 container/steps/910-cleanup.sh diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml index 0c78541..6423a88 100644 --- a/.github/workflows/lxc-build.yml +++ b/.github/workflows/lxc-build.yml @@ -15,38 +15,23 @@ jobs: - name: Checkout Repository uses: actions/checkout@v2 - # validate templates - - name: Validate Container - run: packer validate piston.pkr.hcl - working-directory: container - - - name: Install LXC and Packer - run: | - sudo apt update - sudo apt install -y lxc lxc-templates debootstrap libvirt0 packer - echo "lxc.net.0.type = veth" > default.conf - echo "lxc.net.0.link = lxcbr0" >> default.conf - echo "lxc.net.0.flags = up" >> default.conf - sudo rm /etc/lxc/default.conf - sudo cp default.conf /etc/lxc - sudo systemctl start lxc-net - + - name: Install Distrobuilder + run: sudo apt-get install -y distrobuilder # build container - name: Build Artifact - run: sudo packer build -var 'make_threads=32' -var 'apt_mirror=http://azure.archive.ubuntu.com/ubuntu' piston.pkr.hcl + run: sudo ./build.sh + working-directory: container + working-directory: container - name: chown everything run: | sudo chown -R runner:runner . working-directory: container - - name: Rename config - run: mv lxc-config config - working-directory: container # Upload container - uses: actions/upload-artifact@v2 with: name: lxc-container path: | - container/output-piston-bionic/config - container/output-piston-bionic/rootfs.tar.gz \ No newline at end of file + container/output-piston-bionic/meta.tar.xz + container/output-piston-bionic/rootfs.tar.xz \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0e31c49..932e600 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ api/api lxc/i lxc/lockfile -container/output-* \ No newline at end of file +container/build.yaml +container/*.tar.xz \ No newline at end of file diff --git a/container/build.sh b/container/build.sh new file mode 100755 index 0000000..c7f7355 --- /dev/null +++ b/container/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +python3 -m pip install pyyaml +python3 configure.py +distrobuilder build-lxc build.yaml + diff --git a/container/configure.py b/container/configure.py new file mode 100644 index 0000000..5550313 --- /dev/null +++ b/container/configure.py @@ -0,0 +1,13 @@ +import yaml + + +with open('piston.yaml') as dbc: + with open('install_script.sh') as install_script_file: + with open('build.yaml' , 'w+') as distrobuilder_config_file_new: + distrobuilder_config = yaml.safe_load(dbc) + distrobuilder_config['actions'].append({ + 'trigger': 'post-packages', + 'action': install_script_file.read(), + + }) + yaml.dump(distrobuilder_config, distrobuilder_config_file_new) \ No newline at end of file diff --git a/container/install.sh b/container/install.sh deleted file mode 100755 index 565b767..0000000 --- a/container/install.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -packer build piston.pkr.hcl -cd output-piston-bionic && mkdir -p /var/lib/lxc/piston && cd /var/lib/lxc/piston && cp "$OLDPWD/lxc-config" config && tar -xzf "$OLDPWD/rootfs.tar.gz" \ No newline at end of file diff --git a/container/install_script.sh b/container/install_script.sh new file mode 100644 index 0000000..9631791 --- /dev/null +++ b/container/install_script.sh @@ -0,0 +1,284 @@ +#!/bin/bash +#echo "Don't run this on your system!" && exit 0 + +# install all necessary piston dependencies +echo 'source /opt/.profile' >> /opt/.bashrc +echo 'export HOME=/opt' >> /opt/.profile +echo 'export TERM=linux' >> /opt/.profile +echo 'export PATH=$PATH:/opt/.local/bin' >> /opt/.profile +export HOME=/opt +export TERM=linux +sed -i 's/\/root/\/opt/' /etc/passwd +sed -i \ + 's/http:\/\/archive.ubuntu.com\/ubuntu/http:\/\/mirror.math.princeton.edu\/pub\/ubuntu/' \ + /etc/apt/sources.list +apt-get update +apt-get install -y \ + nano wget build-essential pkg-config libxml2-dev \ + libsqlite3-dev mono-complete curl cmake libpython2.7-dev \ + ruby libtinfo-dev unzip git openssl libssl-dev sbcl libevent-dev + +# install python2 +# final binary: /opt/python2/Python-2.7.17/python +# get version: /opt/python2/Python-2.7.17/python -V +cd /opt && mkdir python2 && cd python2 +wget https://www.python.org/ftp/python/2.7.17/Python-2.7.17.tar.xz +unxz Python-2.7.17.tar.xz +tar -xf Python-2.7.17.tar +cd Python-2.7.17 +./configure +# open Modules/Setup and uncomment zlib line +make +echo 'export PATH=$PATH:/opt/python2/Python-2.7.17' >> /opt/.profile +. /opt/.profile + +# install python3 +# final binary: /opt/python3/Python-3.8.2/python +# get version: /opt/python3/Python-3.8.2/python -V +cd /opt && mkdir python3 && cd python3 +wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz +unxz Python-3.8.2.tar.xz +tar -xf Python-3.8.2.tar +cd Python-3.8.2 +./configure +make +ln -s python python3.8 +echo 'export PATH=$PATH:/opt/python3/Python-3.8.2' >> /opt/.profile +. /opt/.profile + +# install paradoc +# this is not a binary, it is a python module +# therefore it cannot be run directly as it requires python3 to be installed +cd /opt && mkdir paradoc && cd paradoc +git clone https://github.com/betaveros/paradoc.git + +# install node.js +# final binary: /opt/nodejs/node-v12.16.1-linux-x64/bin/node +# get version: /opt/nodejs/node-v12.16.1-linux-x64/bin/node -v +cd /opt && mkdir nodejs && cd nodejs +wget https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.xz +unxz node-v12.16.1-linux-x64.tar.xz +tar -xf node-v12.16.1-linux-x64.tar +echo 'export PATH=$PATH:/opt/nodejs/node-v12.16.1-linux-x64/bin' >> /opt/.profile +. /opt/.profile + +# install typescript +# final binary: /opt/nodejs/node-v12.16.1-linux-x64/bin/tsc +# get version: /opt/nodejs/node-v12.16.1-linux-x64/bin/tsc -v +/opt/nodejs/node-v12.16.1-linux-x64/bin/npm i -g typescript + +# install golang +# final binary: /opt/go/go/bin/go +# get version: /opt/go/go/bin/go version +cd /opt && mkdir go && cd go +wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz +tar -xzf go1.14.1.linux-amd64.tar.gz +echo 'export PATH=$PATH:/opt/go/go/bin' >> /opt/.profile +echo 'export GOROOT=/opt/go/go' >> /opt/.profile +echo 'export GOCACHE=/tmp' >> /opt/.profile +. /opt/.profile + +# install php +# final binary: /usr/local/bin/php +# get version: /usr/local/bin/php -v +cd /opt && mkdir php && cd php +wget https://www.php.net/distributions/php-8.0.0.tar.gz +tar -xzf php-8.0.0.tar.gz +cd php-8.0.0 +./configure +make +make install + +# install rust +# final binary: /usr/local/bin/rustc +# get version: /usr/local/bin/rustc --version +cd /opt && mkdir rust && cd rust +wget https://static.rust-lang.org/dist/rust-1.49.0-x86_64-unknown-linux-gnu.tar.gz +tar -xzf rust-1.49.0-x86_64-unknown-linux-gnu.tar.gz +cd rust-1.49.0-x86_64-unknown-linux-gnu +./install.sh + +# install swift +# final binary: /opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin/swift +# get version: /opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin/swift --version +cd /opt && mkdir swift && cd swift +wget https://swift.org/builds/swift-5.1.5-release/ubuntu1804/swift-5.1.5-RELEASE/swift-5.1.5-RELEASE-ubuntu18.04.tar.gz +tar -xzf swift-5.1.5-RELEASE-ubuntu18.04.tar.gz +echo 'export PATH=$PATH:/opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin' >> /opt/.profile +. /opt/.profile + +# install nasm +# final binary: /opt/nasm/nasm-2.14.02/nasm +# get version: /opt/nasm/nasm-2.14.02/nasm -v +cd /opt && mkdir nasm && cd nasm +wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.gz +tar -xzf nasm-2.14.02.tar.gz +cd nasm-2.14.02 +./configure +make +echo 'export PATH=$PATH:/opt/nasm/nasm-2.14.02' >> /opt/.profile +. /opt/.profile + +# install java +# final binary: /opt/java/jdk-14/bin/java +# get version: /opt/java/jdk-14/bin/java -version +cd /opt && mkdir java && cd java +wget https://download.java.net/java/GA/jdk14/076bab302c7b4508975440c56f6cc26a/36/GPL/openjdk-14_linux-x64_bin.tar.gz +tar -xzf openjdk-14_linux-x64_bin.tar.gz +echo 'export PATH=$PATH:/opt/java/jdk-14/bin' >> /opt/.profile +. /opt/.profile + +# install jelly +cd /opt && mkdir jelly && cd jelly +wget https://github.com/DennisMitchell/jellylanguage/archive/master.zip +unzip master.zip +cd jellylanguage-master +python3.8 -m pip install . +sed -i 's/\/usr\/local\/bin\/python3.8/\/opt\/python3\/Python-3.8.2\/python3.8/' /usr/local/bin/jelly + +# install julia +# final binary: /opt/julia/julia-1.5.0/bin/julia +# get version: /opt/julia/julia-1.5.0/bin/julia --version +cd /opt && mkdir julia && cd julia +wget https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.0-linux-x86_64.tar.gz +tar -xzf julia-1.5.0-linux-x86_64.tar.gz +echo 'export PATH=$PATH:/opt/julia/julia-1.5.0/bin' >> /opt/.profile +. /opt/.profile + +# install kotlin +# final binary: /opt/kotlinc/bin/kotlinc +# get version: /opt/kotlinc/bin/kotlinc -version +cd /opt +wget https://github.com/JetBrains/kotlin/releases/download/v1.4.10/kotlin-compiler-1.4.10.zip +unzip kotlin-compiler-1.4.10.zip +rm kotlin-compiler-1.4.10.zip +echo 'export PATH=$PATH:/opt/kotlinc/bin' >> /opt/.profile +. /opt/.profile + +# install elixir and erlang +# final binary: /opt/elixir/bin/elixir +# get version: /opt/elixir/bin/elixir --version +# erlang +cd /opt && mkdir erlang && cd erlang +wget http://erlang.org/download/otp_src_23.0.tar.gz +gunzip -c otp_src_23.0.tar.gz | tar xf - +cd otp_src_23.0 && ./configure +make +echo 'export PATH=$PATH:/opt/erlang/otp_src_23.0/bin' >> /opt/.profile +. /opt/.profile +# elixir +cd /opt && mkdir elixir && cd elixir +wget https://github.com/elixir-lang/elixir/releases/download/v1.10.3/Precompiled.zip +mkdir elixir-1.10.3 && unzip Precompiled.zip -d elixir-1.10.3/ +echo 'export PATH=$PATH:/opt/elixir/elixir-1.10.3/bin' >> /opt/.profile +. /opt/.profile + +# install emacs +# final binary: /opt/emacs/emacs-26.3/src/emacs +# get version: /opt/emacs/emacs-26.3/src/emacs --version +cd /opt && mkdir emacs && cd emacs +wget https://mirrors.ocf.berkeley.edu/gnu/emacs/emacs-26.3.tar.xz +tar -xf emacs-26.3.tar.xz +rm emacs-26.3.tar.xz +cd emacs-26.3 +./configure --with-gnutls=no +make +echo 'export PATH=$PATH:/opt/emacs/emacs-26.3/src' >> /opt/.profile +. /opt/.profile + +# install lua +# final binary: /opt/lua/lua54/src/lua +# get version: /opt/lua/lua54/src/lua -v +cd /opt && mkdir lua && cd lua +wget https://sourceforge.net/projects/luabinaries/files/5.4.0/Docs%20and%20Sources/lua-5.4.0_Sources.tar.gz/download +tar -xzf download +cd lua54 +make +echo 'export PATH=$PATH:/opt/lua/lua54/src' >> /opt/.profile +. /opt/.profile + +# install haskell +# final binary: /usr/bin/ghc +# get version: /usr/bin/ghc --version +apt install -y ghc + +# install deno +# final binary: /opt/.deno/bin/deno +# get version: /opt/.deno/bin/deno --version +cd /opt && mkdir deno && cd deno +curl -fsSL https://deno.land/x/install/install.sh | sh +echo 'export DENO_INSTALL="/opt/.deno"' >> /opt/.profile +echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> /opt/.profile +. /opt/.profile + +# install brainfuck +cd /opt && mkdir bf && cd bf +git clone https://github.com/texus/Brainfuck-interpreter +cd Brainfuck-interpreter +echo 'export PATH=$PATH:/opt/bf/Brainfuck-interpreter' >> /opt/.profile +. /opt/.profile + +# install crystal +# final binary: /opt/crystal/crystal-0.35.1-1/bin/crystal +# get version: /opt/crystal/crystal-0.35.1-1/bin/crystal -v +cd /opt && mkdir crystal && cd crystal +wget https://github.com/crystal-lang/crystal/releases/download/0.35.1/crystal-0.35.1-1-linux-x86_64.tar.gz +tar -xzf crystal-0.35.1-1-linux-x86_64.tar.gz +echo 'export PATH="$PATH:/opt/crystal/crystal-0.35.1-1/bin:$PATH"' >> /opt/.profile +. /opt/.profile + +# install d +# final binary: /opt/d/dmd2/linux/bin64/dmd +# get version: /opt/d/dmd2/linux/bin64/dmd --version +cd /opt && mkdir d && cd d +wget http://downloads.dlang.org/releases/2.x/2.095.0/dmd.2.095.0.linux.tar.xz +unxz dmd.2.095.0.linux.tar.xz +tar -xf dmd.2.095.0.linux.tar +echo 'export PATH=$PATH:/opt/d/dmd2/linux/bin64' >> /opt/.profile +. /opt/.profile + +# install zig +# final binary: /opt/zig/zig +# get version: /opt/zig/zig version +cd /opt && mkdir zig && cd zig +wget https://ziglang.org/download/0.7.1/zig-linux-x86_64-0.7.1.tar.xz +tar -xf zig-linux-x86_64-0.7.1.tar.xz +mv zig-linux-x86_64-0.7.1 zig +rm zig-linux-x86_64-0.7.1.tar.xz +echo 'export PATH=$PATH:/opt/zig/zig' >> /opt/.profile +. /opt/.profile + +# install nim +# final binary: /opt/nim/bin/nim +# get version: /opt/nim/bin/nim -v +cd /opt && mkdir nim && cd nim +wget https://nim-lang.org/download/nim-1.4.0-linux_x64.tar.xz +unxz nim-1.4.0-linux_x64.tar.xz +tar -xf nim-1.4.0-linux_x64.tar +cd nim-1.4.0 +./install.sh /opt +echo 'export PATH=$PATH:/opt/nim/bin' >> /opt/.profile +. /opt/.profile + +# create runnable users and apply limits +for i in {1..150}; do + useradd -M runner$i + usermod -d /tmp runner$i + echo "runner$i soft nproc 64" >> /etc/security/limits.conf + echo "runner$i hard nproc 64" >> /etc/security/limits.conf + echo "runner$i soft nofile 2048" >> /etc/security/limits.conf + echo "runner$i hard nofile 2048" >> /etc/security/limits.conf +done + +# remove any lingering write access to others +cd /opt +chown -R root: * +chmod -R o-w * + +# cleanup +rm -rf /home/ubuntu +chmod 777 /tmp + +# disable cron +systemctl stop cron +systemctl disable cron diff --git a/container/lxc.conf b/container/lxc.conf deleted file mode 100644 index be15450..0000000 --- a/container/lxc.conf +++ /dev/null @@ -1,7 +0,0 @@ -lxc.net.0.type = empty - -lxc.include = /usr/share/lxc/config/ubuntu.common.conf -lxc.arch = x86_64 - -lxc.rootfs.path = /var/lib/lxc/piston/rootfs -lxc.uts.name = piston \ No newline at end of file diff --git a/container/piston.pkr.hcl b/container/piston.pkr.hcl deleted file mode 100644 index d3e10de..0000000 --- a/container/piston.pkr.hcl +++ /dev/null @@ -1,41 +0,0 @@ -variable "make_threads" { - type = number - default = 8 -} - -variable "apt_mirror" { - type = string - default = "http://mirror.math.princeton.edu/pub/ubuntu" -} - -source "lxc" "piston-bionic" { - config_file = "lxc.conf" - attach_options = ["--clear-env"] - - # Base of Ubuntu Bionic (amd64) - template_name = "download" - template_parameters = [ - "--dist", "ubuntu", - "--release", "bionic", - "--arch", "amd64" - ] - -} - -build { - sources = ["source.lxc.piston-bionic"] - provisioner "shell" { - # Make sure /opt/.profile exists - inline = ["touch /opt/.profile"] - } - - provisioner "shell" { - scripts = fileset(".", "steps/*.sh") - execute_command = "chmod +x {{ .Path }}; . /opt/.profile; {{ .Vars }} bash {{ .Path }}" - environment_vars = [ - #"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", - "MAKE_THREADS=${var.make_threads}", - "APT_MIRROR=${var.apt_mirror}" - ] - } -} diff --git a/container/piston.yaml b/container/piston.yaml new file mode 100644 index 0000000..550c834 --- /dev/null +++ b/container/piston.yaml @@ -0,0 +1,355 @@ +image: + name: ubuntu-disco-x86_64-piston + distribution: ubuntu + release: focal + description: |- + Ubuntu {{ image.release }} preconfigured for Piston + architecture: x86_64 + +source: + downloader: debootstrap + same_as: gutsy + url: http://archive.ubuntu.com/ubuntu + keyserver: keyserver.ubuntu.com + keys: + - '0x790BC7277767219C42C86F933B4FE6ACC0B21F32' + - '0xf6ecb3762474eda9d21b7022871920d1991bc93c' + +targets: + lxc: + create-message: |- + You just created an {{ image.description }} container. + To enable SSH, run: apt install openssh-server + No default root or user password are set by LXC. + config: + - type: all + before: 5 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/ubuntu.common.conf + - type: user + before: 5 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/ubuntu.userns.conf + - type: all + after: 4 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/common.conf + # For Ubuntu 14.04 + lxc.mount.entry = /sys/kernel/debug sys/kernel/debug none bind,optional 0 0 + lxc.mount.entry = /sys/kernel/security sys/kernel/security none bind,optional 0 0 + lxc.mount.entry = /sys/fs/pstore sys/fs/pstore none bind,optional 0 0 + lxc.mount.entry = mqueue dev/mqueue mqueue rw,relatime,create=dir,optional 0 0 + - type: user + after: 4 + content: |- + lxc.include = LXC_TEMPLATE_CONFIG/userns.conf + # For Ubuntu 14.04 + lxc.mount.entry = /sys/firmware/efi/efivars sys/firmware/efi/efivars none bind,optional 0 0 + lxc.mount.entry = /proc/sys/fs/binfmt_misc proc/sys/fs/binfmt_misc none bind,optional 0 0 + - type: all + content: |- + lxc.arch = {{ image.architecture_personality }} +files: +- path: /etc/hostname + generator: hostname + +- path: /etc/hosts + generator: hosts + +- path: /etc/resolvconf/resolv.conf.d/original + generator: remove + +- path: /etc/resolvconf/resolv.conf.d/tail + generator: remove + +- path: /etc/machine-id + generator: dump + + +- path: /var/lib/dbus/machine-id + generator: remove + +- path: /etc/netplan/10-lxc.yaml + generator: dump + content: |- + network: + version: 2 + ethernets: + eth0: + dhcp4: true + dhcp-identifier: mac + releases: + - bionic + - eoan + - focal + - groovy + types: + - container + variants: + - default + +- path: /etc/network/interfaces + generator: dump + content: |- + # This file describes the network interfaces available on your system + # and how to activate them. For more information, see interfaces(5). + # The loopback network interface + auto lo + iface lo inet loopback + auto eth0 + iface eth0 inet dhcp + source /etc/network/interfaces.d/*.cfg + releases: + - trusty + - xenial + types: + - container + +- path: /etc/netplan/10-lxc.yaml + generator: dump + content: |- + network: + version: 2 + ethernets: + enp5s0: + dhcp4: true + dhcp-identifier: mac + releases: + - bionic + - eoan + - focal + - groovy + types: + - vm + variants: + - default + +- path: /etc/network/interfaces + generator: dump + content: |- + # This file describes the network interfaces available on your system + # and how to activate them. For more information, see interfaces(5). + # The loopback network interface + auto lo + iface lo inet loopback + auto enp5s0 + iface enp5s0 inet dhcp + source /etc/network/interfaces.d/*.cfg + releases: + - trusty + - xenial + types: + - vm + +- path: /etc/init/lxc-tty.conf + generator: upstart-tty + releases: + - trusty + types: + - container + +- name: meta-data + generator: cloud-init + variants: + - cloud + +- name: network-config + generator: cloud-init + variants: + - cloud + +- name: user-data + generator: cloud-init + variants: + - cloud + +- name: vendor-data + generator: cloud-init + variants: + - cloud + +- name: ext4 + generator: fstab + types: + - vm + +- name: lxd-agent + generator: lxd-agent + types: + - vm + +- path: /etc/default/grub.d/50-lxd.cfg + generator: dump + content: |- + GRUB_RECORDFAIL_TIMEOUT=0 + GRUB_TIMEOUT=0 + GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} console=tty1 console=ttyS0" + GRUB_TERMINAL=console + types: + - vm + +- path: /etc/sudoers.d/90-lxd + generator: dump + mode: '0440' + content: |- + # User rules for ubuntu + ubuntu ALL=(ALL) NOPASSWD:ALL + variants: + - default + +packages: + manager: apt + update: true + cleanup: true + sets: + - packages: + - apt-transport-https + - fuse + - language-pack-en + - openssh-client + - vim + action: install + + - packages: + - cloud-init + action: install + variants: + - cloud + + - packages: + - acpid + action: install + architectures: + - amd64 + - arm64 + types: + - vm + + - packages: + - grub-efi-amd64-signed + - shim-signed + action: install + architectures: + - amd64 + types: + - vm + + - packages: + - grub-efi-arm64-signed + action: install + architectures: + - arm64 + types: + - vm + + - packages: + - shim-signed + action: install + architectures: + - arm64 + releases: + - disco + - eoan + - focal + - groovy + types: + - vm + + - packages: + - linux-virtual-hwe-16.04 + action: install + releases: + - xenial + types: + - vm + + - packages: + - linux-virtual + action: install + releases: + - bionic + - eoan + - focal + - groovy + types: + - vm + + - packages: + - os-prober + action: remove + types: + - vm + + repositories: + - name: sources.list + url: |- + deb http://archive.ubuntu.com/ubuntu {{ image.release }} main restricted universe multiverse + deb http://archive.ubuntu.com/ubuntu {{ image.release }}-updates main restricted universe multiverse + deb http://security.ubuntu.com/ubuntu {{ image.release }}-security main restricted universe multiverse + architectures: + - amd64 + - i386 + + - name: sources.list + url: |- + deb http://ports.ubuntu.com/ubuntu-ports {{ image.release }} main restricted universe multiverse + deb http://ports.ubuntu.com/ubuntu-ports {{ image.release }}-updates main restricted universe multiverse + deb http://ports.ubuntu.com/ubuntu-ports {{ image.release }}-security main restricted universe multiverse + architectures: + - armhf + - arm64 + - powerpc + - powerpc64 + - ppc64el + +actions: +- trigger: post-update + action: |- + #!/bin/sh + set -eux + # Create the ubuntu user account + getent group sudo >/dev/null 2>&1 || groupadd --system sudo + useradd --create-home -s /bin/bash -G sudo -U ubuntu + variants: + - default + +- trigger: post-packages + action: |- + #!/bin/sh + set -eux + # Enable systemd-networkd + systemctl enable systemd-networkd + releases: + - bionic + - eoan + - focal + - groovy + +- trigger: post-packages + action: |- + #!/bin/sh + set -eux + # Make sure the locale is built and functional + locale-gen en_US.UTF-8 + update-locale LANG=en_US.UTF-8 + # Cleanup underlying /run + mount -o bind / /mnt + rm -rf /mnt/run/* + umount /mnt + # Cleanup temporary shadow paths + rm /etc/*- +- trigger: post-files + action: |- + #!/bin/sh + set -eux + TARGET="x86_64" + [ "$(uname -m)" = "aarch64" ] && TARGET="arm64" + update-grub + grub-install --uefi-secure-boot --target="${TARGET}-efi" --no-nvram --removable + update-grub + sed -i "s#root=[^ ]*#root=/dev/sda2#g" /boot/grub/grub.cfg + types: + - vm + +mappings: + architecture_map: debian \ No newline at end of file diff --git a/container/steps/000-wait-for-network.sh b/container/steps/000-wait-for-network.sh deleted file mode 100644 index 7d9f9eb..0000000 --- a/container/steps/000-wait-for-network.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -while ! ping -c 1 -W 1 1.1.1.1; do - echo "Waiting for 1.1.1.1 - network is down" - sleep 1 -done diff --git a/container/steps/001-dependencies.sh b/container/steps/001-dependencies.sh deleted file mode 100644 index 65272fd..0000000 --- a/container/steps/001-dependencies.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -# install all necessary piston dependencies -echo 'source /opt/.profile' >> /opt/.bashrc -echo 'export HOME=/opt' >> /opt/.profile -echo 'export TERM=linux' >> /opt/.profile -echo 'export PATH=$PATH:/opt/.local/bin' >> /opt/.profile -export HOME=/opt -export TERM=linux -sed -i 's/\/root/\/opt/' /etc/passwd -sed -i \ - 's~http://archive.ubuntu.com/ubuntu~'"$APT_MIRROR~" \ - /etc/apt/sources.list - - -apt-get update -apt-get install -y \ - nano wget build-essential pkg-config libxml2-dev \ - libsqlite3-dev mono-complete curl cmake libpython2.7-dev \ - ruby libtinfo-dev unzip git openssl libssl-dev sbcl libevent-dev libffi-dev \ No newline at end of file diff --git a/container/steps/100-python2.sh b/container/steps/100-python2.sh deleted file mode 100644 index b307552..0000000 --- a/container/steps/100-python2.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -# install python2 -# final binary: /opt/python2/Python-2.7.17/python -# get version: /opt/python2/Python-2.7.17/python -V -cd /opt && mkdir python2 && cd python2 -wget https://www.python.org/ftp/python/2.7.17/Python-2.7.17.tar.xz -unxz Python-2.7.17.tar.xz -tar -xf Python-2.7.17.tar -cd Python-2.7.17 -./configure -# open Modules/Setup and uncomment zlib line -make -j$MAKE_THREADS -echo 'export PATH=$PATH:/opt/python2/Python-2.7.17' >> /opt/.profile -source /opt/.profile \ No newline at end of file diff --git a/container/steps/110-python3.sh b/container/steps/110-python3.sh deleted file mode 100644 index 7455947..0000000 --- a/container/steps/110-python3.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -# install python3 -# final binary: /opt/python3/Python-3.8.2/python -# get version: /opt/python3/Python-3.8.2/python -V -cd /opt && mkdir python3 && cd python3 -wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz -unxz Python-3.8.2.tar.xz -tar -xf Python-3.8.2.tar -cd Python-3.8.2 -./configure -make -j$MAKE_THREADS -ln -s python python3.8 -echo 'export PATH=$PATH:/opt/python3/Python-3.8.2' >> /opt/.profile -source /opt/.profile -curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py -python3.8 get-pip.py diff --git a/container/steps/111-paradoc.sh b/container/steps/111-paradoc.sh deleted file mode 100644 index fdd8260..0000000 --- a/container/steps/111-paradoc.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -# install paradoc -# this is not a binary, it is a python module -# therefore it cannot be run directly as it requires python3 to be installed -cd /opt && mkdir paradoc && cd paradoc -git clone https://github.com/betaveros/paradoc.git \ No newline at end of file diff --git a/container/steps/120-node.sh b/container/steps/120-node.sh deleted file mode 100644 index 636b5eb..0000000 --- a/container/steps/120-node.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -# install node.js -# final binary: /opt/nodejs/node-v12.16.1-linux-x64/bin/node -# get version: /opt/nodejs/node-v12.16.1-linux-x64/bin/node -v -cd /opt && mkdir nodejs && cd nodejs -wget https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.xz -unxz node-v12.16.1-linux-x64.tar.xz -tar -xf node-v12.16.1-linux-x64.tar -echo 'export PATH=$PATH:/opt/nodejs/node-v12.16.1-linux-x64/bin' >> /opt/.profile - -cat /opt/.profile \ No newline at end of file diff --git a/container/steps/121-typescript.sh b/container/steps/121-typescript.sh deleted file mode 100644 index cae1b16..0000000 --- a/container/steps/121-typescript.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -# install typescript -# final binary: /opt/nodejs/node-v12.16.1-linux-x64/bin/tsc -# get version: /opt/nodejs/node-v12.16.1-linux-x64/bin/tsc -v -/opt/nodejs/node-v12.16.1-linux-x64/bin/npm i -g typescript \ No newline at end of file diff --git a/container/steps/130-golang.sh b/container/steps/130-golang.sh deleted file mode 100644 index ac8b92d..0000000 --- a/container/steps/130-golang.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# install golang -# final binary: /opt/go/go/bin/go -# get version: /opt/go/go/bin/go version -cd /opt && mkdir go && cd go -wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz -tar -xzf go1.14.1.linux-amd64.tar.gz -echo 'export PATH=$PATH:/opt/go/go/bin' >> /opt/.profile -echo 'export GOROOT=/opt/go/go' >> /opt/.profile -echo 'export GOCACHE=/tmp' >> /opt/.profile diff --git a/container/steps/140-php.sh b/container/steps/140-php.sh deleted file mode 100644 index ae99a30..0000000 --- a/container/steps/140-php.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -# install php -# final binary: /usr/local/bin/php -# get version: /usr/local/bin/php -v -cd /opt && mkdir php && cd php -wget https://www.php.net/distributions/php-8.0.0.tar.gz -tar -xzf php-8.0.0.tar.gz -cd php-8.0.0 -./configure -make -j$MAKE_THREADS -make install \ No newline at end of file diff --git a/container/steps/150-rust.sh b/container/steps/150-rust.sh deleted file mode 100644 index db3294a..0000000 --- a/container/steps/150-rust.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -# install rust -# final binary: /usr/local/bin/rustc -# get version: /usr/local/bin/rustc --version -cd /opt && mkdir rust && cd rust -wget https://static.rust-lang.org/dist/rust-1.49.0-x86_64-unknown-linux-gnu.tar.gz -tar -xzf rust-1.49.0-x86_64-unknown-linux-gnu.tar.gz -cd rust-1.49.0-x86_64-unknown-linux-gnu -./install.sh \ No newline at end of file diff --git a/container/steps/160-swift.sh b/container/steps/160-swift.sh deleted file mode 100644 index 801b099..0000000 --- a/container/steps/160-swift.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -# install swift -# final binary: /opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin/swift -# get version: /opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin/swift --version -cd /opt && mkdir swift && cd swift -wget https://swift.org/builds/swift-5.1.5-release/ubuntu1804/swift-5.1.5-RELEASE/swift-5.1.5-RELEASE-ubuntu18.04.tar.gz -tar -xzf swift-5.1.5-RELEASE-ubuntu18.04.tar.gz -echo 'export PATH=$PATH:/opt/swift/swift-5.1.5-RELEASE-ubuntu18.04/usr/bin' >> /opt/.profile diff --git a/container/steps/170-nasm.sh b/container/steps/170-nasm.sh deleted file mode 100644 index d96d828..0000000 --- a/container/steps/170-nasm.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -# install nasm -# final binary: /opt/nasm/nasm-2.14.02/nasm -# get version: /opt/nasm/nasm-2.14.02/nasm -v -cd /opt && mkdir nasm && cd nasm -wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.gz -tar -xzf nasm-2.14.02.tar.gz -cd nasm-2.14.02 -./configure -make -j$MAKE_THREADS -echo 'export PATH=$PATH:/opt/nasm/nasm-2.14.02' >> /opt/.profile diff --git a/container/steps/180-java.sh b/container/steps/180-java.sh deleted file mode 100644 index 460c152..0000000 --- a/container/steps/180-java.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -# install java -# final binary: /opt/java/jdk-14/bin/java -# get version: /opt/java/jdk-14/bin/java -version -cd /opt && mkdir java && cd java -wget https://download.java.net/java/GA/jdk14/076bab302c7b4508975440c56f6cc26a/36/GPL/openjdk-14_linux-x64_bin.tar.gz -tar -xzf openjdk-14_linux-x64_bin.tar.gz -echo 'export PATH=$PATH:/opt/java/jdk-14/bin' >> /opt/.profile diff --git a/container/steps/190-jelly.sh b/container/steps/190-jelly.sh deleted file mode 100644 index 98719d4..0000000 --- a/container/steps/190-jelly.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -# install jelly -cd /opt && mkdir jelly && cd jelly -wget https://github.com/DennisMitchell/jellylanguage/archive/master.zip -unzip master.zip -cd jellylanguage-master -python3.8 -m pip install . -sed -i 's/\/usr\/local\/bin\/python3.8/\/opt\/python3\/Python-3.8.2\/python3.8/' /usr/local/bin/jelly diff --git a/container/steps/200-julia.sh b/container/steps/200-julia.sh deleted file mode 100644 index c77c575..0000000 --- a/container/steps/200-julia.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -# install julia -# final binary: /opt/julia/julia-1.5.0/bin/julia -# get version: /opt/julia/julia-1.5.0/bin/julia --version -cd /opt && mkdir julia && cd julia -wget https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.0-linux-x86_64.tar.gz -tar -xzf julia-1.5.0-linux-x86_64.tar.gz -echo 'export PATH=$PATH:/opt/julia/julia-1.5.0/bin' >> /opt/.profile diff --git a/container/steps/210-kotlin.sh b/container/steps/210-kotlin.sh deleted file mode 100644 index 5fa0ce0..0000000 --- a/container/steps/210-kotlin.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -# install kotlin -# final binary: /opt/kotlinc/bin/kotlinc -# get version: /opt/kotlinc/bin/kotlinc -version -cd /opt -wget https://github.com/JetBrains/kotlin/releases/download/v1.4.10/kotlin-compiler-1.4.10.zip -unzip kotlin-compiler-1.4.10.zip -rm kotlin-compiler-1.4.10.zip -echo 'export PATH=$PATH:/opt/kotlinc/bin' >> /opt/.profile \ No newline at end of file diff --git a/container/steps/220-elixar-erlang.sh b/container/steps/220-elixar-erlang.sh deleted file mode 100644 index 985df1f..0000000 --- a/container/steps/220-elixar-erlang.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -# install elixir and erlang -# final binary: /opt/elixir/bin/elixir -# get version: /opt/elixir/bin/elixir --version -# erlang -cd /opt && mkdir erlang && cd erlang -wget http://erlang.org/download/otp_src_23.0.tar.gz -gunzip -c otp_src_23.0.tar.gz | tar xf - -cd otp_src_23.0 && ./configure -make -j$MAKE_THREADS -echo 'export PATH=$PATH:/opt/erlang/otp_src_23.0/bin' >> /opt/.profile -source /opt/.profile -# elixir -cd /opt && mkdir elixir && cd elixir -wget https://github.com/elixir-lang/elixir/releases/download/v1.10.3/Precompiled.zip -mkdir elixir-1.10.3 && unzip Precompiled.zip -d elixir-1.10.3/ -echo 'export PATH=$PATH:/opt/elixir/elixir-1.10.3/bin' >> /opt/.profile - diff --git a/container/steps/230-emacs.sh b/container/steps/230-emacs.sh deleted file mode 100644 index 3b5e5e0..0000000 --- a/container/steps/230-emacs.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -# install emacs -# final binary: /opt/emacs/emacs-26.3/src/emacs -# get version: /opt/emacs/emacs-26.3/src/emacs --version -cd /opt && mkdir emacs && cd emacs -wget https://mirrors.ocf.berkeley.edu/gnu/emacs/emacs-26.3.tar.xz -tar -xf emacs-26.3.tar.xz -rm emacs-26.3.tar.xz -cd emacs-26.3 -./configure --with-gnutls=no -make -echo 'export PATH=$PATH:/opt/emacs/emacs-26.3/src' >> /opt/.profile \ No newline at end of file diff --git a/container/steps/240-lua.sh b/container/steps/240-lua.sh deleted file mode 100644 index 23c9338..0000000 --- a/container/steps/240-lua.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# install lua -# final binary: /opt/lua/lua54/src/lua -# get version: /opt/lua/lua54/src/lua -v -cd /opt && mkdir lua && cd lua -wget https://sourceforge.net/projects/luabinaries/files/5.4.0/Docs%20and%20Sources/lua-5.4.0_Sources.tar.gz/download -tar -xzf download -cd lua54 -make -j$MAKE_THREADS -echo 'export PATH=$PATH:/opt/lua/lua54/src' >> /opt/.profile \ No newline at end of file diff --git a/container/steps/250-haskell.sh b/container/steps/250-haskell.sh deleted file mode 100644 index 17ef3f3..0000000 --- a/container/steps/250-haskell.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -# install haskell -# final binary: /usr/bin/ghc -# get version: /usr/bin/ghc --version -apt install -y ghc diff --git a/container/steps/260-deno.sh b/container/steps/260-deno.sh deleted file mode 100644 index 23090cd..0000000 --- a/container/steps/260-deno.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -# install deno -# final binary: /opt/.deno/bin/deno -# get version: /opt/.deno/bin/deno --version -cd /opt && mkdir deno && cd deno -curl -fsSL https://deno.land/x/install/install.sh | sh -echo 'export DENO_INSTALL="/opt/.deno"' >> /opt/.profile -echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> /opt/.profile diff --git a/container/steps/270-brainfuck.sh b/container/steps/270-brainfuck.sh deleted file mode 100644 index 5e5cdaa..0000000 --- a/container/steps/270-brainfuck.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -# install brainfuck -cd /opt && mkdir bf && cd bf -git clone https://github.com/texus/Brainfuck-interpreter -cd Brainfuck-interpreter -echo 'export PATH=$PATH:/opt/bf/Brainfuck-interpreter' >> /opt/.profile -source /opt/.profile diff --git a/container/steps/280-crystal.sh b/container/steps/280-crystal.sh deleted file mode 100644 index cba176d..0000000 --- a/container/steps/280-crystal.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -# install crystal -# final binary: /opt/crystal/crystal-0.35.1-1/bin/crystal -# get version: /opt/crystal/crystal-0.35.1-1/bin/crystal -v -cd /opt && mkdir crystal && cd crystal -wget https://github.com/crystal-lang/crystal/releases/download/0.35.1/crystal-0.35.1-1-linux-x86_64.tar.gz -tar -xzf crystal-0.35.1-1-linux-x86_64.tar.gz -echo 'export PATH="$PATH:/opt/crystal/crystal-0.35.1-1/bin:$PATH"' >> /opt/.profile diff --git a/container/steps/290-d.sh b/container/steps/290-d.sh deleted file mode 100644 index 133e54c..0000000 --- a/container/steps/290-d.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# install d -# final binary: /opt/d/dmd2/linux/bin64/dmd -# get version: /opt/d/dmd2/linux/bin64/dmd --version -cd /opt && mkdir d && cd d -wget http://downloads.dlang.org/releases/2.x/2.095.0/dmd.2.095.0.linux.tar.xz -unxz dmd.2.095.0.linux.tar.xz -tar -xf dmd.2.095.0.linux.tar -echo 'export PATH=$PATH:/opt/d/dmd2/linux/bin64' >> /opt/.profile -source /opt/.profile diff --git a/container/steps/300-zig.sh b/container/steps/300-zig.sh deleted file mode 100644 index 96fd2fa..0000000 --- a/container/steps/300-zig.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# install zig -# final binary: /opt/zig/zig -# get version: /opt/zig/zig version -cd /opt && mkdir zig && cd zig -wget https://ziglang.org/download/0.7.1/zig-linux-x86_64-0.7.1.tar.xz -tar -xf zig-linux-x86_64-0.7.1.tar.xz -mv zig-linux-x86_64-0.7.1 zig -rm zig-linux-x86_64-0.7.1.tar.xz -echo 'export PATH=$PATH:/opt/zig/zig' >> /opt/.profile diff --git a/container/steps/310-nim.sh b/container/steps/310-nim.sh deleted file mode 100644 index 6aa91bd..0000000 --- a/container/steps/310-nim.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -# install nim -# final binary: /opt/nim/bin/nim -# get version: /opt/nim/bin/nim -v -cd /opt && mkdir nim && cd nim -wget https://nim-lang.org/download/nim-1.4.0-linux_x64.tar.xz -unxz nim-1.4.0-linux_x64.tar.xz -tar -xf nim-1.4.0-linux_x64.tar -cd nim-1.4.0 -./install.sh /opt -echo 'export PATH=$PATH:/opt/nim/bin' >> /opt/.profile \ No newline at end of file diff --git a/container/steps/900-runner-users.sh b/container/steps/900-runner-users.sh deleted file mode 100644 index f15545c..0000000 --- a/container/steps/900-runner-users.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# create runnable users and apply limits -for i in {1..150}; do - useradd -M runner$i - usermod -d /tmp runner$i - echo "runner$i soft nproc 64" >> /etc/security/limits.conf - echo "runner$i hard nproc 64" >> /etc/security/limits.conf - echo "runner$i soft nofile 2048" >> /etc/security/limits.conf - echo "runner$i hard nofile 2048" >> /etc/security/limits.conf -done \ No newline at end of file diff --git a/container/steps/910-cleanup.sh b/container/steps/910-cleanup.sh deleted file mode 100644 index 09112cc..0000000 --- a/container/steps/910-cleanup.sh +++ /dev/null @@ -1,12 +0,0 @@ -# remove any lingering write access to others -cd /opt -chown -R root: * -chmod -R o-w * - -# cleanup -rm -rf /home/ubuntu -chmod 777 /tmp - -# disable cron -systemctl stop cron -systemctl disable cron From c33d57fa1a6696ab1edad0097f6c4d34ec0b18f1 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 22:20:39 +1300 Subject: [PATCH 10/18] fix ci --- .github/workflows/lxc-build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml index 6423a88..f14f446 100644 --- a/.github/workflows/lxc-build.yml +++ b/.github/workflows/lxc-build.yml @@ -22,7 +22,6 @@ jobs: run: sudo ./build.sh working-directory: container - working-directory: container - name: chown everything run: | sudo chown -R runner:runner . From 6d20a108e9affc3c6cead9c85e20996617253b9e Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 22:22:57 +1300 Subject: [PATCH 11/18] build distrobuilder from source --- .github/workflows/lxc-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml index f14f446..f0fce01 100644 --- a/.github/workflows/lxc-build.yml +++ b/.github/workflows/lxc-build.yml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@v2 - name: Install Distrobuilder - run: sudo apt-get install -y distrobuilder + run: sudo go get -v -x github.com/lxc/distrobuilder/distrobuilder # build container - name: Build Artifact run: sudo ./build.sh From bc8b8787efb45d7f72b7922b09cd7fb2b901c2fd Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 22:53:54 +1300 Subject: [PATCH 12/18] go bin file directly --- .github/workflows/lxc-build.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml index f0fce01..9facff8 100644 --- a/.github/workflows/lxc-build.yml +++ b/.github/workflows/lxc-build.yml @@ -16,10 +16,14 @@ jobs: uses: actions/checkout@v2 - name: Install Distrobuilder - run: sudo go get -v -x github.com/lxc/distrobuilder/distrobuilder + run: | + sudo go get -v -x github.com/lxc/distrobuilder/distrobuilder + sudo python3 -m pip install pyyaml # build container - name: Build Artifact - run: sudo ./build.sh + run: | + python3 configure.py + sudo /home/runner/go/bin/distrobuilder build-lxc build.yaml working-directory: container - name: chown everything From 59dd4e9c01e23d91424a92b4ee95e0f53a591374 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 23:04:52 +1300 Subject: [PATCH 13/18] ci --- .github/workflows/lxc-build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml index 9facff8..7d11740 100644 --- a/.github/workflows/lxc-build.yml +++ b/.github/workflows/lxc-build.yml @@ -17,6 +17,8 @@ jobs: - name: Install Distrobuilder run: | + sudo apt update + sudo apt install -y golang-go debootstrap rsync gpg squashfs-tools git sudo go get -v -x github.com/lxc/distrobuilder/distrobuilder sudo python3 -m pip install pyyaml # build container From dde705da5658094bbfd3f1f5e47eda4fb9d8080e Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 23:10:55 +1300 Subject: [PATCH 14/18] bionic based --- .github/workflows/lxc-build.yml | 2 +- container/piston.yaml | 6 +++--- readme.md | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml index 7d11740..4040944 100644 --- a/.github/workflows/lxc-build.yml +++ b/.github/workflows/lxc-build.yml @@ -19,7 +19,7 @@ jobs: run: | sudo apt update sudo apt install -y golang-go debootstrap rsync gpg squashfs-tools git - sudo go get -v -x github.com/lxc/distrobuilder/distrobuilder + sudo go get -x github.com/lxc/distrobuilder/distrobuilder sudo python3 -m pip install pyyaml # build container - name: Build Artifact diff --git a/container/piston.yaml b/container/piston.yaml index 550c834..b8b3a3c 100644 --- a/container/piston.yaml +++ b/container/piston.yaml @@ -1,14 +1,14 @@ image: - name: ubuntu-disco-x86_64-piston + name: ubuntu-bionic-x86_64-piston distribution: ubuntu - release: focal + release: bionic description: |- Ubuntu {{ image.release }} preconfigured for Piston architecture: x86_64 source: downloader: debootstrap - same_as: gutsy + same_as: bionic url: http://archive.ubuntu.com/ubuntu keyserver: keyserver.ubuntu.com keys: diff --git a/readme.md b/readme.md index 8be5356..8506c0f 100644 --- a/readme.md +++ b/readme.md @@ -141,20 +141,20 @@ cd piston/lxc #### Installation (simple) -- `mkdir -p /var/lib/lxc/piston` -- `cd /var/lib/lxc/piston` - `wget [latest container url] -o container.zip` - `unzip container.zip` -- `tar xzf rootfs.tar.gz` -- `rm rootfs.tar.gz container.zip` +- `lxc-create -n piston -t local -- --metadata meta.tar.xz --fstree rootfs.tar.xz` +- `cd ../lxc && ./start` - Good to go! #### Installation (advanced) -- `cd ../container && ./install.sh` +- Install additional dependencies python3, pip and distrobuilder +- `cd ../container && ./build.sh` - Wait, it may take up to an hour. -- `cd ../lxc && ./start && cd ..` +- `lxc-create -n piston -t local -- --metadata meta.tar.xz --fstree rootfs.tar.xz` +- `cd ../lxc && ./start` - Good to go! Alternatively, see `var/install.txt` for how to build the container manually From aa3a1a239ff05da12597aa31d768d90bea3490f4 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 23:15:08 +1300 Subject: [PATCH 15/18] dont update go --- .github/workflows/lxc-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml index 4040944..710f18e 100644 --- a/.github/workflows/lxc-build.yml +++ b/.github/workflows/lxc-build.yml @@ -18,7 +18,7 @@ jobs: - name: Install Distrobuilder run: | sudo apt update - sudo apt install -y golang-go debootstrap rsync gpg squashfs-tools git + sudo apt install -y debootstrap rsync gpg squashfs-tools git sudo go get -x github.com/lxc/distrobuilder/distrobuilder sudo python3 -m pip install pyyaml # build container From 3bcb96832de22bcefe58e35f0b6d7d0ffe078c3a Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Thu, 28 Jan 2021 23:21:17 +1300 Subject: [PATCH 16/18] install go 14 --- .github/workflows/lxc-build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml index 710f18e..7dadb82 100644 --- a/.github/workflows/lxc-build.yml +++ b/.github/workflows/lxc-build.yml @@ -15,6 +15,11 @@ jobs: - name: Checkout Repository uses: actions/checkout@v2 + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: '^1.14.14' + - name: Install Distrobuilder run: | sudo apt update From 062c4c89c8aadb3ed32824edac07322d549aff1e Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Fri, 29 Jan 2021 13:27:54 +1300 Subject: [PATCH 17/18] Remove CI --- .github/workflows/lxc-build.yml | 47 --------------------------------- readme.md | 14 +++------- 2 files changed, 4 insertions(+), 57 deletions(-) delete mode 100644 .github/workflows/lxc-build.yml diff --git a/.github/workflows/lxc-build.yml b/.github/workflows/lxc-build.yml deleted file mode 100644 index 7dadb82..0000000 --- a/.github/workflows/lxc-build.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- - -name: LXC Build - -on: - push: - workflow_dispatch: - -jobs: - packer: - runs-on: ubuntu-latest - name: packer - - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: '^1.14.14' - - - name: Install Distrobuilder - run: | - sudo apt update - sudo apt install -y debootstrap rsync gpg squashfs-tools git - sudo go get -x github.com/lxc/distrobuilder/distrobuilder - sudo python3 -m pip install pyyaml - # build container - - name: Build Artifact - run: | - python3 configure.py - sudo /home/runner/go/bin/distrobuilder build-lxc build.yaml - working-directory: container - - - name: chown everything - run: | - sudo chown -R runner:runner . - working-directory: container - - # Upload container - - uses: actions/upload-artifact@v2 - with: - name: lxc-container - path: | - container/output-piston-bionic/meta.tar.xz - container/output-piston-bionic/rootfs.tar.xz \ No newline at end of file diff --git a/readme.md b/readme.md index 8506c0f..a7b3c34 100644 --- a/readme.md +++ b/readme.md @@ -141,15 +141,6 @@ cd piston/lxc #### Installation (simple) -- `wget [latest container url] -o container.zip` -- `unzip container.zip` -- `lxc-create -n piston -t local -- --metadata meta.tar.xz --fstree rootfs.tar.xz` -- `cd ../lxc && ./start` -- Good to go! - - -#### Installation (advanced) - - Install additional dependencies python3, pip and distrobuilder - `cd ../container && ./build.sh` - Wait, it may take up to an hour. @@ -157,7 +148,10 @@ cd piston/lxc - `cd ../lxc && ./start` - Good to go! -Alternatively, see `var/install.txt` for how to build the container manually + +#### Installation (advanced) + +- See `var/install.txt` for how to build the container manually #### CLI Usage - `cli/execute [language] [file path] [args]` From 8d92661cfd3a869cc0c5bd78ef5e3760fe8265c9 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Fri, 29 Jan 2021 13:28:32 +1300 Subject: [PATCH 18/18] Add new lines --- .gitignore | 2 +- container/configure.py | 2 +- container/piston.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 932e600..5dcba17 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ api/api lxc/i lxc/lockfile container/build.yaml -container/*.tar.xz \ No newline at end of file +container/*.tar.xz diff --git a/container/configure.py b/container/configure.py index 5550313..5c02fd3 100644 --- a/container/configure.py +++ b/container/configure.py @@ -10,4 +10,4 @@ with open('piston.yaml') as dbc: 'action': install_script_file.read(), }) - yaml.dump(distrobuilder_config, distrobuilder_config_file_new) \ No newline at end of file + yaml.dump(distrobuilder_config, distrobuilder_config_file_new) diff --git a/container/piston.yaml b/container/piston.yaml index b8b3a3c..4cbb9c0 100644 --- a/container/piston.yaml +++ b/container/piston.yaml @@ -352,4 +352,4 @@ actions: - vm mappings: - architecture_map: debian \ No newline at end of file + architecture_map: debian