Skip to main content
Docker
These are docker guidelines that are a MUST for every developments.development:
- Docker support consists in 4 kind of
files:files: compose.local.yaml (for local development), compose.dev.yaml (for development infrastructure), compose.test.yaml (for test infrastructure), compose.yaml (for production infrastructure)
- In local compose we use the build keyword; In others we use image keyword only, with related tag
prefixsprefixes (dev, test, none x prod)
- With every environment comes
aan env file,file, this is done to avoid making errors in productions
- Loading env file (dotenv.
load_dotenv)load_dotenv) is not needed because it's loaded using env_file keyword (remember adding to .dockerignore to avoid sensible informationsinformation leaking)
- Pinning version in composes of used images it's good because we can get
envrionmentsenvironments exactly as we expect in development
- Creating a .dockerignore file allow us to reduce images size, avoid info leaking
- Order in Dockerfile instructions matter, it can reduce the builds time
- All docker support files are stored in "docker"
folder
- Provide healthcheck for services (es. PostgresDB, endpoint for webapp)
- It's
preferedpreferred to use local mount instead of volumes because we can easily get the content from devops
- To build images that have private dependencies, we need to pass a token as argument (
WIPWIP))
- Use a proper container name with development name and code (ex. 123_geocoding)
- When a service has a external exposed port, we declare in ports keyword; When it's only for internal use, we declare in expose keyword
- In test, dev and prod it's convenient to set the restart policy to always
- IaC files (ex. scheduling files) can be stored in "iac" folder, and need to observe this guide
ContinousContinuous Development it's handy to update code in different enviroments,environments, we set by adding "cloud.eagleprojects.autocd.enable=true"true" in label list keyword