Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci/cd): build containers using drone.io #891

Merged
merged 5 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ workflows:
- run:
name: container
command: |
make $APP-image
make $APP-image-cross

# builds and pushes a container
.publish: &publish
Expand Down
22 changes: 22 additions & 0 deletions .drone/docker-manifest.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
image: grafanasaur/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
- image: grafanasaur/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-amd64
platform:
architecture: amd64
os: linux
- image: grafanasaur/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-arm64
platform:
architecture: arm64
os: linux
variant: v8
- image: grafanasaur/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-arm
platform:
architecture: arm
os: linux
variant: v7
101 changes: 101 additions & 0 deletions .drone/drone.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
local apps = ['loki', 'loki-canary', 'promtail'];
local archs = ['amd64', 'arm64', 'arm'];

local condition(verb) = {
tagMaster: {
ref: {
[verb]:
[
'refs/heads/master',
'refs/tags/v*',
],
},
},
};

local pipeline(name) = {
kind: 'pipeline',
name: name,
steps: [],
};

local docker(arch, app) = {
name: '%s-image' % if $.settings.dry_run then 'build-' + app else 'publish-' + app,
image: 'plugins/docker',
settings: {
repo: 'grafanasaur/%s' % app,
dockerfile: 'cmd/%s/Dockerfile' % app,
username: { from_secret: 'saur_username' },
password: { from_secret: 'saur_password' },
dry_run: false,
},
};

local multiarch_image(arch) = pipeline('docker-' + arch) {
platform: {
os: 'linux',
arch: arch,
},
steps: [{
name: 'image-tag',
image: 'alpine',
commands: [
'apk add --no-cache bash git',
'git fetch origin --tags',
'echo $(./tools/image-tag)-%s > .tags' % arch,
],
}] + [
// dry run for everything that is not tag or master
docker(arch, app) {
depends_on: ['image-tag'],
when: condition('exclude').tagMaster,
settings+: { dry_run: true },
}
for app in apps
] + [
// publish for tag or master
docker(arch, app) {
depends_on: ['image-tag'],
when: condition('include').tagMaster,
}
for app in apps
],
};

local manifest(apps) = pipeline('manifest') {
steps: [
{
name: 'manifest-' + app,
image: 'plugins/manifest',
settings: {
// the target parameter is abused for the app's name,
// as it is unused in spec mode. See docker-manifest.tmpl
target: app,
spec: '.drone/docker-manifest.tmpl',
ignore_missing: true,
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
},
depends_on: ['clone'],
}
for app in apps
],
} + {
depends_on: [
'docker-%s' % arch
for arch in archs
],
};

local drone = [
multiarch_image(arch)
for arch in archs
] + [
manifest(['promtail', 'loki', 'loki-canary']) {
trigger: condition('include').tagMaster,
},
];

{
drone: std.manifestYamlStream(drone),
}
Loading