• Stars
    star
    318
  • Rank 131,872 (Top 3 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Drone plugin for publishing Docker images

drone-docker

Build Status Gitter chat Join the discussion at https://discourse.drone.io Drone questions at https://stackoverflow.com Go Doc Go Report

Drone plugin uses Docker-in-Docker 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.

Using Docker buildkit Secrets

kind: pipeline
name: default

steps:
- name: build dummy docker file and publish
  image: plugins/docker
  pull: never
  settings:
    repo: tphoney/test
    tags: latest
    secret: id=mysecret,src=secret-file
    username:
      from_secret: docker_username
    password:
      from_secret: docker_password

Using a dockerfile that references the secret-file

# syntax=docker/dockerfile:1.2

FROM alpine

# shows secret from default secret location:
RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret

and a secret file called secret-file

COOL BANANAS

Running from the CLI

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

Developer Notes

  • When updating the base image, you will need to update for each architecture and OS.
  • Arm32 base images are no longer being updated.

Release procedure

Run the changelog generator.

docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator -u drone-plugins -p drone-docker -t <secret github token>

You can generate a token by logging into your GitHub account and going to Settings -> Personal access tokens.

Next we tag the PR's with the fixes or enhancements labels. If the PR does not fufil the requirements, do not add a label.

Run the changelog generator again with the future version according to semver.

docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator -u drone-plugins -p drone-docker -t <secret token> --future-release v1.0.0

Create your pull request for the release. Get it merged then tag the release.

More Repositories

1

drone-gitea-release

Drone plugin for creating and tagging Gitea releases
Go
64
star
2

drone-slack

Drone plugin for sending Slack notifications
Go
62
star
3

drone-git

Drone plugin for cloning Git repositories
Go
53
star
4

drone-webhook

Drone plugin for triggering webhook notifications
Go
50
star
5

drone-github-release

Drone plugin for creating and tagging GitHub releases
Go
37
star
6

drone-s3

Drone plugin for publishing artifacts to Amazon S3
Go
36
star
7

drone-coverage

Plugin for publishing coverage reports
Go
32
star
8

drone-downstream

Drone plugin to trigger downstream repositories to build
Go
31
star
9

drone-ansible

Drone plugin to provision via Ansible
Go
30
star
10

drone-hugo

Drone plugin to publish Hugo generated websites
Go
29
star
11

drone-s3-cache

Caches build artifacts to S3 compatible storage backends
Go
28
star
12

drone-s3-sync

Drone plugin for syncing artifacts with an Amazon S3 Bucket
Go
25
star
13

drone-slack-blame

Drone plugin to send build status blames via Slack
Go
22
star
14

drone-npm

Drone plugin for publishing packages to NPM
Go
20
star
15

github-actions

Run github action as a drone plugin
Go
20
star
16

drone-ecr

Drone plugin for publishing Docker images to the EC2 Container Registry
19
star
17

drone-manifest

Drone plugin to push Docker manifests
Go
16
star
18

drone-volume-cache

Drone plugin to cache directories within the build workspace
Go
16
star
19

drone-gh-pages

Drone plugin for publishing to GitHub Pages
Go
14
star
20

drone-irc

Drone plugin for sending IRC messages
Go
12
star
21

drone-cache

Drone plugin for caching your build workspace
Jsonnet
10
star
22

drone-base

Base image used by the plugins
10
star
23

drone-gcs

Drone plugin for publishing artifacts to Google Cloudstorage
Go
9
star
24

drone-pypi

Drone plugin to publish python packages to PyPi
Go
8
star
25

drone-matrix

Drone plugin for sending Matrix notifications
Go
8
star
26

drone-gpgsign

Drone plugin to sign artifacts with GnuPG
Go
8
star
27

drone-buildah

Drone plugin for publishing Docker images via buildah tool
Go
8
star
28

sonarqube-scanner

sonarqube-scanner
Go
7
star
29

drone-sftp

Drone plugin for uploading files to an SFTP server
Go
7
star
30

drone-rsync

Drone plugin for deploying code using rsync
Go
7
star
31

drone-plugin-lib

Helpers for creating plugins for Drone in Go
Go
7
star
32

drone-buildx

Drone plugin for publishing Docker images using Docker-in-Docker using buildx
Go
6
star
33

drone-azure-storage

Drone plugin for publishing files to Azure Storage
Go
5
star
34

boilr-plugin

boilr template for Drone plugins
Go
5
star
35

drone-marathon

Drone plugins for deploy to Marathon
Go
5
star
36

drone-containership

Drone plugin for deploying to ContainerShip
Jsonnet
5
star
37

drone-codecov

Drone plugin to publish coverage to Codecov
Go
4
star
38

drone-git-action

Drone plugin to handle Git commands
Go
4
star
39

drone-nuget

Drone plugin for uploading files to NuGet repository
JavaScript
4
star
40

drone-hg

Drone plugin for cloning Mercurial repositories
Go
4
star
41

drone-codedeploy

Drone plugin for deploying to CodeDeploy
Jsonnet
4
star
42

drone-dockerhub

Drone plugin for trigger a remote Docker Hub build
Jsonnet
3
star
43

drone-devpi

Drone plugin for publishing python packages with Devpi
Python
3
star
44

artifact-metadata-publisher

Go
2
star
45

drone-pushover

Drone plugin for sending build status notifications via Pushover
Go
2
star
46

drone-download

Drone plugin for downloading files
Go
2
star
47

drone-buildx-gcr

Go
1
star
48

drone-harness-trigger

Go
1
star
49

drone-bintray

Drone plugin for publishing files to Bintray
Go
1
star
50

drone-snyk

Go
1
star
51

drone-azure-web-apps

Drone plugin for deploying to Azure Web Apps
Go
1
star
52

drone-github-release-download

Drone plugin for downloading GitHub Releases
Go
1
star