You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tty-server/vagrantfile

51 lines
1.7 KiB
Plaintext

Vagrant.configure("2") do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "becorecode/alpinelinux-3.11"
config.vm.box_version = "1.0.0"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine.
# By connecting to localhost:8080 from the host, we can access the guest's
# webserver.
config.vm.network :forwarded_port, guest: 5000, host: 8080
config.vm.network :forwarded_port, guest: 22, host: 5522
config.vm.network :forwarded_port, guest: 6543, host: 6543
# Forward x11 via ssh.
# Handy if you need to share a clipboard, convey viewport info, etc.
config.ssh.forward_x11 = true
config.ssh.shell = "ash"
$install_script = <<-SCRIPT
build_deps="go make dep"
runtime_deps="dumb-init bash"
apk update && \
apk add -u $build_deps $runtime_deps && \
cd /go/src/github.com/elisescu/tty-server && \
GOPATH=/go dep ensure && \
GOPATH=/go make all && \
cp tty-server /usr/bin/ && \
rm -r /go && \
apk del $build_deps
SCRIPT
$serve_script = <<-SCRIPT
cat << EOD > /usr/bin/serve
#!/usr/bin/env bash
URL="${1:-http://localhost:5000}"
/usr/bin/tty-server -web_address :5000 --sender_address :6543 -url "$URL"
EOD
chmod a+x /usr/bin/serve
SCRIPT
config.vm.provision "file", source: ".", destination: "$HOME/go/src/github.com/elisescu/tty-server"
config.vm.provision "shell", inline: 'mv "/home/vagrant/go" "/go"', name: "move_go"
config.vm.provision "shell", inline: $install_script, name: "install"
config.vm.provision "shell", inline: $serve_script, name: "serve"
end