This repo contains the source for a Kalastack-like Drupal stack using Docker container technology for Drupal. It was built specifically for the Kalabox project and for use with boot2docker-cli.
We have provided a script to help you get started really easily. Right now this startup script has only been tested on MacOSX 1.9+
On your host machine
cd ~
# Get a copy of the kalastack-docker project.
git clone https://github.com/kalamuna/kalastack-docker.git
# Perform Mac installation.
cd kalastack-docker/macosx
./setup.sh
# Connect to the Docker VM.
boot2docker ssh
# Start the container.
docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock -t pirog/kalabox-proxy
docker run --name=test_data pirog/kaladata-docker
docker run -d -t \
-e VIRTUAL_HOST=test.kala \
-e VIRTUAL_PORT=80 -p :22 -p :80 -p :3306 \
--volumes-from="test_data" \
--name="test.kala" \
--hostname="test.kala" \
pirog/kalastack-docker:12.04
In order to access your webserver in your browser you wil want to add an entry into your /etc/hosts file. In order to do this you need to find the docker vm ip address.
Generally you can find this by running ifconfig
inside your docker vm. If you aren't doing anything weird this will usually be something like 1.3.3.7. You may also wish to check your boot2docker config to see if an alternate IP address is being used. You can do that by running boot2docker config
on your host machine. Once you discover this IP address you want to add an entry into the /etc/hosts file on you hosts machine like this:
1.3.3.7 test.kala
You can run docker ps
inside the docker vm to see what ports are doing in your container. This will help you access your services.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c69959c355ae kalastack-docker:12.04 /bin/bash /start.sh 2 seconds ago Up 1 seconds 0.0.0.0:49171->22/tcp, 0.0.0.0:49172->3306/tcp, 0.0.0.0:49173->80/tcp test.kala
In the above example the following service mappings apply
SSH -> 22 -> 49171
HTTP -> 3306 -> 49173
MYSQL -> 3306 -> 49172
Meaning you can connect to these services on your host machine in the following ways:
- HTTP -> Navigate to test.kala in your browser
- SSH -> Run
ssh -p 49171 [email protected]
(the default password should be kala) - MYSQL -> Using your favorite mysql client use host: test.kala, port: 49172, user: root, pass: root.
In this example we assume that you have set your VIRTUAL_HOST for the container to test.kala and you have also set up the appropriate /etc/hosts entry on your host machine.
The easiest way to build a Drupal site is to ssh into your container and navigate to your code by running cd /data/code
. Once you are in here you can build a site from Acquia or Pantheon by
using the Switchboard or by pulling a site down with curl, wget or git.
Most people like to use the text-editor or IDE on their host machine. Kalastack-docker does not provide any file sharing with your host out of the box but you can download a copy of your code onto your host machine and sync it into your container with
With scp
scp -rp -P 49171 ~/mycode/* [email protected]:/data/code/
With rsync over ssh
rsync -ravz -e "ssh -p 49171 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --delete --progress --exclude 'sites/default/files' ~/mycode/* [email protected]:/data/code/
Remember to use the correct SSH port for your container.
For now the easiest way to forward your keys into any kalastack-docker is to add the following lines to your ~/.ssh/config file
Host *.kala
ForwardAgent yes
This assumes that your VIRTUAL_HOST is set to something.kala when you run your container.
As long as you use the setup script above or set your boot2docker host-only network host IP to 1.3.3.1 you can use xdebug out of the box with kalastack-docker. Of course, you will want to follow the normal procedure for setting up debug config for your text editor/IDE. In SublimeText2 the config looks something like this:
{
"folders":
[
{
"path": "/Users/mpirog/mycode"
}
],
"settings":
{
"xdebug":
{
"super_globals": true,
"close_on_stop": true,
"path_mapping":
{
"/data/code/": "/Users/mpirog/mycode/"
},
"port": 9000,
"url": "http://test.kala"
}
}
}
We need to instantiate a docker environment in order to get all the docker magix.
Start by installing boot2docker-cli.
We want users to be able to enter something like "site.local" in their host browsers instead of "192.168.59.103:49173" to access their site. In order to do this we need to set up a reverse proxy that sits in front of all the docker containers to route requests appropriately.
As such you will need to pull down the kalabox-proxy container and run it. For more details on how to install the kalabox-proxy go here
We want users data to be stored outside of the docker container running the webserver so that webservers can be spun down, spun up, upgraded, swapped out, ec. In order to facilitate this users must instantiate a data-only container built specifically for Kalabox. To do so please follow the installation instructions. You will want to give your data container a name you can remember such as 'test_data.' You will need this later when you mount this onto Kalastack
You can either pull the container pre-built from the Docker Index or you can build the container from source.
First SSH into boot2docker by running boot2docker ssh
To pull from the Docker Index simply run
docker pull pirog/kalastack-docker
To build from source run the following
git clone https://github.com/kalamuna/kalastack-docker.git
cd kalastack-docker
docker build --tag="pirog/kalastack-docker" .
VIRTUAL_HOST and VIRTUAL_PORT tell the kalabox-proxy how to route your request. VIRTUAL_HOST should be the address you want to enter into your browser to access your site. VIRTUAL_PORT should almost always be 80. You will want to add an entry into your /etc/hosts file on the host side to facilitate the magic. Please consult "Your VM IP address" below for more details.
docker run -d -t \
-e VIRTUAL_HOST=test.kala \
-e VIRTUAL_PORT=80 -p :22 -p :80 -p :3306 \
--volumes-from="test_data" \
--name="test.kala" \
--hostname="test.kala" \
pirog/kalastack-docker:12.04
The best way to uninstall this whole thing either because you hate it or to try to reinstall is to run the following commands from your host machine
boot2docker stop
boot2docker delete
sudo rm /usr/local/bin/boot2docker
rm -rf ~/.boot2docker
Optionally, and if you are feeling RISKY. You can uninstall VirtualBox with the uninstall.tool that ships with the VB DMG.
Feel free to fork and contribute to this code. :)
- Fork the repo
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Forked from/based on the drupal-docker-nginx project by Ricardo Amaro ([email protected])
GPL v3