parabuzzle / craneoperator

Gives you a simple web interface for browsing around a Docker Registry
https://hub.docker.com/r/parabuzzle/craneoperator
MIT License
127 stars 32 forks source link

Docker should handle installing dependencies #35

Closed TheBay0r closed 7 years ago

TheBay0r commented 7 years ago

From my point of view the docker container should handle installing the dependencies without "polluting" the host system with the installed dependencies.

Like this it is not necessary to have node, rake, etc. installed on the host system to still be able to build a new docker container. :)

parabuzzle commented 7 years ago

@TheBay0r I disagree. Build environment != Runtime environment

The docker container is the runtime environment for the application. It should only have the things required to run the application to keep it as small as possible in my opinion. You don't need nodejs or the npm modules for anything other than building the bundle.js with webpack.

Your container contains 136.5MB of extra stuff that is not needed for the application to run. Now you could clean that up as an extra layer in the Dockerfile; however, that invalidates almost all the other layers in the cache which means building the container will require a full run through the Dockerfile again.

In bigger projects (mostly C++ based projects), I've created a build container Dockerfile that builds the binaries (in this case the bundle.js) and spits out the finished artifacts into a mounted volume and then the actual runtime (runable) container uses the artifacts the build container built.

That seems like a bit of overkill for such a small project.

I'm open to suggestions here but I don't think putting nodejs and all the npm modules into the container just to run webpack and bundle up the react app is the right solution here.

TheBay0r commented 7 years ago

@parabuzzle Thank you for your response. That's definitely a valid point, I haven't considered for this project. For most of my docker containers nodejs is anyways required because I usually use node servers (and develop inside the containers) instead of ruby.

It just felt weird to me to need gem, httparty, memoist on my system to even be able to build the container. My first thought about your concerns were also cleaning up the container to reduce its size again.

I guess I have to rethink this 🤔

TheBay0r commented 7 years ago

@parabuzzle Just pushed a change that would be also some "dockery" kind of way. With this change the total image size is just 11MB bigger than the original one.

I also dared to reduce the number of layers 😅

Let me know what you think about it. If you don't like it, I guess this PR can be closed :)

parabuzzle commented 7 years ago

Looks good to me :)