KubeNow icon indicating copy to clipboard operation
KubeNow copied to clipboard

Dockerfile best practices need to be applied

Open mcapuccini opened this issue 6 years ago • 10 comments

Docker file install needs to be splitted in multiple commands. As it is now it is hard to read. https://github.com/kubenow/KubeNow/blob/master/Dockerfile#L26-L61

mcapuccini avatar Dec 07 '17 16:12 mcapuccini

Yes but otherwise it creates more layers and get substantially larger... In the future Travis might support the new (currently experimental) command docker --squash

andersla avatar Dec 07 '17 16:12 andersla

Docker squash is now in Travis: https://github.com/travis-ci/travis-ci/issues/7380

mcapuccini avatar Dec 07 '17 17:12 mcapuccini

Unfortunately it is still part of the "experimental" features not enabled on travis - I already did try to enable it with env-vars but never got it to work.

andersla avatar Dec 07 '17 19:12 andersla

Is there any thread we can follow, so we kwon when it will become available?

mcapuccini avatar Dec 08 '17 08:12 mcapuccini

Well, if you want to have your stuff readable and in one RUN, simply follow the dockerfile best practices. There is no need to split it and squash it.

RUN true \
 && command \
 && apt install -y \
      aIndented \
      bAnd \
      cSORTED \
      dPackage \
      eList \
 && command \
 && true
  • Group (read: indent) the commands correct.
  • Pack the arguments into a new line (and if the arguments are a set, sort it!)
  • I usually add true as the first and last command. This allows me to insert commands at the beginning/end without touching the previous first/last command and not polluting the git history

The stuff with the

`# this is a comment`

is genius!

bebehei avatar Dec 12 '17 15:12 bebehei

I'm submitting a PR. Give me some time pls.

bebehei avatar Dec 12 '17 15:12 bebehei

That's a good remark 🙂

mcapuccini avatar Dec 12 '17 15:12 mcapuccini

So, I also reviewed this part of the dockerfile (But I'm not touching these with the PR):

  • Also, there should be an export DEBIAN_FRONTEND=noninteractive in every RUN statement involving apt. (Do not export it in an ENV).
  • The multiple ENVs should also be grouped together.
  • If you install apt-transport-https, I think you should also add the repository with https instead of http.
  • As you're downloading from https, it might be also good to make sure, that ca-certificates package is installed and up to date.

bebehei avatar Dec 12 '17 15:12 bebehei

@mcapuccini Thanks for merging #312. But KIM the other points, I also have noted in my previous comment here.

bebehei avatar Dec 13 '17 13:12 bebehei

Yep, reopening the issue and renaming it 🙂

mcapuccini avatar Dec 13 '17 13:12 mcapuccini