TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Lessons from Building Node Apps in Docker

107 点作者 JohnHammersley超过 5 年前

7 条评论

peterwwillis超过 5 年前
If you&#x27;re going to run these containers in production [on more than a single host], throw out the volumes and docker compose. Mock up your dev sdlc to work like production (ex. you can&#x27;t use Docker Compose to start Fargate tasks)<p>In fact, I&#x27;m going to make a very heretical suggestion and say, don&#x27;t even start writing app code until you know exactly how your whole SDLC, deployment workflow, architecture, etc will work in production. Figure out all that crap right at the start. You&#x27;ll have a lot of extra considerations you didn&#x27;t think of before, like container and app security scanning, artifact repository, source of truth for deployment versions, quality gates, different pipelines for dev and prod, orchestration system, deployment strategy, release process, secrets management, backup, access control, network requirements, service accounts, monitoring, etc.<p>The reason to map all that out up front is to &quot;shift left&quot;. If you do these things one at a time, you lose more time later as you slowly implement each piece, refactoring as you go. Whereas if you know everything you&#x27;re going to have to do, you have much better estimates of work. It&#x27;s like doing sprint grooming but much farther ahead. Figure out potential problems sooner and it saves your butt down the road. (You can still change everything as you go, but your estimates will be wayyyy closer to reality, and you&#x27;ll need less rework)<p>A weird comparison would be trying to build wooden furniture without planning out how you were gonna build it. You can get it done, but you have no idea if it&#x27;ll take a weekend or two months. Plan it out and you can get more done in one shot, and the quality even improves. This is also the principle behind <i>mise en place</i>.
评论 #21211290 未加载
评论 #21210740 未加载
评论 #21227093 未加载
ypeter超过 5 年前
Why do you run the final production container with a node (slim) image and not just nginx? Would be another 6 times smaller.
评论 #21211970 未加载
rcarmo超过 5 年前
In case anyone needs ARM containers for node, I build my own LTS containers on Travis:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;insightfulsystems&#x2F;alpine-node" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;insightfulsystems&#x2F;alpine-node</a><p>...and use those as the base for most of my stuff in order to have a bit more control over what goes in the images:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;insightfulsystems&#x2F;node-red" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;insightfulsystems&#x2F;node-red</a>
ne01超过 5 年前
The fact that you need to learn so many lessons while using docker shows how complex it is.
评论 #21212495 未加载
iquestionshard超过 5 年前
Is there a benefit to why you&#x27;d `npm install` in docker? I would likely have already done that in the checkout and test part of my workflow, and can just copy everything over from that?
评论 #21212672 未加载
评论 #21213005 未加载
chrisweekly超过 5 年前
Thanks, @JohnHammersley! Your 2016 writeup of the same name was well-received; given how fast things change in this space, I&#x27;d bet this &quot;updated for 2019&quot; version is worth bookmarking.
评论 #21216365 未加载
dang超过 5 年前
Related from 2016: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11545975" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11545975</a>