docker_ignore_all

This script will create a .dockerignore file ignoring everything for a given directory ($PWD if not given).

The following parameters are optional:

f

overwrite an existing .dockerignore file

The generated file contains two sections:

  1. generally useful ignores

  2. all top-level directories and files

It should be used as a starting point, i.e. you should remove entries which should not be ignored.

Usage

$ scripts/docker/docker_ignore_all.sh
$ tree --noreport -a -I .git /tmp/example
/tmp/example
├── .dockerignore
└── Dockerfile
$ scripts/docker/docker_ignore_all.sh -f /tmp/example
$ cat /tmp/example/.dockerignore
# https://docs.docker.com/build/building/context/#dockerignore-files
*~
*.orig
*.sw[a-p]
*.tmp
.DS_Store
[Dd]esktop.ini
Thumbs.db

.dockerignore
Dockerfile