Last active
December 27, 2015 23:59
-
-
Save mgmcintyre/7410482 to your computer and use it in GitHub Desktop.
HHVM on Docker on Vagrant
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
| # DOCKER-VERSION 0.6 | |
| FROM ubuntu:precise | |
| MAINTAINER Mark McIntyre, [email protected] | |
| # Install HHVM | |
| RUN echo deb http://dl.hhvm.com/ubuntu precise main >> /etc/apt/sources.list | |
| RUN echo deb http://archive.ubuntu.com/ubuntu precise main universe >> /etc/apt/sources.list | |
| RUN apt-get update | |
| RUN apt-get install -y --force-yes hhvm | |
| # Install wget and unzip (needed for PHP composer and npm) | |
| RUN apt-get install -y wget unzip | |
| # Install Node.js | |
| RUN apt-get install -y python-software-properties python g++ make | |
| RUN add-apt-repository ppa:chris-lea/node.js | |
| RUN apt-get -y update | |
| RUN apt-get -y install nodejs | |
| # Copy current directory into container | |
| ADD . /var/app | |
| # Stop deps being copied across | |
| RUN rm -rf src/vendor src/node_modules | |
| # Install npm deps | |
| RUN cd /var/app; npm install | |
| # Install composer and PHP deps | |
| RUN apt-get install -y php5 php5-curl | |
| RUN cd /var/app; wget https://getcomposer.org/composer.phar | |
| RUN cd /var/app; php composer.phar install | |
| # Expose port 8080 | |
| EXPOSE 8080 | |
| # Run subsequent commands from application source folder | |
| WORKDIR /var/app | |
| # Entry command is HHVM running as daemon | |
| CMD ["hhvm", "--mode", "server", "--config", "Hiphopfile", "-v", "Log.Level=Verbose", "-v", "Log.NoSilencer=on"] |
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
| Server { | |
| Port = 8080 | |
| SourceRoot = /var/app/web/ | |
| } | |
| VirtualHost { | |
| * { | |
| Pattern = .* | |
| RewriteRules { | |
| * { | |
| pattern = ^(.*)$ | |
| to = index.php | |
| qsa = true | |
| } | |
| } | |
| } | |
| } | |
| StaticFile { | |
| Extensions { | |
| css = text/css | |
| gif = image/gif | |
| jpeg = image/jpeg | |
| jpg = image/jpeg | |
| png = image/png | |
| } | |
| } |
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
| # Build the docker image | |
| sudo docker build -t openxo/pluto . | |
| # Create a running container from the image | |
| PID=$( docker run -d -p 8080:8080 openxo/pluto ) | |
| # View logs for container | |
| docker logs $PID | |
| # Check connectivity | |
| curl -i localhost:8080 |
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| | |
| # Setup VM with custom "docker-ready" image | |
| config.vm.box = "precise64-docker" | |
| config.vm.box_url = "http://nitron-vagrant.s3-website-us-east-1.amazonaws.com/vagrant_ubuntu_12.04.3_amd64_virtualbox.box" | |
| # Forward SSH keys | |
| config.ssh.forward_agent = true | |
| # Build provisioning command, to start we add lxc-docker package | |
| pkg_cmd = "wget -q -O - https://get.docker.io/gpg | apt-key add -; " | |
| pkg_cmd << "echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list; " | |
| pkg_cmd << "apt-get update -qq; apt-get install -q -y --force-yes lxc-docker; " | |
| # Add Ubuntu raring backported kernel (not required with "docker-ready" image) | |
| # pkg_cmd << "apt-get update -qq; apt-get install -q -y linux-image-generic-lts-raring; " | |
| # pkg_cmd << "apt-get install -q -y linux-headers-generic-lts-raring dkms; " | |
| # Add vagrant user to the docker group | |
| pkg_cmd << "usermod -a -G docker vagrant; " | |
| # Activate new kernel (not required with "docker-ready" image) | |
| # pkg_cmd << "shutdown -r +1;" | |
| # Provision the VM | |
| config.vm.provision :shell, :inline => pkg_cmd | |
| # Virtualbox specific machine configuration | |
| config.vm.provider :virtualbox do |vb| | |
| vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] | |
| vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] | |
| vb.customize ["modifyvm", :id, "--memory", 2048] | |
| end | |
| # Forward 8080 because it's cool to use 8080 | |
| config.vm.network :forwarded_port, :host => 8080, :guest => 8080 | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment