Looking for Recommendations - Deploy Golang Code using Docker to AWS

polaris · · 729 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I just starting working with Docker. Is this a good way to deploy Golang applications from GitHub to a server (link at bottom)? The reason I&#39;m asking is because I usually write my Golang applications on Windows and then have to go through a lengthy process (minutes) to get to code to a Linux box in order to do UAT testing there. Eventually, I&#39;d like to incorporate the suggestions from CodeShip article about CI and Delivery with Docker.</p> <p>I&#39;m looking for a simple and reliable way to deploy my Golang applications to an AWS Linux machine and I want to make sure I&#39;m not making things more complicated than they actually are. Thanks!!</p> <p>GitHub: <a href="https://github.com/josephspurrier/godockertest">https://github.com/josephspurrier/godockertest</a></p> <hr/>**评论:**<br/><br/>bkeroack: <pre><p>You don&#39;t need any kind of external service other than CI, and not even that if you&#39;re just testing it out.</p> <ol> <li>Write your Dockerfile and put it in the root of your repo. There is an <a href="https://hub.docker.com/_/golang/">official image</a> that makes this really simple (5 lines in your Dockerfile). I personally don&#39;t like the onbuild variant--I use vanilla golang:1.5, then add my code &#34;ADD . /go/src/foo/bar&#34; and build it &#34;RUN go-wrapper download &amp;&amp; go-wrapper install&#34;.</li> <li><p>Build the container image via any CI system. I like quay.io because it automates the building and registry, but with any CI it can be as simple as: <code>$ docker build -t mytag . &amp;&amp; docker push mytag #requires Docker Hub account</code></p></li> <li><p>Pull and run the container on your AWS server: <code>$ docker pull mytag &amp;&amp; docker run -d -p 80:80 --name service mytag /go/bin/myapp</code></p></li> </ol> <p>That&#39;s it!</p></pre>hey_bros_its_gerry: <pre><p>This is my solution as well, using Google&#39;s Cloud Registry <a href="http://gcr.io" rel="nofollow">http://gcr.io</a> instead of Docker Hub</p></pre>motojo: <pre><p>Awesome, I love these solutions. I&#39;m going to test out golang:alpine and for now, I&#39;ll wrap my commands in a bash script and then save my docker images in the Google Cloud Registry. Thanks guys!</p></pre>captncraig: <pre><p>You should look into elastic beanstalk. It is a sort of batteries-included easy mode for aws stuff. Go and docker is pretty easy to get running.</p></pre>motojo: <pre><p>Cool, looks pretty simple. I like that it will put nginx infront.</p></pre>Mteigers: <pre><p>We use Docker + Go two ways on AWS:</p> <ol> <li><p>CodePipeline + CodeDeploy: on a push to GitHub we have Jenkins rebuild our container with a tag of the Jenkins build and then push that up. CodePipeline handles sending the code to Jenkins and then kicks off the CodeDeploy. At the CodeDeploy level instead of copying code to the server we leverage the hooks to stop our containers, pull the next version, and restart our application. </p></li> <li><p>Amazon ECS: we now have several systems using ECS. Following the same idea a git push goes directly to Jenkins which rebuilds the container, pushes the container, then updates the ECS Task Definition, then updates the ECS service which then deploys our container using a Blue + Green deployment. </p></li> </ol></pre>motojo: <pre><p>Ah, I didn&#39;t know about ECS Task Definition, I&#39;ll look into it. Thanks!</p></pre>loki77: <pre><p>You could also checkout Empire- it&#39;s an API that sits in front of ECS to make all the processes a bit simpler. <a href="https://github.com/remind101/empire" rel="nofollow">https://github.com/remind101/empire</a></p></pre>mbanzon: <pre><p>It really depends on what kind of application you have. If it is somewhat simple (if it can be build with &#34;go build&#34;) you could have a service like Codeship build a binary via a GitHub webhook and then just scp it to the server and run a command to stop the currently running process and start the new one.</p></pre>motojo: <pre><p>Yeah, my web application will have additional files so I figured Docker was a good way to keep everything together.</p></pre>

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

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