Skip to content

Instantly share code, notes, and snippets.

@ailispaw
Last active December 8, 2016 05:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ailispaw/4c90d9f2086ae388f998ed0c809e820c to your computer and use it in GitHub Desktop.
Save ailispaw/4c90d9f2086ae388f998ed0c809e820c to your computer and use it in GitHub Desktop.
MariaDB on NFS + bindfs in Barge with Vagrant
# A dummy plugin for Barge to set hostname and network correctly at the very first `vagrant up`
module VagrantPlugins
module GuestLinux
class Plugin < Vagrant.plugin("2")
guest_capability("linux", "change_host_name") { Cap::ChangeHostName }
guest_capability("linux", "configure_networks") { Cap::ConfigureNetworks }
end
end
end
PWD=Dir.pwd
Vagrant.configure(2) do |config|
config.vm.define "barge-bindfs"
config.vm.box = "ailispaw/barge"
config.vm.network :private_network, ip: "192.168.33.10"
config.vm.synced_folder ".", "/vagrant", type: "nfs",
mount_options: ["nolock", "vers=3", "udp", "noatime", "actimeo=1"]
config.vm.provision :shell, run: "always" do |sh|
sh.inline = <<-EOT
pkg install bindfs
if mountpoint -q /vagrant && ! mountpoint -q '#{PWD}/mariadb'; then
mkdir -p /vagrant/mariadb
mkdir -p '#{PWD}/mariadb'
_UID=$(ls -ld /vagrant | awk '{print $3}')
_GID=$(ls -ld /vagrant | awk '{print $4}')
bindfs --map=${_UID}/999:@${_GID}/@999 /vagrant/mariadb '#{PWD}/mariadb'
fi
docker rm -f mariadb || true
EOT
end
config.vm.provision :docker, run: "always" do |docker|
docker.pull_images "mariadb"
docker.run "mariadb",
image: "mariadb",
args: [
"-e MYSQL_ROOT_PASSWORD=test",
"-v '#{PWD}/mariadb':/var/lib/mysql",
"-p 3306:3306"
].join(" "),
restart: false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment