AWS Elastic Beanstalk应用程序和静态资源部署隔离

huangapple go评论89阅读模式
英文:

AWS Elastic Beanstalk Application and Static Assets Deployment Isolation

问题

我有一个处理路由和RESTful API的应用程序代码,使用golang编写,但是我的客户端代码都是用Vue编写的,我希望将这两者隔离开来,这样在修改一个div时就不必部署整个容器。我考虑将所有静态内容托管在CDN上,但是动态引用哈希值有点困难。

我考虑过从S3前端动态获取内容,但即使使用缓存,这可能也会很昂贵。有没有办法将AWS EB git钩子和拉取操作与适当的Docker容器关联起来?

英文:

I have my application code which handles routing and the restful API, written in golang, however all my client side code is written in Vue and I wanted to isolate the two so I did not have to deploy the entire container when I modified a div. I looked into hosting all my static content on a CDN however its a bit hard to dynamically reference the hash

<!DOCTYPE html>
<html>

<head>
  <meta charset=utf-8>
  <title>Test</title>
  <link href=/static/css/app.c6d9c9fc12c1dbaee77703a4dd731a8b.css rel=stylesheet>
</head>

<body>
  <div id=app>
  </div>
  <script type=text/javascript src=/static/js/manifest.c40d98f512f01d44a02f.js>

  </script>
  <script type=text/javascript src=/static/js/vendor.94202f7575960a15f341.js>

  </script>
  <script type=text/javascript src=/static/js/app.7a2bba27be158abd2c91.js>

  </script>
</body>

</html>

I have thought of dynamically pulling from S3 front end, however, this could be costly even if I cache it. Is there any way to tie AWS EB git hooks and pulling onto the appropriate docker containers?

答案1

得分: 1

我最终采用的方法是使用CloudFront,将我的www.website.com指向CloudFront站点,设置了SSL,所以现在我的前端部署基本上只需推送到S3。

然后,我在弹性Beanstalk上运行我的API,并设置了SSL,所以现在如果我想访问API,我将任何api.website.com转发到服务器的名称。我还设置了SSL,所以所有内容都是加密的。

我还按以下方式对我的API进行版本控制:
api.website.com/v1/<endpoint>
现在部署非常轻松!

英文:

What I ended up doing was using cloudfront, pointing my www.website.com to the cloudfront site, set up ssl so now my front end deployment is just pushing to s3 essentially.

Then I have my api running on elastic beanstalk and also have ssl set up, so now if I want to hit the api i forward any api.website.com to the name of the server. I also setup ssl so everything is encrypted.

I am also versioning my api like so
api.website.com/v1/&lt;endpoint&gt;
Deployments are a breeze now!

huangapple
  • 本文由 发表于 2017年4月5日 08:45:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/43220027.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定