ci: jsonnet deploy function
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
42e78cc0dc
commit
1f3371ca47
|
@ -5,97 +5,15 @@ 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';
|
||||
local deploy = import 'lib/deploy.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',
|
||||
},
|
||||
],
|
||||
},
|
||||
deploy(
|
||||
'guacamole',
|
||||
[
|
||||
'LOCAL_DOCKER_REGISTRY',
|
||||
'REGISTRY_PASSWORD',
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'dockersock',
|
||||
temp: {},
|
||||
},
|
||||
{
|
||||
name: 'ca',
|
||||
host: {
|
||||
path: '/etc/docker/certs.d',
|
||||
},
|
||||
},
|
||||
],
|
||||
steps:[
|
||||
compose(
|
||||
std.map(
|
||||
function(secret) util.printEnv('env-guacamole', secret),
|
||||
publicSecrets,
|
||||
)
|
||||
)
|
||||
(
|
||||
images.ssh {
|
||||
settings +: {
|
||||
script: [
|
||||
'rm -f env-guacamole',
|
||||
],
|
||||
},
|
||||
},
|
||||
) {
|
||||
name: 'print env',
|
||||
},
|
||||
images.scp(
|
||||
'/stack/guacamole'
|
||||
),
|
||||
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/guacamole",
|
||||
'docker login $${LOCAL_DOCKER_REGISTRY} --username client --password "$${REGISTRY_PASSWORD}"',
|
||||
'sh pull.sh',
|
||||
'sh deploy.sh',
|
||||
]
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
}
|
||||
publicSecrets,
|
||||
secretSecrets
|
||||
),
|
||||
]
|
||||
|
|
|
@ -66,10 +66,10 @@ steps:
|
|||
image: docker:dind
|
||||
commands:
|
||||
- set -e
|
||||
- docker login $${LOCAL_DOCKER_REGISTRY} --username client --password "$${REGISTRY_PASSWORD}"
|
||||
- sh login.sh
|
||||
- sh build.sh
|
||||
- sh push.sh
|
||||
- docker logout $${LOCAL_DOCKER_REGISTRY}
|
||||
- sh logout.sh
|
||||
environment:
|
||||
LOCAL_DOCKER_REGISTRY:
|
||||
from_secret: local-docker-registry
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
local images = import 'images.libsonnet';
|
||||
local environment = import '../node_modules/@sigyl/jsonnet-drone-environment/environment.libsonnet';
|
||||
|
||||
function(secrets)
|
||||
images.docker {
|
||||
name +: 'build:',
|
||||
environment +: environment.environmentSecrets([
|
||||
'LOCAL_DOCKER_REGISTRY',
|
||||
'REGISTRY_PASSWORD',
|
||||
]),
|
||||
environment +: environment.environmentSecrets(secrets),
|
||||
volumes: [
|
||||
{
|
||||
name: 'dockersock',
|
||||
|
@ -15,9 +13,9 @@ local environment = import '../node_modules/@sigyl/jsonnet-drone-environment/env
|
|||
],
|
||||
commands: [
|
||||
'set -e',
|
||||
'docker login $${LOCAL_DOCKER_REGISTRY} --username client --password "$${REGISTRY_PASSWORD}"',
|
||||
'sh login.sh',
|
||||
'sh build.sh',
|
||||
'sh push.sh',
|
||||
'docker logout $${LOCAL_DOCKER_REGISTRY}',
|
||||
'sh logout.sh',
|
||||
],
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
local build = import 'build.libsonnet';
|
||||
local images = import 'images.libsonnet';
|
||||
local environment = import '../node_modules/@sigyl/jsonnet-drone-environment/environment.libsonnet';
|
||||
local compose = import '../node_modules/@sigyl/jsonnet-compose/compose.libsonnet';
|
||||
local util = import 'util.libsonnet';
|
||||
|
||||
function(
|
||||
name,
|
||||
buildSecrets,
|
||||
publicSecrets,
|
||||
secretSecrets
|
||||
)
|
||||
{
|
||||
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-guacamole', secret),
|
||||
publicSecrets,
|
||||
)
|
||||
)
|
||||
(
|
||||
images.ssh {
|
||||
settings +: {
|
||||
script: [
|
||||
'rm -f env-guacamole',
|
||||
],
|
||||
},
|
||||
},
|
||||
) {
|
||||
name: 'print env',
|
||||
},
|
||||
images.scp(
|
||||
'/stack/guacamole'
|
||||
),
|
||||
images.wait(15),
|
||||
build(buildSecrets),
|
||||
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/guacamole",
|
||||
'docker login $${LOCAL_DOCKER_REGISTRY} --username client --password "$${REGISTRY_PASSWORD}"',
|
||||
'sh pull.sh',
|
||||
'sh deploy.sh',
|
||||
]
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
docker login ${LOCAL_DOCKER_REGISTRY} --username client --password "${REGISTRY_PASSWORD}"
|
Loading…
Reference in New Issue