This commit is contained in:
Mo 2022-08-07 20:20:14 +02:00
parent d658894c1d
commit 6cc1692d89
3 changed files with 71 additions and 0 deletions
containers
images
volumes/traefik

22
containers/ttyd.fish Executable file
View file

@ -0,0 +1,22 @@
#!/usr/bin/fish
if test -z $argv[1]
echo "A container number as an argument is required!"
exit 1
end
set -l container_name ttyd$argv[1]
set -l container_volumes_dir ~/volumes/$container_name
set -l container_home_dir $container_volumes_dir/home
mkdir -p $container_volumes_dir
if not test -d $container_home_dir
cp -r ~/sync/volumes/ubuntu_home $container_home_dir
end
podman-default-create \
$container_name \
--network traefik \
-v $container_home_dir:/home/student:Z \
localhost/ttyd:latest

35
images/ttyd.fish Executable file
View file

@ -0,0 +1,35 @@
#!/usr/bin/fish
if podman image exists ttyd
podman rmi ttyd
end
buildah rm builder &>/dev/null
buildah from --pull --name builder docker.io/library/ubuntu:latest
buildah run builder -- apt update
buildah run builder -- apt dist-upgrade -y
buildah run builder -- apt install -y git fish python3
buildah run builder -- apt install -y sudo software-properties-common
buildah run builder -- add-apt-repository -y ppa:neovim-ppa/stable
buildah run builder -- apt update
buildah run builder -- apt install neovim -y
buildah run builder -- apt install -y build-essential cmake libjson-c-dev libwebsockets-dev
buildah run builder -- git clone https://github.com/tsl0922/ttyd.git /root/src/ttyd
buildah run builder -- mkdir -p /root/src/ttyd/build
buildah config --workingdir /root/src/ttyd/build builder
buildah run builder -- cmake ..
buildah run builder -- make
buildah run builder -- make install
buildah run builder -- apt autoremove -y
buildah run builder -- apt clean
buildah run builder -- adduser student
buildah run builder -- usermod -aG sudo student
buildah config --workingdir /home/student --cmd "bash -c 'chown -R student:student /home/student && runuser -u student -- ttyd -p 8080 -c $TTYD_USER:$TTYD_PASSWORD bash'" builder
buildah commit --rm builder ttyd

View file

@ -21,6 +21,14 @@ http:
service: nextcloud
tls:
certResolver: le
{{ $max_ttyd_num := 1 }}
{{ range $index, $num := until $max_ttyd_num }}
to_ttyd{{ $num }}:
rule: Host(`ttyd{{ $num }}.mo8it.xyz`)
service: ttyd{{ $num }}
tls:
certResolver: le
{{ end }}
services:
dudu_hugo:
@ -39,3 +47,9 @@ http:
loadBalancer:
servers:
- url: http://nextcloud
{{ range $index, $num := until $max_ttyd_num }}
ttyd{{ $num }}:
loadBalancer:
servers:
- url: http://ttyd{{ $num }}:8080
{{ end }}