2020-08-15 09:43:20 +00:00
|
|
|
local build = import 'lib/build.libsonnet';
|
|
|
|
local images = import 'lib/images.libsonnet';
|
2020-08-19 20:12:35 +00:00
|
|
|
local environment = import 'lib/node_modules/@sigyl/jsonnet-drone-environment/environment.libsonnet';
|
2020-08-19 20:01:46 +00:00
|
|
|
local compose = import 'lib/node_modules/@sigyl/jsonnet-compose/compose.libsonnet';
|
2020-08-15 09:43:20 +00:00
|
|
|
local util = import 'lib/util.libsonnet';
|
|
|
|
|
|
|
|
function(
|
|
|
|
name,
|
|
|
|
root,
|
|
|
|
buildSecrets,
|
|
|
|
publicSecrets,
|
2020-08-27 20:11:22 +00:00
|
|
|
secretSecrets,
|
|
|
|
droneSecrets
|
2020-08-15 09:43:20 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
kind: 'pipeline',
|
|
|
|
type: 'docker',
|
|
|
|
name: 'deploy',
|
|
|
|
clone: {
|
|
|
|
disable: false,
|
|
|
|
depth: 0,
|
|
|
|
},
|
|
|
|
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-%s' % name, secret),
|
2020-08-19 20:31:03 +00:00
|
|
|
buildSecrets +
|
|
|
|
publicSecrets +
|
|
|
|
secretSecrets
|
2020-08-15 09:43:20 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
(
|
|
|
|
images.ssh {
|
|
|
|
settings +: {
|
|
|
|
script: [
|
|
|
|
'rm -f env-%s' % name,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
) {
|
|
|
|
name: 'print env',
|
|
|
|
},
|
|
|
|
images.scp(
|
|
|
|
'%(root)s%(name)s' % { root: root, name: name }
|
|
|
|
),
|
|
|
|
images.wait(15),
|
2020-08-27 21:18:55 +00:00
|
|
|
build(buildSecrets),
|
2020-08-15 09:43:20 +00:00
|
|
|
compose(
|
|
|
|
std.map(
|
|
|
|
function(secret) environment.envSet(secret),
|
2020-08-27 21:00:02 +00:00
|
|
|
publicSecrets + secretSecrets + buildSecrets,
|
2020-08-15 09:43:20 +00:00
|
|
|
),
|
|
|
|
)(
|
|
|
|
images.ssh {
|
|
|
|
name: 'deploy',
|
|
|
|
settings +: {
|
2020-08-27 22:04:27 +00:00
|
|
|
envs +: std.map(
|
|
|
|
environment.env,
|
|
|
|
droneSecrets,
|
|
|
|
),
|
2020-08-15 09:43:20 +00:00
|
|
|
script +:
|
|
|
|
std.map(
|
|
|
|
function(secret)
|
|
|
|
'export %(env)s=$${%(env)s}' % {
|
|
|
|
env: environment.environment(secret)
|
|
|
|
},
|
2020-08-27 20:11:22 +00:00
|
|
|
secretSecrets + publicSecrets + buildSecrets + droneSecrets,
|
2020-08-15 09:43:20 +00:00
|
|
|
) +
|
|
|
|
[
|
|
|
|
'set -e',
|
|
|
|
'cd %(root)s%(name)s' % { root: root, name: name },
|
|
|
|
'sh .drone/login.sh',
|
|
|
|
'sh .drone/pull.sh',
|
|
|
|
'sh .drone/deploy.sh',
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
|