Install
We run our code on docker. Docker is a system that allows you to create standardised distributable units called containers. These containers work using a feature of the Linux kernel called cgroups.
In order to use these on Docker containers on OS X we need to start a VM. Thankfully the docker toolbox comes with a handy commandline to make this easier. This tool is called docker-machine and the following commands will help you interact with it.
This command will create a new VM in vitualbox called default
docker-machine create -d virtualbox defaultIt might error if you have already created the VM, you can check if you have by running docker-machine ls and seeing if default appears in that list.
If the VM already exists, and you just need to get it running type
docker-machine start defaultEnvironment variables are a standard way of configuring software. You can see what environment variables a running in the current shell by typing export.
In order to use docker and other tools around docker we need to tell docker about the VM that is running a docker server you have running, via environment variables. Fortunately docker machine has a command build in to make this easier.
eval $(docker-machine env default)It's probably worth breaking down what this command is doing. Firstly $(something) will run something on the commandline and you can use it's output in another command. Secondly eval will take anything that's in a parameter to it, and run it in the shell like you had typed it.
In docker-machine env default this is code to set some environment variables. You can run docker-machine env default without the $() notation to see what this looks like.
To check stuff out make sure git has your SSH keys, if these commands fail that might be why.
To checkout code run git clone $URL, where $URL is the SSH clone url for the repository. These look like this [email protected]:PurpleBooth/stupid-twitter-bot.git or ssh://[email protected]:PurpleBooth/stupid-twitter-bot.git
So the full command would look like this
git clone [email protected]:PurpleBooth/stupid-twitter-bot.gitMove to the directory you checked out the code and type
git pullNow rebuild the container so docker knows about the updated code.
docker-compose builddocker-compose upIt'll tell you what port it's listening on. To find the IP of the server it's running on type
docker-machine ip defaultRun this
docker-machine rm default && docker-machine create -d virtualbox default && eval $(docker-machine env default)
This will
- Delete the virtual machine for docker
- Create a new virtual machine
- and setup your shell again
The following commands will reset any local changes and make your copy look like the one on the server
git checkout master
git fetch
git reset --hard origin/master- Checks out the "master" branch.
- Download changes from the server
- Make your master branch look like the remote master server.