Skip to content

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)

  1. Copy the packages list and name of the base image from the Dockerfile to variables PACKAGES and BASE respectively in make.env/task.env.
  2. Run make packages/task packages to 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
...
3. Copy the package versions from 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.