Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Improve Dockerfile #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

glogiotatidis
Copy link

Hey folks,

This is a much improved dockerfile I thought to prepare for you with some docker best-practices. Here it goes:

  • Improve docker caching: Move commands that will not change with code changes on the top, like WORKDIR, apt-get install etc. This way when only your code changes these docker layers will not get invalidated.
  • Start with a slimmer image, less download, more profit.
  • Copy requirements and pip install before code to improve caching even further.
  • Run apt-get update and apt-get installs in the same line, otherwise you will eventually end up with docker images that cannot get build because the apt-get update will be cached and pointing to packages that no longer exist. See for more caching and “apt-get update” moby/moby#3313
  • ADD is a complicated command with lots of magic (url downloading, auto tarball extraction, etc). Try to use COPY instead and limit ADD use to the absolute necessary.

More can be done like create a user and run based on that user which will help with file permissions on the host too.

Enjoy!

@comzeradd
Copy link
Contributor

Looks good to me. I'll let @johngian review it further since he's done the docker implementation here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants