Created
June 2, 2025 15:15
-
-
Save ZwangaMukwevho/f924cac57a6475fdd4876157a1e5793a to your computer and use it in GitHub Desktop.
Vagrant file for creating Ubuntu VM with dependencies installed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Vagrant.configure("2") do |config| | |
| config.vm.box = "ubuntu/focal64" | |
| config.vm.hostname = "doc-classification" | |
| # Forward HTTP port 80 on guest to 8080 on host | |
| config.vm.network "forwarded_port", guest: 80, host: 8080 | |
| # Forward SSH agent (optional) | |
| config.ssh.forward_agent = true | |
| # Sync scripts folder (optional) | |
| config.vm.synced_folder "./scripts", "/home/vagrant/scripts" | |
| config.vm.provision "shell", inline: <<-SHELL | |
| set -eux | |
| # Update and upgrade packages | |
| sudo apt-get update | |
| sudo apt-get -y upgrade | |
| # Install basic packages (except golang) | |
| sudo apt-get install -y git nginx certbot python3-certbot-nginx ufw curl npm | |
| # Setup firewall | |
| sudo ufw allow 'Nginx Full' | |
| sudo ufw allow OpenSSH | |
| sudo ufw --force enable | |
| # Install Node.js 20 via NodeSource | |
| curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - | |
| sudo apt-get install -y nodejs | |
| # Install pm2 globally | |
| sudo npm install -g pm2 | |
| # Install latest Go | |
| GO_VERSION="1.21.1" | |
| wget https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz | |
| sudo rm -rf /usr/local/go | |
| sudo tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz | |
| rm go${GO_VERSION}.linux-amd64.tar.gz | |
| echo "export PATH=\$PATH:/usr/local/go/bin" >> /home/vagrant/.profile | |
| echo "export GOPATH=\$HOME/go" >> /home/vagrant/.profile | |
| echo "export PATH=\$PATH:\$GOPATH/bin" >> /home/vagrant/.profile | |
| echo "export PATH=\$PATH:/usr/local/go/bin" >> /root/.profile | |
| echo "export GOPATH=\$HOME/go" >> /root/.profile | |
| echo "export PATH=\$PATH:\$GOPATH/bin" >> /root/.profile | |
| sudo systemctl enable nginx | |
| sudo systemctl restart nginx | |
| SHELL | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment