|
| 1 | +# -*- mode: ruby -*- |
| 2 | +# vi: set ft=ruby : |
| 3 | + |
| 4 | +# All Vagrant configuration is done below. The "2" in Vagrant.configure |
| 5 | +# configures the configuration version (we support older styles for |
| 6 | +# backwards compatibility). Please don't change it unless you know what |
| 7 | +# you're doing. |
| 8 | +Vagrant.configure("2") do |config| |
| 9 | + # The most common configuration options are documented and commented below. |
| 10 | + # For a complete reference, please see the online documentation at |
| 11 | + # https://docs.vagrantup.com. |
| 12 | + |
| 13 | + # Check for plugins needed |
| 14 | + if !Vagrant.has_plugin?("vagrant-disksize") |
| 15 | + print " WARN: Missing plugin 'vagrant-disksize'.\n" |
| 16 | + print " Use 'vagrant plugin install vagrant-disksize' to install.\n" |
| 17 | + end |
| 18 | + |
| 19 | + if !Vagrant.has_plugin?("vagrant-docker-compose") |
| 20 | + print " WARN: Missing plugin 'vagrant-docker-compose'.\n" |
| 21 | + print " Use 'vagrant plugin install vagrant-docker-compose' to install.\n" |
| 22 | + end |
| 23 | + |
| 24 | + # Every Vagrant development environment requires a box. You can search for |
| 25 | + # boxes at https://vagrantcloud.com/search. |
| 26 | + config.vm.box = "ubuntu/bionic64" |
| 27 | + config.vm.hostname = "scb-test" |
| 28 | + |
| 29 | + # Defines a given disk size for this Box. |
| 30 | + # You can search for this plugin at https://github.com/sprotheroe/vagrant-disksize |
| 31 | + config.disksize.size = '40GB' |
| 32 | + |
| 33 | + # Disable automatic box update checking. If you disable this, then |
| 34 | + # boxes will only be checked for updates when the user runs |
| 35 | + # `vagrant box outdated`. This is not recommended. |
| 36 | + # config.vm.box_check_update = false |
| 37 | + |
| 38 | + # Create a forwarded port mapping which allows access to a specific port |
| 39 | + # within the machine from a port on the host machine. In the example below, |
| 40 | + # accessing "localhost:8080" will access port 80 on the guest machine. |
| 41 | + # NOTE: This will enable public access to the opened port |
| 42 | + config.vm.network "forwarded_port", guest: 80, host: 80 |
| 43 | + config.vm.network "forwarded_port", guest: 8080, host: 8080 |
| 44 | + config.vm.network "forwarded_port", guest: 443, host: 443 |
| 45 | + config.vm.network "forwarded_port", guest: 8443, host: 8443 |
| 46 | + config.vm.network "forwarded_port", guest: 9200, host: 9200 |
| 47 | + config.vm.network "forwarded_port", guest: 5601, host: 5601 |
| 48 | + |
| 49 | + |
| 50 | + # Create a forwarded port mapping which allows access to a specific port |
| 51 | + # within the machine from a port on the host machine and only allow access |
| 52 | + # via 127.0.0.1 to disable public access |
| 53 | + # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" |
| 54 | + |
| 55 | + # Create a private network, which allows host-only access to the machine |
| 56 | + # using a specific IP. |
| 57 | + # config.vm.network "private_network", ip: "192.168.33.10" |
| 58 | + |
| 59 | + # Create a public network, which generally matched to bridged network. |
| 60 | + # Bridged networks make the machine appear as another physical device on |
| 61 | + # your network. |
| 62 | + # config.vm.network "public_network" |
| 63 | + |
| 64 | + #config.ssh.guest_port = 29683 |
| 65 | + |
| 66 | + # Share an additional folder to the guest VM. The first argument is |
| 67 | + # the path on the host to the actual folder. The second argument is |
| 68 | + # the path on the guest to mount the folder. And the optional third |
| 69 | + # argument is a set of non-required options. |
| 70 | + # config.vm.synced_folder "../data", "/vagrant_data" |
| 71 | + |
| 72 | + # Provider-specific configuration so you can fine-tune various |
| 73 | + # backing providers for Vagrant. These expose provider-specific options. |
| 74 | + # Example for VirtualBox: |
| 75 | + # |
| 76 | + config.vm.provider "virtualbox" do |vb| |
| 77 | + vb.name = "scb-test" |
| 78 | + |
| 79 | + # Display the VirtualBox GUI when booting the machine |
| 80 | + vb.gui = false |
| 81 | + |
| 82 | + # Customize the amount of memory on the VM: |
| 83 | + vb.memory = "8192" |
| 84 | + vb.cpus = 1 |
| 85 | + end |
| 86 | + |
| 87 | + |
| 88 | + # |
| 89 | + # View the documentation for the provider you are using for more |
| 90 | + # information on available options. |
| 91 | + |
| 92 | + # Enable provisioning with a shell script. Additional provisioners such as |
| 93 | + # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the |
| 94 | + # documentation for more information about their specific syntax and use. |
| 95 | + # config.vm.provision "shell", inline: <<-SHELL |
| 96 | + # apt-get update |
| 97 | + # apt-get install -y apache2 |
| 98 | + # SHELL |
| 99 | + |
| 100 | + compose_env = Hash.new |
| 101 | + if File.file?(".env") |
| 102 | + array = File.read(".env").split("\n") |
| 103 | + array.each do |e| |
| 104 | + unless e.start_with?("#") |
| 105 | + var = e.split("=") |
| 106 | + compose_env[var[0]] = var[1] |
| 107 | + end |
| 108 | + end |
| 109 | + end |
| 110 | + |
| 111 | + # If errors occur, try running "vagrant provision" manually |
| 112 | + # after "vagrant up" |
| 113 | + config.vm.provision :docker |
| 114 | + |
| 115 | + # To use docker_compose as a provisioning tool, install |
| 116 | + # vagrant-docker-compose plugin first. It should also solve the |
| 117 | + # "The '' provisioner could not be found." error: |
| 118 | + # $ vagrant plugin install vagrant-docker-compose |
| 119 | + config.vm.provision :docker_compose, |
| 120 | + project_name: "docker-vagrant", |
| 121 | + yml: [ |
| 122 | + "/vagrant/docker-compose.yml", |
| 123 | + "/vagrant/docker-compose.demo.yml" |
| 124 | + ], |
| 125 | + env: compose_env, |
| 126 | + run: "always" |
| 127 | +end |
0 commit comments