docs: add parameter documentation (#26)

This commit is contained in:
Robert Kaussow 2021-09-11 12:02:03 +02:00 committed by GitHub
parent 916bfebb37
commit 3fd42b869c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 147 additions and 55 deletions

107
README.md
View File

@ -50,6 +50,113 @@ docker run --rm \
thegeeklab/drone-docker --dry-run
```
## Parameters
dry_run
: disables docker push
drone_remote_url
: sets the git remote url
mirror
: sets a registry mirror to pull images
storage_driver
: sets the docker daemon storage driver
storage_path (default `/var/lib/docker`)
: sets the docker daemon storage path
bip
: allows the docker daemon to bride ip address
mtu
: sets docker daemon custom mtu setting
custom_dns
: sets custom docker daemon dns server
custom_dns_search
: sets custom docker daemon dns search domain
insecure
: allows the docker daemon to use insecure registries
ipv6
: enables docker daemon ipv6 support
experimental
: enables docker daemon experimental mode
debug "docker_launch_debug
: enables verbose debug mode for the docker daemon
daemon_off
: disables the startup of the docker daemon
dockerfile (default `./Dockerfile`)
: sets dockerfile to use for the image build
context (default `./`)
: sets the path of the build context to use
tags (default `latest`)
: sets repository tags to use for the image; tags can also be loaded from a `.tags` file
auto_tag
: generates tag names automatically based on git branch and git tag
auto_tag_suffix
: generates tag names with the given suffix
build_args
: sets custom build arguments for the build
build_args_from_env
: forwards environment variables as custom arguments to the build
quiet
: enables suppression of the build output
target
: sets the build target to use
cache_from
: sets images to consider as cache sources
pull_image (default `true`)
: enforces to pull base image at build time
compress
: enables compression og the build context using gzip
repo
: sets repository name for the image
registry (default `https://index.docker.io/v1/`)
: sets docker registry to authenticate with
username
: sets username to authenticates with
password
: sets password to authenticates with
email
: sets email addres to authenticates with
config
: sets content of the docker daemon json config
purge (default `true`)
: enables cleanup of the docker environment at the end of a build
no_cache
: disables the usage of cached intermediate containers
add_host
: sets additional host:ip mapping
## Contributors
Special thanks goes to all [contributors](https://github.com/thegeeklab/drone-docker/graphs/contributors). If you would like to contribute,

View File

@ -10,226 +10,220 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "dry-run",
Usage: "dry run disables docker push",
EnvVars: []string{"PLUGIN_DRY_RUN"},
Usage: "disables docker push",
Destination: &settings.Dryrun,
},
&cli.StringFlag{
Name: "remote.url",
Usage: "git remote url",
EnvVars: []string{"DRONE_REMOTE_URL"},
Usage: "sets the git remote url",
Destination: &settings.Build.Remote,
},
&cli.StringFlag{
Name: "daemon.mirror",
Usage: "docker daemon registry mirror",
EnvVars: []string{"PLUGIN_MIRROR", "DOCKER_PLUGIN_MIRROR"},
Usage: "sets a registry mirror to pull images",
Destination: &settings.Daemon.Mirror,
},
&cli.StringFlag{
Name: "daemon.storage-driver",
Usage: "docker daemon storage driver",
EnvVars: []string{"PLUGIN_STORAGE_DRIVER"},
Usage: "sets the docker daemon storage driver",
Destination: &settings.Daemon.StorageDriver,
},
&cli.StringFlag{
Name: "daemon.storage-path",
Usage: "docker daemon storage path",
Value: "/var/lib/docker",
EnvVars: []string{"PLUGIN_STORAGE_PATH"},
Usage: "sets the docker daemon storage path",
Value: "/var/lib/docker",
Destination: &settings.Daemon.StoragePath,
},
&cli.StringFlag{
Name: "daemon.bip",
Usage: "docker daemon bride ip address",
EnvVars: []string{"PLUGIN_BIP"},
Usage: "allows the docker daemon to bride ip address",
Destination: &settings.Daemon.Bip,
},
&cli.StringFlag{
Name: "daemon.mtu",
Usage: "docker daemon custom mtu setting",
EnvVars: []string{"PLUGIN_MTU"},
Usage: "sets docker daemon custom mtu setting",
Destination: &settings.Daemon.MTU,
},
&cli.StringSliceFlag{
Name: "daemon.dns",
Usage: "docker daemon dns server",
EnvVars: []string{"PLUGIN_CUSTOM_DNS"},
Usage: "sets custom docker daemon dns server",
Destination: &settings.Daemon.DNS,
},
&cli.StringSliceFlag{
Name: "daemon.dns-search",
Usage: "docker daemon dns search domains",
EnvVars: []string{"PLUGIN_CUSTOM_DNS_SEARCH"},
Usage: "sets custom docker daemon dns search domain",
Destination: &settings.Daemon.DNSSearch,
},
&cli.BoolFlag{
Name: "daemon.insecure",
Usage: "docker daemon allows insecure registries",
EnvVars: []string{"PLUGIN_INSECURE"},
Usage: "allows the docker daemon to use insecure registries",
Destination: &settings.Daemon.Insecure,
},
&cli.BoolFlag{
Name: "daemon.ipv6",
Usage: "docker daemon IPv6 networking",
EnvVars: []string{"PLUGIN_IPV6"},
Usage: "enables docker daemon IPv6 support",
Destination: &settings.Daemon.IPv6,
},
&cli.BoolFlag{
Name: "daemon.experimental",
Usage: "docker daemon Experimental mode",
EnvVars: []string{"PLUGIN_EXPERIMENTAL"},
Usage: "enables docker daemon experimental mode",
Destination: &settings.Daemon.Experimental,
},
&cli.BoolFlag{
Name: "daemon.debug",
Usage: "docker daemon executes in debug mode",
EnvVars: []string{"PLUGIN_DEBUG", "DOCKER_LAUNCH_DEBUG"},
Usage: "enables verbose debug mode for the docker daemon",
Destination: &settings.Daemon.Debug,
},
&cli.BoolFlag{
Name: "daemon.off",
Usage: "don't start the docker daemon",
EnvVars: []string{"PLUGIN_DAEMON_OFF"},
Usage: "disables the startup of the docker daemon",
Destination: &settings.Daemon.Disabled,
},
&cli.StringFlag{
Name: "dockerfile",
Usage: "build dockerfile",
Value: "Dockerfile",
EnvVars: []string{"PLUGIN_DOCKERFILE"},
Usage: "sets dockerfile to use for the image build",
Value: "Dockerfile",
Destination: &settings.Build.Dockerfile,
},
&cli.StringFlag{
Name: "context",
Usage: "build context",
Value: ".",
EnvVars: []string{"PLUGIN_CONTEXT"},
Usage: "sets the path of the build context to use",
Value: ".",
Destination: &settings.Build.Context,
},
&cli.StringSliceFlag{
Name: "tags",
Usage: "build tags",
Value: cli.NewStringSlice([]string{"latest"}...),
EnvVars: []string{"PLUGIN_TAG", "PLUGIN_TAGS"},
Usage: "sets repository tags to use for the image",
Value: cli.NewStringSlice([]string{"latest"}...),
FilePath: ".tags",
Destination: &settings.Build.Tags,
},
&cli.BoolFlag{
Name: "tags.auto",
Usage: "default build tags",
EnvVars: []string{"PLUGIN_DEFAULT_TAGS", "PLUGIN_AUTO_TAG"},
Usage: "generates tag names automatically based on git branch and git tag",
Destination: &settings.Build.TagsAuto,
},
&cli.StringFlag{
Name: "tags.suffix",
Usage: "default build tags with suffix",
EnvVars: []string{"PLUGIN_DEFAULT_SUFFIX", "PLUGIN_AUTO_TAG_SUFFIX"},
Usage: "generates tag names with the given suffix",
Destination: &settings.Build.TagsSuffix,
},
&cli.StringSliceFlag{
Name: "args",
Usage: "build args",
EnvVars: []string{"PLUGIN_BUILD_ARGS"},
Usage: "sets custom build arguments for the build",
Destination: &settings.Build.Args,
},
&cli.StringSliceFlag{
Name: "args-from-env",
Usage: "build args",
EnvVars: []string{"PLUGIN_BUILD_ARGS_FROM_ENV"},
Usage: "forwards environment variables as custom arguments to the build",
Destination: &settings.Build.ArgsEnv,
},
&cli.BoolFlag{
Name: "quiet",
Usage: "quiet docker build",
EnvVars: []string{"PLUGIN_QUIET"},
Usage: "enables suppression of the build output",
Destination: &settings.Build.Quiet,
},
&cli.StringFlag{
Name: "target",
Usage: "build target",
EnvVars: []string{"PLUGIN_TARGET"},
Usage: "sets the build target to use",
Destination: &settings.Build.Target,
},
&cli.StringSliceFlag{
Name: "cache-from",
Usage: "images to consider as cache sources",
EnvVars: []string{"PLUGIN_CACHE_FROM"},
Usage: "sets images to consider as cache sources",
Destination: &settings.Build.CacheFrom,
},
&cli.BoolFlag{
Name: "squash",
Usage: "squash the layers at build time",
EnvVars: []string{"PLUGIN_SQUASH"},
Destination: &settings.Build.Squash,
},
&cli.BoolFlag{
Name: "pull-image",
Usage: "force pull base image at build time",
EnvVars: []string{"PLUGIN_PULL_IMAGE"},
Usage: "enforces to pull base image at build time",
Value: true,
Destination: &settings.Build.Pull,
},
&cli.BoolFlag{
Name: "compress",
Usage: "compress the build context using gzip",
EnvVars: []string{"PLUGIN_COMPRESS"},
Usage: "enables compression og the build context using gzip",
Destination: &settings.Build.Compress,
},
&cli.StringFlag{
Name: "repo",
Usage: "docker repository",
EnvVars: []string{"PLUGIN_REPO"},
Usage: "sets repository name for the image",
Destination: &settings.Build.Repo,
},
&cli.StringFlag{
Name: "docker.registry",
Usage: "docker registry",
Value: "https://index.docker.io/v1/",
EnvVars: []string{"PLUGIN_REGISTRY", "DOCKER_REGISTRY"},
Usage: "sets docker registry to authenticate with",
Value: "https://index.docker.io/v1/",
Destination: &settings.Login.Registry,
},
&cli.StringFlag{
Name: "docker.username",
Usage: "docker username",
EnvVars: []string{"PLUGIN_USERNAME", "DOCKER_USERNAME"},
Usage: "sets username to authenticates with",
Destination: &settings.Login.Username,
},
&cli.StringFlag{
Name: "docker.password",
Usage: "docker password",
EnvVars: []string{"PLUGIN_PASSWORD", "DOCKER_PASSWORD"},
Usage: "sets password to authenticates with",
Destination: &settings.Login.Password,
},
&cli.StringFlag{
Name: "docker.email",
Usage: "docker email",
EnvVars: []string{"PLUGIN_EMAIL", "DOCKER_EMAIL"},
Usage: "sets email addres to authenticates with",
Destination: &settings.Login.Email,
},
&cli.StringFlag{
Name: "docker.config",
Usage: "docker json dockerconfig content",
EnvVars: []string{"PLUGIN_CONFIG", "DOCKER_PLUGIN_CONFIG"},
Usage: "sets content of the docker daemon json config",
Destination: &settings.Login.Config,
},
&cli.BoolFlag{
Name: "docker.purge",
Usage: "docker should cleanup images",
EnvVars: []string{"PLUGIN_PURGE"},
Usage: "enables cleanup of the docker environment at the end of a build",
Value: true,
Destination: &settings.Cleanup,
},
&cli.BoolFlag{
Name: "no-cache",
Usage: "do not use cached intermediate containers",
EnvVars: []string{"PLUGIN_NO_CACHE"},
Usage: "disables the usage of cached intermediate containers",
Destination: &settings.Build.NoCache,
},
&cli.StringSliceFlag{
Name: "add-host",
Usage: "additional host:IP mapping",
EnvVars: []string{"PLUGIN_ADD_HOST"},
Usage: "sets additional host:ip mapping",
Destination: &settings.Build.AddHost,
},
}

View File

@ -66,9 +66,6 @@ func commandBuild(build Build) *exec.Cmd {
}
args = append(args, build.Context)
if build.Squash {
args = append(args, "--squash")
}
if build.Compress {
args = append(args, "--compress")
}

View File

@ -52,7 +52,6 @@ type Build struct {
Args cli.StringSlice // Docker build args
ArgsEnv cli.StringSlice // Docker build args from env
Target string // Docker build target
Squash bool // Docker build squash
Pull bool // Docker build pull
CacheFrom cli.StringSlice // Docker build cache-from
Compress bool // Docker build compress
@ -153,11 +152,6 @@ func (p *Plugin) Execute() error {
fmt.Println("Registry credentials or Docker config not provided. Guest mode enabled.")
}
if p.settings.Build.Squash && !p.settings.Daemon.Experimental {
fmt.Println("Squash build flag is only available when Docker deamon is started with experimental flag. Ignoring...")
p.settings.Build.Squash = false
}
// add proxy build args
addProxyBuildArgs(&p.settings.Build)