Skip to content

piotr-semenov/dockerfile-commons

Repository files navigation

License: MIT

This repo holds the collections of "ready-to-use" code snippets helping to develop tiny Docker images.

Collection Description
Make Recipes Certain "ready to use" Makefile recipes to cover the most of Docker image development:
  • Lint all the files matching Dockerfile* pattern via Hadolint (run by make lint-dockerfiles, see lint-dockerfiles.mk).
  • List all the files sending to docker build context (run by make test-dockerignore, see test-dockerignore.mk).
  • Scan the docker image for the vulnerabilities via Anchore/Clair (run by make scan-docker, see scan-docker.mk)
  • Clean out the dangling docker images, intermediate (i.e. providing the label stage=intermediate) ones, and already exited containers (run by make clean-docker, see clean-docker.mk).
Make Functions Makefile functions for common Docker development tasks: build, test via Dgoss, and uuid generation.
Bash Scripts POSIX-compliant shell scripts for Alpine Linux to short-cut the commonly used Dockerfile RUN directives:
Configs Config for Hadolint tool (see .hadolint.yaml).

Installation

Just copy the sources to your project root. Or you can add it as submodule to your repository via command below:

git submodule add https://github.com/piotr-semenov/dockerfile-commons dockerfile-commons

Requirements

Usage

You can setup the following environment variables in your .env file.

Variable Description Used by recipes
HADOLINT_CONFIG Path to your Hadolint config (if not set, make lint-dockerfiles will use "./dockerfile-commons/.hadolint.yaml"). lint-dockerfiles
IMAGE_NAMES Whitespace-separated list of Docker image tags existing in your local Docker registry. E.g. "postgres:9 ubuntu:latest". scan-docker

Please, find the example .env file below:

HADOLINT_CONFIG=$$PWD/.hadolint.yaml
IMAGE_NAMES=postgres:9 busybox

Now you do the job via make lint-dockerfiles test-dockerignore scan-docker clean-docker.

Also you can include these recipes in your own Makefile with lines below:

include /path/to/dockerfile-commons/Makefile

Projects using dockerfile-commons

Project Description
tiny-elm The smallest docker image for recent Elm compiler + tools.
tiny-yuicompressor The smallest docker image for yuicompressor tool.
tiny-uglify The smallest docker image for uglifyJS and uglifyCSS tools.
tiny-parigp The smallest docker image for PARI/GP and GP2C scientific software.