Deploying Golang

xuanbao · · 510 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi there,</p> <p>I&#39;ve written a web application in Go, but I am unsure what is the best approach to deploy it. I intend on deploying to a cloud based service such as AWS or Digital Ocean. My application itself is stateless and connects to a Postgres database. It was designed so the application nodes could be scaled horizontally, and the database vertically until such a time if/when sharding is required. </p> <p>My go application and database both have their own docker containers. I&#39;m just unsure on how to deploy them nicely. I see all these fancy tutorials for provisioning a dead simple applications to cloud servers, but they don&#39;t have any detail how how they progress from that point. </p> <p>Say I deploy 3x app nodes and 1xdatabase. If a week later I want to update my application, my app nodes can just be deleted and swapped with new instances. My database on the other hand contains data that must be preserved. Most of these tutorials seem to gloss over what happens to the database at this point. Particularly if the database structure has changed slightly and I need to migrate. I&#39;ve been playing around with docker machine and docker compose, which seem nice, but also seem slightly restricted in what they can do with complex deployment.</p> <p>I&#39;m not sure if this is the correct subreddit, because I realize it&#39;s not 100% Go. If not, could you please tell me where the best place to ask is?</p> <p>Any suggestions?</p> <p>Thanks.</p> <hr/>**评论:**<br/><br/>lacion: <pre><p>given than one of the strongest points of go is single binary, i would build the binary in CI (Travis, Circle, Jenkins) and once the build succeed push it to some kind of artifact store (bintree, artifactory s3)</p> <p>them you can deploy easily with ansible/salt/chef or what every and that way you only need to copy your binary and template your configs.</p> <p>that way you gain ultimate freedom on deployment and will not need to marry any specific platform.</p></pre>ptman: <pre><ul> <li>I find it easier to run postgres containers with persistent volumes for storing the data. You need to take care when upgrading from e.g. postgres 9.4 to 9.5, though</li> <li>Your application needs to be able to handle the migration, or you need to do it by hand (not preferable). With postgres and its excellent flexibility it&#39;s also possible to e.g. create versioned schemas that use e.g. views or functions to offer the same data to different versions of the application</li> </ul></pre>NicholasTheGr8t: <pre><p>If you&#39;re using Godeps or GB for vendoring, you can deploy this relatively easily on Heroku. <a href="https://devcenter.heroku.com/articles/getting-started-with-go#introduction" rel="nofollow">https://devcenter.heroku.com/articles/getting-started-with-go#introduction</a></p></pre>zserge: <pre><p>Or on Dokku running inside a 5$ DigitalOcean droplet. Fully compatible with Heroku build packs.</p></pre>karnd01: <pre><p>I can highly recommend tutm <a href="https://www.tutum.co/" rel="nofollow">https://www.tutum.co/</a> to help in managing you environment.. it helps abstract away allot of the management work and when integrated into dockerhub for your images provides a very easily managed environment..even accross providers.</p></pre>Fwippy: <pre><p>My gut says you should mount an EFS share as a volume inside the DB container - here&#39;s a <a href="https://aws.amazon.com/blogs/compute/using-amazon-efs-to-persist-data-from-amazon-ecs-containers/" rel="nofollow">guide to doing that</a></p></pre>Justinsaccount: <pre><p>Or just use RDS.</p> <p><a href="https://aws.amazon.com/rds/" rel="nofollow">https://aws.amazon.com/rds/</a></p></pre>

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

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