docker

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

drone-buildah

Build Status Gitter chat Go Doc Go Report

Drone plugin uses buildah 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/buildah-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/buildah-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/buildah-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/buildah-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/buildah-heroku .

Usage

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultTagSuffix

func DefaultTagSuffix(ref, suffix string) ([]string, error)

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

func DefaultTags

func DefaultTags(ref string) ([]string, error)

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

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. It is a NOOP in buildah
	Compress    bool     // Docker build compress
	Repo        string   // Docker build repository
	LabelSchema []string // label-schema Label map
	AutoLabel   bool     // auto-label bool
	Labels      []string // Label map
	Link        string   // Git repo link
	NoCache     bool     // Docker build no-cache
	AddHost     []string // Docker build add-host
	Quiet       bool     // Docker build quiet
	S3CacheDir  string
	S3Bucket    string
	S3Endpoint  string
	S3Region    string
	S3Key       string
	S3Secret    string
	S3UseSSL    bool
	Layers      bool
}

Build defines Docker build parameters.

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
	Config   string // Docker Auth Config
}

Login defines Docker login parameters.

type Plugin

type Plugin struct {
	Login   Login // Docker login configuration
	Build   Build // Docker build 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