Skip to content

Instantly share code, notes, and snippets.

@joshuacox
Created May 23, 2022 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuacox/267062259e38de8a45545faca8b50467 to your computer and use it in GitHub Desktop.
Save joshuacox/267062259e38de8a45545faca8b50467 to your computer and use it in GitHub Desktop.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "generic/ubuntu2004"
config.vm.provision "shell", inline: <<-SHELL
#!/bin/bash
: ${NOMAD_VERSION:=1.3.1}
: ${WAYPOINT_VERSION:=0.8.2}
set -ux
sudo apt-get update
sudo apt-get -yqq install ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -yqq docker-ce docker-ce-cli containerd.io docker-compose-plugin
cd
echo 'export PATH=$HOME/bin:$PATH' >> .bashrc
git clone --depth=1 https://github.com/hashicorp/waypoint-examples.git
mkdir bin
cd bin
curl https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad_${NOMAD_VERSION}_linux_amd64.zip
unzip nomad_${NOMAD_VERSION}_linux_amd64.zip
rm -v nomad_${NOMAD_VERSION}_linux_amd64.zip
chmod +x nomad
curl https://releases.hashicorp.com/waypoint/${WAYPOINT_VERSION}/waypoint_${WAYPOINT_VERSION}_linux_amd64.zip -o waypoint_${WAYPOINT_VERSION}_linux_amd64.zip
unzip waypoint_${WAYPOINT_VERSION}_linux_amd64.zip
rm -v waypoint_${WAYPOINT_VERSION}_linux_amd64.zip
chmod +x waypoint
ls -alh
cd
mkdir -p /data/waypoint-server
chown 100 /data/waypoint-server
echo 'client { host_volume "waypoint-server" { path = "/data/waypoint-server", read_only = false }}'>nomad.config
echo 'IFACE=eth0
nomad agent -dev -network-interface=$IFACE -config=nomad.config 1>/tmp/nomad.stdout 2>/tmp/nomad.stderr &
THIS_RESULT=1
THIS_COUNT=0
echo -n "Awaiting nomad to start."
until [[ $THIS_RESULT == 0 ]];
do
nomad status &> /dev/null
THIS_RESULT=$?
sleep 2
((++THIS_COUNT))
done
echo "# $THIS_COUNT"
time waypoint install -platform=nomad -accept-tos -nomad-host-volume=waypoint-server -nomad-consul-service=false
cd ~/waypoint-examples/nomad/nodejs
waypoint init
waypoint up' > start.sh
chmod +x start.sh
SHELL
end
@joshuacox
Copy link
Author

vagrant up && vagrant ssh

then

sudo -i
./start.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment