cozy-labs / cozy-docker

Dockerfile to build an official Cozy image
44 stars 26 forks source link

Implement Dockerfile best practices. #2

Closed jankeromnes closed 9 years ago

jankeromnes commented 9 years ago

Thanks for writing a Dockerfile for Cozy!

I took the liberty to implement some best practices, including an improved handling of cache.

For example, the commands apt-get update and apt-get install should always be in the same RUN instruction, because they need to be executed approximately at the same time. Otherwise, the result of the update command will be cached and rarely invalidated, whereas the install command will be invalidated regularly (e.g. when new packets need to be installed), which cause network requests based on an outdated index. That's exactly what happened to me when I first tried your Dockerfile:

Err http://archive.ubuntu.com/ubuntu/ trusty-security/main openssl amd64 1.0.1f-1ubuntu2.8
  404  Not Found [IP: 91.189.92.201 80]
Err http://archive.ubuntu.com/ubuntu/ trusty-security/main libssl-dev amd64 1.0.1f-1ubuntu2.8
  404  Not Found [IP: 91.189.92.201 80]
Err http://archive.ubuntu.com/ubuntu/ trusty-security/main libssl-doc all 1.0.1f-1ubuntu2.8
  404  Not Found [IP: 91.189.92.201 80]
Err http://archive.ubuntu.com/ubuntu/ trusty-security/main python-requests all 2.2.1-1ubuntu0.1
  404  Not Found [IP: 91.189.92.201 80]
Fetched 117 MB in 2min 55s (667 kB/s)
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/c/cups-filters/libcupsfilters1_1.0.52-0ubuntu1.2_amd64.deb  404  Not Found [IP: 91.189.91.24 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/openssl_1.0.1f-1ubuntu2.8_amd64.deb  404  Not Found [IP: 91.189.92.201 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.0.1f-1ubuntu2.8_amd64.deb  404  Not Found [IP: 91.189.92.201 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-doc_1.0.1f-1ubuntu2.8_all.deb  404  Not Found [IP: 91.189.92.201 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/r/requests/python-requests_2.2.1-1ubuntu0.1_all.deb  404  Not Found [IP: 91.189.92.201 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Additional changes:

Kloadut commented 9 years ago

Thanks !