Tips for maintaining a local development machine / prod deployment for a go project

blov · · 587 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Looking for some advice from anyone who has experience developing a golang project locally and pushing it to a production environment. </p> <p>I&#39;ve been using go for some time, and understand how it works. It&#39;s fairly easy to just deploy a binary to your server, but I want to make sure I can test the whole environment locally as well (including db&#39;s and other depenencies)</p> <p>Thinking about using <a href="https://ottoproject.io">otto</a> for this. Anyone have some experience setting these environments up? </p> <hr/>**评论:**<br/><br/>tvmaly: <pre><p>I use a Makefile that handles building all the micro services, sass to css etc. For my development, I have a config package that picks the dev stuff is the environment variable DEV is set. Otherwise by default, I run the production version. On osx, the iTerm2 has script support, so I have one script that starts all the micro services. </p></pre>itsamemmario: <pre><p>It depends on what type of server you run. But if you can run docker on your server, you could run docker locally and you&#39;re guaranteed to have the same environment. </p></pre>mjbrender: <pre><p>The catch comes from dependencies. If you want to test the interaction between them, especially db &amp; service, are there recommendations? I&#39;ve seen some arguments for and against mocking. I&#39;m curious to hear more as it relates to @jameoblameo&#39;s. </p></pre>jameoblameo: <pre><p>For now, the database is the only dependency I&#39;m expecting, but I know it will grow. I hate setting these things up all by hand, as it&#39;s fragile and requires a lot of knowledge to set everything up. I think docker or vagrant is probably what I&#39;m looking for.</p></pre>karnd01: <pre><p>I agree with @itsamemmario docker is a good way to go.</p> <p>We use tutum(recently purchased by docker) that hooks into each docker server and have found it invaluable. You can setup what&#39;s called a stack file with all of your dependencies(just like a docker compose file) making setting up an environment a breeze.</p> <p>To take it a step further you can also hook dockerhub into it so when updating your application all you have to do is build your new docker container, lush it to dockerhub and then tell tutum to update your entire app on all servers your service(s) are running on making deploying into production a click of a button.</p> <p>Hope that helps</p></pre>jameoblameo: <pre><p>Yeah, I think docker is exactly what I want. I&#39;m really tempted to use tutum, as it seems like it makes using docker a lot easier. I&#39;ve always been slowed down by the learning curve for docker</p></pre>itsamemmario: <pre><p>I get that, the learning curve was hard for me too. I&#39;ve just gotten into docker and it takes some time to wrap your head around how all dockers interact. What really helped me is the following links: use docker-machine <a href="https://docs.docker.com/machine/" rel="nofollow">https://docs.docker.com/machine/</a> for a VM</p> <p>run this docker <a href="https://hub.docker.com/_/golang/" rel="nofollow">https://hub.docker.com/_/golang/</a> with -v &#34;/path/to/project/on/local/machine:/path/to/project/on/docker/vm&#34; this creates a docker vm with go installed and allows you to compile and run your project on the vm.</p> <p>then read this on how to connect this to your localhost <a href="https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/" rel="nofollow">https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/</a> basicly -P -p is your friend.</p> <p>my final command looks like this docker run -P --name sharedVolume --link mongo -v /Users/itsamemario/Go/src:/go/src -it my-golang-app</p></pre>jameoblameo: <pre><p>this is super helpful. Thank you. I&#39;ll definitely follow up with a post on this sub with my experience with docker &amp; go!</p></pre>

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

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