-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatom.xml
More file actions
176 lines (135 loc) · 15.4 KB
/
atom.xml
File metadata and controls
176 lines (135 loc) · 15.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[Adventures in Development]]></title>
<link href="http://Ryan-K.github.io/atom.xml" rel="self"/>
<link href="http://Ryan-K.github.io/"/>
<updated>2013-06-24T17:57:35-05:00</updated>
<id>http://Ryan-K.github.io/</id>
<author>
<name><![CDATA[Ryan Kolak]]></name>
<email><![CDATA[ryan.kolak+blogrss@gmail.com]]></email>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[First Steps]]></title>
<link href="http://Ryan-K.github.io/blog/2013/06/20/first-steps/"/>
<updated>2013-06-20T15:05:00-05:00</updated>
<id>http://Ryan-K.github.io/blog/2013/06/20/first-steps</id>
<content type="html"><![CDATA[<p>Recently, I described <a href="http://ryan-k.github.io/blog/2013/05/29/virtually-the-only-way-to-go/">why development is best handled in a virtual environment</a>. I often hear complaints that its too difficult to setup and get running and that time spent learning something new takes away from valuable development time. So, this post will walk through the steps to go from nothing to installing all the necessary software to getting your first VM up and running.</p>
<!-- more -->
<h2>Installing VirtualBox and Vagrant</h2>
<p>The very first thing to do is to grab both <a href="https://www.virtualbox.org/wiki/Downloads">VirtualBox</a> and <a href="http://downloads.vagrantup.com">Vagrant</a> and install them. They both have installers and should install like any other software on your platform of choice. Older versions of the software can have issues, so running the latest of both is pretty important for the most painless experience possible. Also, if you’re working on a team with other developers, its often useful to ensure that everyone is working with the same versions of the software as compatibility issue can arise.</p>
<p>In the past, there was an alternative way to install Vagrant via a ruby gem. Thankfully, that’s been eliminated as it has caused more confusion and conflicts and requires managing more of the ruby environment on your local workstation. That’s something that I never want to have to deal with, ever.</p>
<p>Once those are installed, you’ll find that there’s a GUI interface for VirtualBox that will allow you to manage your VMs. The only time you’ll need to go into there is if things get into a bad state and Vagrant gets very confused. Hopefully, that never happens but if you ever find yourself in that situation, firing up VirtualBox and powering down the VM should reset things. The main benefit of Vagrant is not having to deal with VirtualBox.</p>
<h2>Starting your first VM</h2>
<p>To get started with your first Virtual Machine, all that you need to do is initialize a virtual machine, start it up and then you can connect to it. In Vagrant, this is done with a few simple commands which should be run from a empty directory where you’ll be doing your work from.</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$ vagrant init precise32 http://files.vagrantup.com/precise32.box
</span><span class='line'>A `Vagrantfile` has been placed in this directory. You are now
</span><span class='line'>ready to `vagrant up` your first virtual environment! Please read
</span><span class='line'>the comments in the Vagrantfile as well as documentation on
</span><span class='line'>`vagrantup.com` for more information on using Vagrant.
</span><span class='line'>$ vagrant up
</span><span class='line'>[default] Box 'precise32' was not found. Fetching box from specified URL for
</span><span class='line'>the provider 'virtualbox'. Note that if the URL does not have
</span><span class='line'>a box for this provider, you should interrupt Vagrant now and add
</span><span class='line'>the box yourself. Otherwise Vagrant will attempt to download the
</span><span class='line'>full box prior to discovering this error.
</span><span class='line'>Downloading or copying the box...
</span><span class='line'>Extracting box...
</span><span class='line'>Successfully added box 'precise32' with provider 'virtualbox'!
</span><span class='line'>[default] Importing base box 'precise32'...
</span><span class='line'>[default] Matching MAC address for NAT networking...
</span><span class='line'>[default] Setting the name of the VM...
</span><span class='line'>[default] Clearing any previously set forwarded ports...
</span><span class='line'>[default] Fixed port collision for 22 => 2222. Now on port 2200.
</span><span class='line'>[default] Creating shared folders metadata...
</span><span class='line'>[default] Clearing any previously set network interfaces...
</span><span class='line'>[default] Preparing network interfaces based on configuration...
</span><span class='line'>[default] Forwarding ports...
</span><span class='line'>[default] -- 22 => 2200 (adapter 1)
</span><span class='line'>[default] Booting VM...
</span><span class='line'>[default] Waiting for VM to boot. This can take a few minutes.
</span><span class='line'>[default] VM booted and ready for use!
</span><span class='line'>[default] Configuring and enabling network interfaces...
</span><span class='line'>[default] Mounting shared folders...
</span><span class='line'>[default] -- /vagrant
</span><span class='line'>$ vagrant ssh</span></code></pre></td></tr></table></div></figure>
<p>The first line initializes a new VM, names it “precise32” and links it to the base box at that URL. There are many options for what to use for a base box. Precise is a recent LTS release of Ubuntu and is a decent choice. You can find many others at <a href="http://www.vagrantbox.es/">http://www.vagrantbox.es/</a> or <a href="http://cloud-images.ubuntu.com/vagrant">http://cloud-images.ubuntu.com/vagrant</a> that you can substitute in place of the URL in the init command. All that really happens at this point is the creation of a “Vagrantfile” in the current directory which specifies everything about how your VM is configured. Feel free to look through it as common options are included and well documented.</p>
<p>The up command is what actually starts up your VM. Since this is the first time running the VM, it will download the VM image. Depending on your internet connection, this may take quite sometime. Once this completes, the process of actually starting the VM begins and vagrant works its magic. Primarily, this sets up network devices and mounts a shared directory. By default, this enables access of this current folder at “/vagrant” inside the virtual machine. This is how you’ll be able to edit files locally on your desktop in your favorite editor, and inside the VM you’ll see the changes reflected.</p>
<p>Finally, the ssh command will connect you to your brand new ubuntu VM. From here, you can install whatever software you’ll need to run your server.</p>
<h2>Configuring your VM</h2>
<p>The only change to the defaults I recommend when you’re just starting, is to enable bridge networking by uncommenting this line in the auto-generated Vagrantfile by removing the # from the third line:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'> # Create a private network, which allows host-only access to the machine
</span><span class='line'> # using a specific IP.
</span><span class='line'> config.vm.network :private_network, ip: "192.168.33.10"</span></code></pre></td></tr></table></div></figure>
<p>What this does is enable access to your VM at the specified IP address. That’s 192.168.33.10 by default, so if you are running multiple VMs, you’ll also want to give each one a unique IP address. This will allow you to connect to any services running on that box via that IP address. The other options are to forward ports on your local machine to the VM. The commented out example in the config would forward port 8080 on your local machine (the host) to port 80 on your VM (the guest). This would allow a webserver running in your VM to be accessed at <a href="http://localhost:8080/">http://localhost:8080/</a> in a web browser on your machine. The other option is to enable public networking, which extends the visibility of your VM outside of your machine. Generally, you won’t need to do that.</p>
<h2>Other Vagrant Commands</h2>
<p>Finally, there’s a few other vagrant commands that are very useful. We have already seen vagrant init, vagrant up and vagrant ssh. When you are finished with this VM and want to release the resources its using, run vagrant suspend or vagrant halt. I prefer vagrant suspend as it preserves the state of the machine, rather then completely powering it off.</p>
<p>Remember that you’ll have to exit your shell or run those commands from another terminal in the same directory as the vagrant commands do not work from within the VM. Vagrant is a tool that runs on your local machine and manages the VMs via VirtualBox. Inside the VM is a clean server environment that knows nothing about vagrant or that its running on your workstation.</p>
<p>Vagrant reload will reboot the VM, which is useful to allow changes in the Vagrantfile to take effect. Finally, vagrant destroy will remove this VM and the storage associated with it. Any changes you made to the system will be lost, but a vagrant up will recreate the VM and give you a clean machine again.</p>
<p>That’s all there really is to it! In the next post, I’ll introduce my favorite web framework, <a href="http://flask.pocoo.org/">Flask</a>, and get a very simple web service running within a new vagrant box.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Virtually the only way to go]]></title>
<link href="http://Ryan-K.github.io/blog/2013/05/29/virtually-the-only-way-to-go/"/>
<updated>2013-05-29T12:37:00-05:00</updated>
<id>http://Ryan-K.github.io/blog/2013/05/29/virtually-the-only-way-to-go</id>
<content type="html"><![CDATA[<p>Many developers put a lot of work into getting their projects to run locally on their own machines. While running natively locally may seem easier initially, I really feel like you’re setting yourself up for failure.</p>
<p>If you’re a Linux user, you’re not as likely to encounter some issues, but that likely will just give you a false sense of security. Mac users are slightly worse off since they aren’t too far removed from Unix, but there are some definite pitfalls that will trip you up. And Windows developers, I honestly have no idea how you manage to jump through as many hoops as you do to get everything running at all.</p>
<p>Most of this doesn’t apply if you’re doing mobile app development (Android or iOS), building desktop apps, or working within Microsoft’s development environment. By all means, develop as close to your target environment as possible.</p>
<p>And that’s exactly the point. Your personal machine is not a server. The absolute easiest way to mimic your target environment is to run a virtual machine on your desktop. With the advent of <a href="http://aws.amazon.com">Amazon Web Services (AWS)</a>, there’s really no reason to manage your own hardware. AWS allows you to run a server from an image, and a wise developer will use that exact same image locally.</p>
<p>Sure, it takes a bit more resources locally, but running a virtual machine completely isolates changes to your local system from your development environment, allows you to share an exact environment with other developers, and if something goes wrong, you can always rebuild a new box with ease.</p>
<p>Sounds like a daunting task? It’s actually quite easy to get started… and its completely free! <a href="http://www.virtualbox.org">VirtualBox</a> is free software, provided by Oracle (by way of their Sun acquisition, and they haven’t managed to ruin this at all). It provides the layer that reserves resources on your local machine (the host) and provides it to your virtual machine (the guest).</p>
<p>You could use VirtualBox directly, but there’s a few rough spots. I highly recommend another layer on top of VirtualBox that will limit your interactions with VirtualBox to installing it, and applying updates. That layer is <a href="http://www.vagrantup.com">Vagrant</a> which has become an indispensable tool and is widely used.</p>
<p>The combination of VirtualBox and Vagrant is a powerful one. You can run it on Linux, Macs or Windows with ease. Give yourself a couple hours to install and get familiar with them and you’ll never look back. It truly is a paradigm shift and you may wonder how you ever got anything done before.</p>
<p>In future posts, I’ll outline installing both and getting a simple application running.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Rebooting Dev Blogging]]></title>
<link href="http://Ryan-K.github.io/blog/2013/05/28/rebooting-dev-blogging/"/>
<updated>2013-05-28T15:10:00-05:00</updated>
<id>http://Ryan-K.github.io/blog/2013/05/28/rebooting-dev-blogging</id>
<content type="html"><![CDATA[<p>Development has come a long way in the last 15 years. The scale of things that can be accomplished is amazing. Even more impressive is the rate at which things can be produced.</p>
<p>There’s a lot of great resources on the internet, but many of those conflict or are outdated. My goal of this blog is to provide a resource for developers while also tracking progress of some of my side projects.</p>
<p>Much of the work I’ve done over the last couple years, I haven’t been able to talk about. There’s many useful techniques that we used that are very general and could be applied to pretty much any situation to make a developer’s life much easier.</p>
<p>Ideally, this will be helpful for other developers, but if I’m happy if it becomes a resource for myself.</p>
<p>I’m also hosting this via <a href="https://github.com/Ryan-K/ryan-k.github.com">a public repo</a> on GitHub pages and welcome any comments or contributions.</p>
]]></content>
</entry>
</feed>