Linting
My Docker repositories use yamllint and hadolint to lint the repositories.
# Use the Makefile to lint the repository.
make lint
Yamllint
# Manually lint
yamllint .
Hadolint
# Manually lint
hadolint Dockerfile
Pin Package Versions (DL3008)
- Copy the packages list and name of the base image from the
Dockerfileto variablesPACKAGESandBASErespectively inmake.env/task.env. - Run
make packages/task packagesto list the package versions.
task packages-alpine
...
ca-certificates policy:
20191127-r5:
lib/apk/db/installed
http://dl-cdn.alpinelinux.org/alpine/v3.13/main
...
stdout over to the Dockerfile. Similar steps may be taken to pin pip (DL3013) and npm (DL3016) packages.
Alternatively, a shell may be launched of the build image and manually run apk policy <package> or apt-update && apt-cache policy <package> to get the package versions.
Pre-commit hook
If you want to automatically generate README.md files with a pre-commit hook, make sure you install the pre-commit binary, and add a .pre-commit-config.yaml to your project. Then run:
pre-commit install
pre-commit install-hooks
Currently, this only works on amd64 systems.
Github Action
The lint github action is also used to lint the repo upon commit.