alpine/.drone.jsonnet
Robert Kaussow 4d7b134830
All checks were successful
continuous-integration/drone/push Build is passing
test multiarch
2021-01-10 15:54:34 +01:00

194 lines
4.8 KiB
Plaintext

local PipelineTest = {
kind: 'pipeline',
name: 'test',
platform: {
os: 'linux',
arch: 'amd64',
},
steps: [
{
name: 'markdownlint',
image: 'thegeeklab/markdownlint-cli',
commands: [
"markdownlint 'README.md'",
],
},
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
},
};
local PipelineBuildContainer(arch='amd64') = {
kind: 'pipeline',
name: 'build-container-' + std.split(arch, '_')[0],
platform: {
os: 'linux',
arch: 'amd64',
},
steps: [
{
name: 'wait-for',
image: 'thegeeklab/wait-for',
commands: [
'wait-for dind-' + arch + ':2376',
],
environment: {
WAITFOR_TIMEOUT: 60,
},
},
{
name: 'dryrun',
image: 'jdrouet/docker-with-buildx:stable',
commands: [
'docker buildx create --use',
'docker buildx build --platform linux/' + std.strReplace(arch, '_', '/') + ' --tag thegeeklab/buildx-alpine:latest -f "$$DOCKERFILE" .',
],
environment: {
DOCKERFILE: 'Dockerfile.' + std.split(arch, '_')[0],
},
volumes: [{
name: 'dockersock-' + arch,
path: '/var/run',
}],
depends_on: ['wait-for'],
when: {
ref: ['refs/pull/**'],
},
},
{
name: 'tags',
image: 'thegeeklab/docker-autotag',
environment: {
DOCKER_AUTOTAG_FORCE_LATEST: 'True',
DOCKER_AUTOTAG_IGNORE_PRERELEASE: 'True',
DOCKER_AUTOTAG_OUTPUT_FILE: '.tags',
DOCKER_AUTOTAG_VERSION: '${DRONE_TAG}',
},
depends_on: ['wait-for'],
when: {
ref: ['refs/heads/main', 'refs/tags/**'],
},
},
{
name: 'publish-dockerhub',
image: 'jdrouet/docker-with-buildx:stable',
commands: [
'docker login -u "$$DOCKER_USERNAME" -p "$$DOCKER_PASSWORD"',
'docker buildx create --use',
'docker buildx build --push --platform linux/' + std.strReplace(arch, '_', '/') + ' --tag thegeeklab/buildx-alpine:' + std.split(arch, '_')[0] + ' -f "$$DOCKERFILE" .',
],
environment: {
DOCKER_PASSWORD: { from_secret: 'docker_password' },
DOCKER_USERNAME: { from_secret: 'docker_username' },
DOCKERFILE: 'Dockerfile.' + std.split(arch, '_')[0],
},
volumes: [{
name: 'dockersock-' + arch,
path: '/var/run',
}],
when: {
ref: ['refs/heads/main', 'refs/tags/**'],
},
depends_on: ['tags'],
},
],
services: [
{
name: 'dind-' + arch,
image: 'docker:dind',
privileged: true,
volumes: [{
name: 'dockersock-' + arch,
path: '/var/run',
}],
},
],
volumes: [{
name: 'dockersock-' + arch,
temp: {},
}],
depends_on: [
'test',
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
},
};
local PipelineNotifications = {
kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'notifications',
platform: {
os: 'linux',
arch: 'amd64',
},
steps: [
{
image: 'plugins/manifest',
name: 'manifest-dockerhub',
settings: {
ignore_missing: true,
auto_tag: true,
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
spec: 'manifest.tmpl',
},
when: {
status: ['success'],
},
},
{
name: 'pushrm-dockerhub',
pull: 'always',
image: 'chko/docker-pushrm:1',
environment: {
DOCKER_PASS: {
from_secret: 'docker_password',
},
DOCKER_USER: {
from_secret: 'docker_username',
},
PUSHRM_FILE: 'README.md',
PUSHRM_SHORT: 'Rootless Alpine base image',
PUSHRM_TARGET: 'thegeeklab/buildx-alpine',
},
when: {
status: ['success'],
},
},
{
name: 'matrix',
image: 'plugins/matrix',
settings: {
homeserver: { from_secret: 'matrix_homeserver' },
roomid: { from_secret: 'matrix_roomid' },
template: 'Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}',
username: { from_secret: 'matrix_username' },
password: { from_secret: 'matrix_password' },
},
when: {
status: ['success', 'failure'],
},
},
],
depends_on: [
'build-container-amd64',
'build-container-arm64',
'build-container-arm',
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**'],
status: ['success', 'failure'],
},
};
[
PipelineTest,
PipelineBuildContainer(arch='amd64'),
PipelineBuildContainer(arch='arm64_v8'),
PipelineBuildContainer(arch='arm_v7'),
PipelineNotifications,
]