Help learning the deployment process

blov · · 1001 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>So, I&#39;ve been independently learning web development for the last 18 months or so, and I finally feel like I&#39;m ready to deploy to the real live internet. No localhost. And I&#39;m baffled, scared and lost.</p> <p>I&#39;m pretty happy with my go skills, my javascript is passable to pull an app together, and I can kind of cobble enough css together to get stuff to sit where I want it to. I heard that digital ocean was good for your first app. It&#39;s cheap, and it&#39;s easy. Easy? Wat?</p> <p>I feel like a fish on a bicycle. What do I even call this field? System admin? Dev ops? What does &#34;spinning up an instance&#34; mean? What&#39;s a container? I actually don&#39;t want answer to those questions. Can someone please point me in the direction of a 101 article. Like for complete and utter n00bs. Not, so you know how you used to do it this way for LAMP. I mean, I never learned that either. I don&#39;t know anything about nginx or apache.</p> <p>Am I absolutely mental for thinking I could actually deploy an app one day? I don&#39;t want to use an expensive solution like heroku or app engine.</p> <p>Yours despondently, Dave.</p> <hr/>**评论:**<br/><br/>quiI: <pre><p>Dont try to learn too much at once because it can send you down huge rabbit holes. </p> <p>For now, start with deploying your app on something like Heroku</p> <ul> <li><p>It&#39;s free</p></li> <li><p>It&#39;s relatively easy to start with</p></li> <li><p>You will learn things about configuration</p></li> <li><p>And how important logging is. </p></li> </ul> <p>Start off by doing it ad-hocly from your computer but once you get a handle on it think about making it so your website is redeployed on every commit (that passes all your tests). For that you could look at something like Travis CI</p></pre>SocalNick: <pre><p>This. </p> <p>You can also checkout various Cloud Foundry based PaaS like Pivotal Web Services and IBM Bluemix, all of these support Golang apps. </p></pre>earthboundkid: <pre><p>It sort of depends on your time horizons. Learning how to run a Linux box is a useful life skill, but it takes a long time. If you are in school, may as well spend the time learning. If you have a job, may as well do the fastest thing to get a real live result. </p></pre>headzoo: <pre><p>Running your app on a server is exactly the same as running it on your home computer. The only difference is now you&#39;re running it on someone else&#39;s computer.</p> <p>What operating system have you been using while developing the app? Do you have basic command line knowledge? The direction I would point you in depends on what you already know.</p></pre>Vincinho: <pre><p>I&#39;ve been developing both at work on windows 7 (don&#39;t tell my boss) and at home on mac. Got a private repo on bitbucket that I use to synchronise between the two, but I only do SQL at work just to keep things simple.</p> <p>I feel like my command line knowledge is ok. It&#39;s now my primary mode of file and folder interaction, but it&#39;s mostly windows powershell, so I understand that a linux bash shell is something different, something more powerful. Right now I don&#39;t have access to a linux machine. I&#39;ve been thinking of getting a cheap refurb laptop and throwing ubuntu on it, just to increase my familiarity. Is that something you would recommend? </p></pre>headzoo: <pre><p>I would look into running VirtualBox on your Mac, and run Ubuntu as a virtual machine. There&#39;s lots of guides out there to get you up and running. (<a href="http://www.simplehelp.net/2015/06/09/how-to-install-ubuntu-on-your-mac/" rel="nofollow">Example</a>) A laptop is just going to end up sitting on your desk and collecting dust. With VirtualBox you can run Ubuntu in a window, and bring it up at any time.</p> <p>You don&#39;t need to know much though. As long as you can change directories and run <code>go build</code> then you should be fine. I think the only new thing you have to learn is how to use SSH. <a href="http://www.chiark.greenend.org.uk/%7Esgtatham/putty/" rel="nofollow">PuTTY</a> is by far and away the most popular SSH client for Windows. I&#39;m not sure about Mac clients, but I&#39;m sure you can find them with a bit of googling.</p> <p>I see DigitalOcean has $5 a month Linux accounts. You may want to start there for web hosting. I&#39;ve never used them myself, but I hear they have good documentation. With DigitalOcean, you may not even have to learn all this SSH stuff yet. I&#39;m sure they will give you instructions for connecting to your web server.</p> <p>You already have experience moving files back and forth from your work and home computer, and things really aren&#39;t much different once you toss a web server into the mix. It&#39;s nothing more than your 3rd computer. And it really is just another computer. The same way that you&#39;re running your Go app on your home computer is how you&#39;re going to run it on your web server.</p> <p>So, with the work you&#39;re doing, deploying an app is actually going to be really simple.</p> <ul> <li>Commit your work to bitbucket from your work/home computer.</li> <li>Log into your web server using SSH. (or however DigitalOcean does it)</li> <li>From the web server pull your changes from bitbucket.</li> <li>Compile the app using <code>go build</code>.</li> <li>Run the app!</li> </ul> <p>You don&#39;t need to concern yourself yet with things like LAMP and Nginx. Those five steps are really all you need to get your app out on the internet, and it&#39;s the basic deployment process used by most developers for the first year or two. Get comfortable with this fundamental deployment process before you start playing with more complicated toys.</p> <p>The hardest part for you might be installing Go and Bitbucket on your webserver, but you can always post another question here about that once you have DigitalOcean figured out.</p> <p>Edit: Looks like DigitalOcean has instructions for installing Go on your web server. <a href="https://www.digitalocean.com/community/tutorials/how-to-install-go-1-5-3-on-ubuntu-14-04" rel="nofollow">https://www.digitalocean.com/community/tutorials/how-to-install-go-1-5-3-on-ubuntu-14-04</a></p></pre>Vincinho: <pre><p>Thanks a lot for the breakdown. Definitely feels manageable now. Is setting up a production MySQL/MariaDB database also pretty much the same as setting it up locally? I&#39;m just worried about creating gaping security holes if I do it wrong. </p></pre>headzoo: <pre><p>Yup. It&#39;s pretty easy. From the command line (after you SSH into the server) you simply type <code>sudo apt-get install mysql-server-5.6 mysql-client-5.6</code> and that&#39;s it. It will ask you for a root password during the installation process, but there&#39;s nothing else to it.</p> <p>Just keep in mind that you&#39;re going to outgrow the $5 a month hosting package when you start installing a bunch of services (like MySQL) on the web server. But that&#39;s probably not something you need to worry about while tinkering around with your web app. If you ever build something that might get some actual traffic, you should look into the $20 hosting package.</p></pre>icholy: <pre><p>Bash is different, idk about more powerful though. </p></pre>qxclpxzk: <pre><p>Learn how to use ssh, scp, and then rsync. Then make a script to automate your deployment with rsync and ssh. Use Cygwin and/or a Linux VM for this if you&#39;re on Windows. You should be using key-based authentication, and password login should be disabled on your server.</p> <p>This lets you do something like:</p> <pre><code>rsync -avz localdirectory user@website.com:/home/user/directory ssh user@website.com &#39;go build /home/user/directory &amp;&amp; killall appname &amp;&amp; /home/user/directory/appname&#39; </code></pre> <p>I prefer to keep my server applications running in a tmux window, so I close and restart them manually in my interactive ssh terminal. Note that running a single command using ssh (not in an interactive shell) may have a different PATH setup than your average interactive session. That can be configured in your server&#39;s .bashrc file.</p></pre>Vincinho: <pre><p>I really appreciate the info, but this post very much sums up everything that has overwhelmed me so far. What is ssh, what is scp, what is rsync, what is tmux? Are these the first things I should learn before I go any further?</p></pre>qxclpxzk: <pre><ul> <li><a href="https://www.youtube.com/watch?v=0IwZTt2P2zk" rel="nofollow">SSH is the Secure Shell. You use it to log in to and work on remote servers.</a></li> <li><a href="https://www.youtube.com/watch?v=g6tloRJL75w" rel="nofollow">SCP is Secure Copy. It copies files over the SSH protocol.</a></li> <li><a href="https://youtu.be/g6tloRJL75w?t=17m34s" rel="nofollow">Rsync stands for Remote Sync. It&#39;s like scp, but way faster. It synchronizes two directories and only copies what has changed.</a></li> <li><a href="https://www.youtube.com/watch?v=wKEGA8oEWXw" rel="nofollow">Tmux is the terminal multiplexer. It lets you keep applications open inside a terminal that you can reattach to later.</a></li> </ul> <p>You should set up a Linux environment like a VM or Cygwin and learn the basics of each of these tools, starting with SSH.</p></pre>Vincinho: <pre><p>Awesome. Your post just went from shit-my-pants intimidating to you-can-do-it-buddy reassuring. Really appreciate it. </p></pre>icholy: <pre><p>You don&#39;t need rsync or tmux to start. </p></pre>thepciet: <pre><blockquote> <p>man scp</p> <p>man ssh</p> <p>man rsync</p> </blockquote></pre>journalctl: <pre><blockquote> <p>I prefer to keep my server applications running in a tmux window</p> </blockquote> <p>Please stop recommending this. Use <code>/sbin/init</code>.</p></pre>icholy: <pre><p>I prefer supervisord</p></pre>journalctl: <pre><p>May I ask why? Upstart and systemd seem to cover the common use case (starting on boot, restarting on failure) and it&#39;s one less service to run.</p></pre>icholy: <pre><p>My production machines run slackware, so no upstart or systemd. SupervisorD has a nicer interface than init.</p></pre>gdey: <pre><p>Okay, just a couple of questions.</p> <p>Have you gotten a website to work locally? Are you using net/http or a framework? I assume this is in go.</p> <p>Just skimming through this site, looks like it goes through how to get a simple net/http app running on digital ocean</p> <p><a href="http://www.mircozeiss.com/host-your-golang-app-on-digital-ocean" rel="nofollow">http://www.mircozeiss.com/host-your-golang-app-on-digital-ocean</a></p></pre>Vincinho: <pre><p>Yeah, my website works locally. It just uses the net/http package. It does however have a MySQL database.</p> <p>A quick skim through that site for me looks pretty daunting, but I guess that&#39;s just because there&#39;s a whole bunch of new terminology. I guess it&#39;s just like beginning programming, learn by doing. It just seems like the stakes a raised a little bit with managing a server. </p> <p>Thanks a lot for the resource. I really appreciate it. </p></pre>koalefant: <pre><p>If you spin up a server on Digital Ocean they actually email you a list of steps to do to get it up and and running. This includes things like setting up SSH, iptables, nginx or a database etc.</p> <p>I actually learnt a great deal from those tutorials.</p> <p>But apart from that just have a grasp of general bash commands like cd (change directory), ls (lists files in directory) mkdir (make directory), chmod (change file permissions) etc.</p> <p>Then as suggested above create a makefile to automate deployment so you don&#39;t have to memorise all the flags for scp and rsync etc</p> <p>You just gotta do it a step at a time but if you follow the tutorials it becomes much clearer over time.</p></pre>Vincinho: <pre><p>Cool, thanks. I set up an account yesterday. Didn&#39;t have my credit card handy, so I&#39;ll try spinning up a droplet later today hopefully and just go step by step and try not to get bogged down.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1001 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传