Live data from Hacker News

Writing Dockerfiles for Node.js Web Apps

blog.hasura.io

31–37 of 37 posts

Re: Writing Dockerfiles for Node.js Web Apps

#31

I completely get the purpose and benefit of Docker. More and more though I'm becoming convinced that for many settings and problems Docker actually creates more problems and meaningless ritual because Docker rapidly is becoming the standard way of deploying software with hardly anyone asking about the reasons anymore. Docker recreates many of the benefits the Java platform has had from the start (in addition to some…

> So, with Docker we now indiscriminately add an additional layer of complexity on top of existing applications regardless of the actual problems this might solve. I agree that it adds an extra layer of complexity but it also provides a lot of things out of the box (like isolation, separation of concerns, platform agnostic deployments, reproducability and lot more) which makes the life of a developer so easy. If he w…

The problem lies with the "just needs to dockerize his application" part. These days I see many developers regularly servicing Docker containers where they rather should be adding value to the product they're creating. It almost seems as if Docker has become an end in itself rather than just a means.

In some ways with Docker you also only move concerns from one layer to another. While in the past you had to manage dependencies on the target machine you now have to manage Docker dependencies and environments on that machine on top of the dependency management for your application.

Re: Writing Dockerfiles for Node.js Web Apps

#32
post #28

Earlier quoted context omitted.

Depends on the use-case. For development, you would need to install some system dependencies, access to bash for debugging etc and hence the full blown base image. In production, you want the image sizes to be minimal and hence alpine base image. Also reduces the attack vector.

But why are you doing minute-to-minute development within a container? What's so hard about installing the official Node package for your development system's distribution? When the developer is finished working on a feature, then and only then build a production Docker image from the codebase that now implements that feature, maybe run a few smoke tests, and push to CI. Building special containers for development pu…

I am developing in a container - most of the time - as this allows me to run the (micro-)service within it's defined ecosystem, so no need to mock any service boundaries.

Note: New services and major functionalities are usually developed locally with unit-tests ensuring compliance with the spec. But once this is done and stuff needs to be integrated with the real system - or debugged later on - there is IMHO nothing that can beat a complete copy of the real system running locally where one can easily manipulate whatever is needed.

Re: Writing Dockerfiles for Node.js Web Apps

#33
post #29

or not writing dockerfiles at all, using stock docker images. as in this article http://engineering.opensooq.com/on-the-fly-ad-hoc-docker-com...

Instead of writing Dockerfiles, this approach requires me to write a docker-compose.yaml file. How is it more advantageous?

Re: Writing Dockerfiles for Node.js Web Apps

#34

Earlier quoted context omitted.

> So, with Docker we now indiscriminately add an additional layer of complexity on top of existing applications regardless of the actual problems this might solve. I agree that it adds an extra layer of complexity but it also provides a lot of things out of the box (like isolation, separation of concerns, platform agnostic deployments, reproducability and lot more) which makes the life of a developer so easy. If he w…

The problem lies with the "just needs to dockerize his application" part. These days I see many developers regularly servicing Docker containers where they rather should be adding value to the product they're creating. It almost seems as if Docker has become an end in itself rather than just a means. In some ways with Docker you also only move concerns from one layer to another. While in the past you had to manage de…

Fair point. Again it is the call that the developer has to take depending upon certain parameters. If he is shipping multiple applications built with Python with one requiring Python 2.7 and the other requiring Python 3.4. He has to somehow make sure that both the application will run peacefully together or he can just create two docker images on his machine one contains Python2.7 installed and the other contains Python 3.0 installed and deploy it the docker way without any hassle. At the end of the day it is the call he has to take depending upon how much time each of the flow is going to consume and which one makes his life easy.

Re: Writing Dockerfiles for Node.js Web Apps

#35
post #15

Earlier quoted context omitted.

If you use container orchestration platforms like Kubernetes, this is not required, as restarts load balancing etc. are handled by the orchestrator.

Does Kubernetes support graceful reload of containers, with 0 downtime? I'd be very interested if so.

[deleted]

Re: Writing Dockerfiles for Node.js Web Apps

#36
No mention of using a non-root user? Any reason why or just oversight?

With Debian based images like node:carbon you could do something like this:

  ENV HOME /home/nodejs
  RUN groupadd -r nodejs \
  && useradd -r -g nodejs nodejs \
  && mkdir -p $HOME \
  && chown nodejs:nodejs $HOME
  USER nodejs
With alpine something like this:

  RUN addgroup -S nodejs && adduser -S -G nodejs nodejs
  USER nodejs
Post reply on HN