-
Use .dockerignore files
-
- There are several stages:
- Install system dependencies
- Install project-specific packages
- Build an app
- Run the server
- There are several stages:
-
Don't install unnecessary packages
- I didn't include a text editor in a database image.
-
- to cache layers, we need to copy the most volatile files into the image as late as possible
- also described here
-
- In both apps' Dockerfiles:
- used the base images via FROM
- introduced env variables via ENV
- exposed ports via EXPOSE
- created an ENTRYPOINT to set the default command in exec form
- And left its args in the overridable
CMD
- In both apps' Dockerfiles:
-
Followed 12-factor-app guide
- Each server reads from its dotenv files (
.env
)
- Each server reads from its dotenv files (
-
Used heredocs in
Dockerfiles
to ease reading multiline commands -
Used hadolint to lint the Docker files
See the docs