Skip to content

Instantly share code, notes, and snippets.

@Iliyass
Created September 1, 2020 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Iliyass/ff37ddbb14432b1cba0a0b617438fb30 to your computer and use it in GitHub Desktop.
Save Iliyass/ff37ddbb14432b1cba0a0b617438fb30 to your computer and use it in GitHub Desktop.
local volumes = [
{
name: 'cache',
host: {
path: '/var/cache'
},
},
{
name: 'docker',
host: {
path: '/var/cache/${DRONE_REPO}/docker'
},
}
];
local prepare = {
name: 'prepare',
image: 'busybox',
commands: [
'mkdir -p /cache/${DRONE_REPO}/docker'
],
volumes: [
{
name: 'cache',
path: '/cache'
},
]
};
local build(image_tag, when) = {
name: 'building image by %s' % when,
image: 'plugins/docker',
secrets: [ 'docker_username', 'docker_password' ],
environment:{
REPO_LOCATION: 'my.registry.com/',
BASE_VERSION: 'v1.0.0'
},
settings: {
registry: 'https://my.registry.com/',
username: {
from_secret: 'docker_username'
},
password: {
from_secret: 'docker_password'
},
build_args_from_env: [
'REPO_LOCATION',
'BASE_VERSION'
],
repo: 'my.registry.com/repo_name',
tags: image_tag
},
when: {
event: [ when ],
},
volumes: [
{
name: 'docker',
path: '/var/lib/docker'
}
],
};
{
kind: 'pipeline',
type: 'docker',
name: 'build',
steps: [
prepare,
build("${DRONE_BRANCH/\\//-}", "push"),
build("${DRONE_TAG}", "tag")
],
volumes: volumes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment