This document is meant to be a getting started guide to Vagrant. It will walk you through getting a development environment setup on your computer. Complete documentation about Vagrant can be found on Vagrant's Website
When I talk about the Terminal throughout this document, I mean one of the following things:
- If you're on Mac, I mean Terminal. You can find the Terminal application in the Utilities folder (or just type 'Terminal' into Spotlight).
- If you're using Linux, search for 'terminal' using whatever tool your distribution comes with. Some common ones are 'gnome-terminal', 'xfce-terminal', 'rxvt', and 'xterm'.
- If you're on Windows, the terminal is Git Bash. You should install it along with Git (outlined below).
There are a few pieces of software that need to be installed prior to getting a development environment setup.
Visit https://www.virtualbox.org/ to download the version of VirtualBox that works on your computer. It's an automatic installer, so hopefully nothing goes wrong.
Visit http://vagrantup.com/ to download and install the version of Vagrant for your system. Once again it is a simple automatic installer.
Visit http://git-scm.com/ and download the version of Git for your system. There is an automated installer for this as well. The default options should work well enough.
If you are using Windows, make sure you include Git Bash in your install!
If you are new to programming or Git: I would strongly suggest that you download GitHub Desktop. It is pretty friendly, and comes with a tutorial.
Vagrant is a command line tool, and thus it helps to be familiar with Bash commands. If you're new to Bash don't worry, it isn't that bad, and it's a very useful thing to have a working knowledge of. Here is a good guide: The Command Line Crash Course.
GitHub Desktop
- It will be necessary for you to fork this repository before cloning it. To do so, simply hit the 'Fork' link in the top-right of this page.
- Open GitHub Desktop, if you do not already have it open.
- Click to '+' icon in the top-left of the GitHub Desktop window.
- In the panel that appears, click the 'Clone' link in the panel that appears.
- In the text box in the panel, type 'cwdg-vagrant'.
- Click the 'Clone cwdg-vagrant' button.
- Select where on your computer you want to have the CWDG vagrant. It doesn't matter where you put it, just remember where it is.
Command Line
- Pat yourself on the back for being cool.
cd
into the directory where you would like to put this repository.- If you have your SSH keys uploaded to GitHub, run
git clone [email protected]:CWDG/cwdg-vagrant
. Otherwise, rungit clone https://github.com/CWDG/cwdg-vagrant
. If you do not know whether you have your ssh keys uploaded to GitHub, you probably do not.
Using the terminal of your choice (Git Bash is a valid option for Windows), use cd
to go where you cloned this repo. If you are new to the shell, try using ls
and pwd
to get your bearings. Using cd ..
will take you up to the parent directory of the one you are in.
Once you are in the place where you cloned this repo, run:
vagrant up
Once the vagrant up
command finishes, it is time to ssh into your virtual machine. Simply type:
vagrant ssh
And you will connect to your virtual machine. You now have access to a Linux machine that is preconfigured with our Ruby on Rails development environment setup. When you're done working in your VM, type exit
to close the ssh connection and return to your computer's terminal.
In your "home" directory, there will be a directory called "workspace". This is where we will be doing our exercises. This directory is linked from inside the VM to the "workspace" folder inside this cloned repository on your computer. This way, you can use Atom or Sublime Text to edit files within the "workspace" folder natively on your computer, and your changes will be present inside of the Vagrant VM.
The workflow for doing exercises will be:
- Fork the exercise repository on GitHub
- Clone the repository into the "workspace" directory inside of your clone of this repository using your preferred method (GitHub Desktop or just
git
). - ssh into the VM using
vagrant ssh
. - Go to the "workspace" directory inside the VM using
cd workspace
. - Make your changes locally on your computer. Test them inside the VM.
- Commit your changes with Git.
- Open a pull-request against the exercise repo on GitHub.
- Celebrate and wait for a peer review!
When you are done using the VM, make sure to shut it down by running:
vagrant halt
Make sure you do this inside your clone of this repository.
You should occasionally update your Vagrant box. You can do this by running ./scipt/update
in your clone of this repository. I am unsure this works in Git Bash.