BryanDavis has uploaded a new change for review. https://gerrit.wikimedia.org/r/157633
Change subject: Add support for Docker ...................................................................... Add support for Docker Add configuration to support using the built-in Vagrant Docker provider. See support/docker/README.md for usage instructions. Change-Id: I606e7f8b95f145cb7263c51fcbede25adf28e84e --- M Vagrantfile A support/docker/Dockerfile A support/docker/README.md 3 files changed, 149 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant refs/changes/33/157633/1 diff --git a/Vagrantfile b/Vagrantfile index 3d0ba5b..d1dbb07 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -56,14 +56,23 @@ config.vm.hostname = 'mediawiki-vagrant.dev' config.package.name = 'mediawiki.box' + # Default VirtualBox provider config.vm.provider :virtualbox do |vb, override| override.vm.box = 'trusty-cloud' override.vm.box_url = 'https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box' override.vm.box_download_insecure = true end + # VMWare Fusion provider. Enable with `--provider=vmware_fusion` config.vm.provider :vmware_fusion do |vw, override| override.vm.box = 'puppetlabs/ubuntu-14.04-64-puppet' + end + + # Docker provider. Enable with `--provider=docker` + config.vm.provider :docker do |docker, override| + # Disable nfs shares for + # https://github.com/mitchellh/vagrant/issues/4011 + override.nfs.functional = false end config.vm.network :private_network, ip: settings[:static_ip] @@ -127,6 +136,14 @@ #vw.gui = true end + config.vm.provider :docker do |docker| + docker.build_dir = './support/docker' + docker.create_args = ['-i', '-t'] + docker.has_ssh = true + docker.remains_running = true + docker.privileged = true + end + config.vm.provision :puppet do |puppet| puppet.module_path = 'puppet/modules' puppet.manifests_path = 'puppet/manifests' diff --git a/support/docker/Dockerfile b/support/docker/Dockerfile new file mode 100644 index 0000000..119883d --- /dev/null +++ b/support/docker/Dockerfile @@ -0,0 +1,68 @@ +# Dockerfile for Mediawiki-Vagrant +# --------------------------------- +# http://www.mediawiki.org/wiki/Mediawiki-Vagrant +# +# Provisions a base Docker image for use with Mediawiki-Vagrant. This is not +# intended to be an example of the best way to use Docker. We are attempting +# to use the lxc container managed by Docker as a full virtual machine +# replacement rather than as a light weight service container. Once the image +# is built and running, MediaWiki-Vagrant will run puppet inside the container +# to provision a full stack MediaWiki development environment. +# + +# Use base image that runs /sbin/init providing a "machine mode" container +FROM stackbrew/ubuntu-upstart:14.04 +MAINTAINER Mediawiki-Vagrant <http://www.mediawiki.org/wiki/Mediawiki-Vagrant> + +# Disable grub and lilo updates +ENV INITRD no + +# Always report that this is a chroot +RUN dpkg-divert --local --rename --add /usr/bin/ischroot \ + && ln -sf /bin/true /usr/bin/ischroot + +# Install required packages for using puppet to provision the container +RUN apt-get update \ + && INITRD=no DEBIAN_FRONTEND=noninteractive apt-get \ + -o Dpkg::Options::='--force-confdef' \ + -o Dpkg::Options::='--force-confold' \ + -o Dpkg::Options::='--force-unsafe-io' \ + install \ + --no-install-recommends --fix-broken --auto-remove --yes --quiet \ + apt-utils \ + curl \ + facter \ + lsb-release \ + openssh-server \ + puppet \ + puppet-common \ + ruby-hiera \ + sudo \ + virt-what \ + wget + +# Setup things for the container in general +RUN ln -sf /usr/share/zoneinfo/Universal /etc/localtime + +# Make state directory for sshd in case we need to start it directly for +# debugging. +RUN mkdir /var/run/sshd + +# Create and configure vagrant user +RUN useradd --create-home -s /bin/bash vagrant \ + && adduser vagrant sudo \ + && echo -n 'vagrant:vagrant' | chpasswd \ + && sed -i.bkp -e \ + 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' \ + /etc/sudoers \ + && mkdir -p /home/vagrant/.ssh \ + && echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" > /home/vagrant/.ssh/authorized_keys \ + && chown -R vagrant: /home/vagrant/.ssh + +# This makes somethings nicer in wmflabs +RUN groupadd --gid 500 wikidev \ + && adduser vagrant wikidev + +# Cleanup junk +RUN apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/support/docker/README.md b/support/docker/README.md new file mode 100644 index 0000000..272c113 --- /dev/null +++ b/support/docker/README.md @@ -0,0 +1,64 @@ +MediaWiki-Vagrant with Docker +============================= + +The Dockerfile in this directory can be used along with the built-in Docker +provisioner provided with Vagrant 1.6.0+ to run the MediaWiki-Vagrant +application stack inside a Docker container. + +This is not intended to be an example of the best way to use Docker. We are +attempting to use the lxc container managed by Docker as a full virtual +machine replacement rather than as a light weight service container. Once the +image is built and running, MediaWiki-Vagrant will run puppet inside the +container to provision a full stack MediaWiki development environment. + +Recommended versions +-------------------- +Vagrant: 1.6.0+ +Docker: 1.1.0+ + +Usage +----- +* Install Vagrant 1.6.3 +* Install Docker 1.1.0 +* Install MediaWiki-Vagrant +* `./setup.sh` +* `vagrant config nfs_shares no` +* `vagrant up --provider=docker` + +Tips +---- + +Directory permissions +~~~~~~~~~~~~~~~~~~~~~ +Docker will mount your MediaWiki-Vagrant directory using device mapper +virtual block devices. This mounting arrangement provides good performance, +but there is no user mapping facility as is used for NFS or VirtualBox native +mounts. This means that the permissions on your host filesystem must allow the +'vagrant' and 'www-data' users to write to your vagrant and vagrant/logs +directories respectively. The vagrant user inside the Docker-managed container +will have uid 1000 and be a member of gid 1000 and 500. The 1000/1000 uid/gid +is the default for the first user created on an Ubuntu host system and may +serendipitously align with your user on the host system. Gid 500 matches the +"wikidev" group used in Wikimedia Labs. + +Docker as default provisioner +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In addition to the `--provider=docker` method of configuring Vagrant to use +the Docker provider, you can set the VAGRANT_DEFAULT_PROVIDER environment +variable: `export VAGRANT_DEFAULT_PROVIDER=docker` + +Disabling NFS shares +~~~~~~~~~~~~~~~~~~~~ +Vagrant and Docker currently do not play well with each other for using NFS +mounts. When NFS mounting is enabled, Vagrant will report a fatal error during +provisioning: "No host IP was given to the Vagrant core NFS helper. This is +an internal error that should be reported as a bug." This is tracked upstream +with Vagrant as <https://github.com/mitchellh/vagrant/issues/4011>. + +Our Vagrantfile disables creating NFS shares when the Docker provider is in +use even if your host operating system supports NFS. You will need to run +`vagrant config nfs_shares no` to instruct MediaWiki-Vagrant to disable +attempting to use NFS for sharing. If you forget this step, Vagrant will give +you an error message similar to "The synced folder type 'nfs' is reporting as +unusable for your current setup. Please verify you have all the proper +prerequisites for using this shared folder type and try again." -- To view, visit https://gerrit.wikimedia.org/r/157633 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I606e7f8b95f145cb7263c51fcbede25adf28e84e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/vagrant Gerrit-Branch: master Gerrit-Owner: BryanDavis <bda...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits