docker

package module
v0.0.0-...-f937721 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

README

drone-docker

Build Status Gitter chat Go Doc Go Report

Drone plugin to build and publish Docker images to a container registry. For the usage information and a listing of the available options please take a look at the docs.

Build

Build the binaries with the following commands:

export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=0
export GO111MODULE=on

go build -v -a -tags netgo -o release/linux/amd64/drone-docker ./cmd/drone-docker
go build -v -a -tags netgo -o release/linux/amd64/drone-gcr ./cmd/drone-gcr
go build -v -a -tags netgo -o release/linux/amd64/drone-ecr ./cmd/drone-ecr
go build -v -a -tags netgo -o release/linux/amd64/drone-acr ./cmd/drone-acr
go build -v -a -tags netgo -o release/linux/amd64/drone-heroku ./cmd/drone-heroku

Docker

Build the Docker images with the following commands:

docker build \
  --label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
  --label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
  --file docker/docker/Dockerfile.linux.amd64 --tag plugins/docker .

docker build \
  --label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
  --label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
  --file docker/gcr/Dockerfile.linux.amd64 --tag plugins/gcr .

docker build \
  --label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
  --label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
  --file docker/ecr/Dockerfile.linux.amd64 --tag plugins/ecr .

docker build \
  --label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
  --label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
  --file docker/acr/Dockerfile.linux.amd64 --tag plugins/acr .

docker build \
  --label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
  --label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
  --file docker/heroku/Dockerfile.linux.amd64 --tag plugins/heroku .

Usage

Notice: Be aware that the Docker plugin currently requires privileged capabilities, otherwise the integrated Docker daemon is not able to start.

docker run --rm \
  -e PLUGIN_TAG=latest \
  -e PLUGIN_REPO=octocat/hello-world \
  -e DRONE_COMMIT_SHA=d8dbe4d94f15fe89232e0402c6e8a0ddf21af3ab \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  --privileged \
  plugins/docker --dry-run

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultTagSuffix

func DefaultTagSuffix(ref, suffix string) []string

DefaultTagSuffix returns a set of default suggested tags based on the commit ref with an attached suffix.

func DefaultTags

func DefaultTags(ref string) []string

DefaultTags returns a set of default suggested tags based on the commit ref.

func GetTagNameByPath

func GetTagNameByPath(basePath string, currentPath string) (tag string)

func GetTagsByFileSuffix

func GetTagsByFileSuffix(basePath string) (tags []string)

func UseDefaultTag

func UseDefaultTag(ref, defaultBranch string) bool

UseDefaultTag for keep only default branch for latest tag

Types

type Build

type Build struct {
	Remote      string   // Git remote URL
	Name        string   // Docker build using default named tag
	Dockerfile  string   // Docker build Dockerfile
	Context     string   // Docker build context
	Tags        []string // Docker build tags
	Args        []string // Docker build args
	ArgsEnv     []string // Docker build args from env
	Target      string   // Docker build target
	Squash      bool     // Docker build squash
	Pull        bool     // Docker build pull
	CacheFrom   []string // Docker build cache-from
	Compress    bool     // Docker build compress
	Repo        string   // Docker build repository
	LabelSchema []string // label-schema Label map
	Labels      []string // Label map
	NoCache     bool     // Docker build no-cache
	MultiRepo   []string // Multi-Repo list
	MultiBase   string   // Multi-Repo folder base
}

Build defines Docker build parameters.

type Daemon

type Daemon struct {
	Registry      string   // Docker registry
	Mirror        string   // Docker registry mirror
	Insecure      bool     // Docker daemon enable insecure registries
	StorageDriver string   // Docker daemon storage driver
	StoragePath   string   // Docker daemon storage path
	Disabled      bool     // DOcker daemon is disabled (already running)
	Debug         bool     // Docker daemon started in debug mode
	Bip           string   // Docker daemon network bridge IP address
	DNS           []string // Docker daemon dns server
	DNSSearch     []string // Docker daemon dns search domain
	MTU           string   // Docker daemon mtu setting
	IPv6          bool     // Docker daemon IPv6 networking
	Experimental  bool     // Docker daemon enable experimental mode
}

Daemon defines Docker daemon parameters.

type FileWalk

type FileWalk struct {
	BasePath string
	Tags     []string
}

func (*FileWalk) WalkTagByPath

func (f *FileWalk) WalkTagByPath(path string, info os.FileInfo, err error) error

type Login

type Login struct {
	Registry string // Docker registry address
	Username string // Docker registry username
	Password string // Docker registry password
	Email    string // Docker registry email
}

Login defines Docker login parameters.

type Plugin

type Plugin struct {
	Login   Login  // Docker login configuration
	Build   Build  // Docker build configuration
	Daemon  Daemon // Docker daemon configuration
	Dryrun  bool   // Docker push is skipped
	Cleanup bool   // Docker purge is enabled
}

Plugin defines the Docker plugin parameters.

func (Plugin) Exec

func (p Plugin) Exec() error

Exec executes the plugin step

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL