drone/.drone/drone-home.jsonnet

102 lines
2.3 KiB
Plaintext

local build = import 'lib/build.libsonnet';
local images = import 'lib/images.libsonnet';
local environment = import 'node_modules/@sigyl/jsonnet-drone-environment/environment.libsonnet';
local compose = import 'node_modules/@sigyl/jsonnet-compose/compose.libsonnet';
local secretSecrets = import 'lib/secret-secrets.libsonnet';
local publicSecrets = import 'lib/public-secrets.libsonnet';
local util = import 'lib/util.libsonnet';
[
{
kind: 'pipeline',
type: 'docker',
name: 'build',
clone: {
disable: false,
depth: 0,
},
/*trigger: {
event: [
'tag',
],
},*/
services: [
images.docker {
privileged: true,
volumes: [
{
name: 'dockersock',
path: '/var/run',
},
{
name: 'ca',
path: '/etc/docker/certs.d',
},
],
},
],
volumes: [
{
name: 'dockersock',
temp: {},
},
{
name: 'ca',
host: {
path: '/etc/docker/certs.d',
},
},
],
steps:[
compose(
std.map(
function(secret) util.printEnv('env-drone', secret),
publicSecrets,
)
)
(
images.ssh {
settings +: {
script: [
'rm -f env-drone',
],
},
},
) {
name: 'print env',
},
images.scp(
'/stack/drone'
),
images.wait(15),
build,
compose(
std.map(
function(secret) environment.envSet(secret),
publicSecrets + secretSecrets,
),
)(
images.ssh {
name: 'deploy stack',
settings +: {
script +:
std.map(
function(secret)
'export %(env)s=$${%(env)s}' % {
env: environment.environment(secret)
},
secretSecrets + publicSecrets,
) +
[
'set -e',
"cd /stack/drone",
'docker login $${LOCAL_DOCKER_REGISTRY} --username client --password "$${REGISTRY_PASSWORD}"',
'sh pull.sh',
'sh deploy.sh',
]
}
},
),
],
}
]