feat: registry pipeline
BREAKING CHANGE: overide parameter removed
This commit is contained in:
parent
a8cc1ce283
commit
39794f0368
|
@ -4,8 +4,6 @@ local environment = import 'lib/node_modules/@sigyl/jsonnet-drone-environment/en
|
||||||
local compose = import 'lib/node_modules/@sigyl/jsonnet-compose/compose.libsonnet';
|
local compose = import 'lib/node_modules/@sigyl/jsonnet-compose/compose.libsonnet';
|
||||||
local util = import 'lib/util.libsonnet';
|
local util = import 'lib/util.libsonnet';
|
||||||
|
|
||||||
local overide = function(overides, name)
|
|
||||||
({ [name]: {}} + overides)[name];
|
|
||||||
|
|
||||||
function(config)
|
function(config)
|
||||||
function(
|
function(
|
||||||
|
@ -15,7 +13,6 @@ function(config)
|
||||||
publicSecrets,
|
publicSecrets,
|
||||||
secretSecrets,
|
secretSecrets,
|
||||||
droneSecrets,
|
droneSecrets,
|
||||||
imageOverides = {},
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
kind: 'pipeline',
|
kind: 'pipeline',
|
||||||
|
@ -26,7 +23,7 @@ function(config)
|
||||||
depth: 0,
|
depth: 0,
|
||||||
},
|
},
|
||||||
services: [
|
services: [
|
||||||
images(config).docker(overide(imageOverides, 'docker')) {
|
images(config).docker {
|
||||||
privileged: true,
|
privileged: true,
|
||||||
volumes: [
|
volumes: [
|
||||||
{
|
{
|
||||||
|
@ -62,7 +59,7 @@ function(config)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(
|
(
|
||||||
images(config).ssh(overide(imageOverides, 'ssh')) {
|
images(config).ssh {
|
||||||
settings +: {
|
settings +: {
|
||||||
script +: [
|
script +: [
|
||||||
'rm -f env-%s' % name,
|
'rm -f env-%s' % name,
|
||||||
|
@ -72,18 +69,18 @@ function(config)
|
||||||
) {
|
) {
|
||||||
name: 'print env',
|
name: 'print env',
|
||||||
},
|
},
|
||||||
images(config).scp(overide(imageOverides, 'scp'))(
|
images(config).scp(
|
||||||
'%(root)s%(name)s' % { root: root, name: name }
|
'%(root)s%(name)s' % { root: root, name: name }
|
||||||
),
|
),
|
||||||
images(config).wait(overide(imageOverides, 'alpine'))(15),
|
images(config).wait(15),
|
||||||
build(config)(overide(imageOverides, 'docker'))(buildSecrets),
|
build(config)(buildSecrets),
|
||||||
compose(
|
compose(
|
||||||
std.map(
|
std.map(
|
||||||
function(secret) environment.envSet(secret),
|
function(secret) environment.envSet(secret),
|
||||||
publicSecrets + secretSecrets + buildSecrets,
|
publicSecrets + secretSecrets + buildSecrets,
|
||||||
),
|
),
|
||||||
)(
|
)(
|
||||||
images(config).ssh(overide(imageOverides, 'ssh')) {
|
images(config).ssh{
|
||||||
name: 'deploy',
|
name: 'deploy',
|
||||||
settings +: {
|
settings +: {
|
||||||
envs +: std.map(
|
envs +: std.map(
|
||||||
|
@ -110,5 +107,3 @@ function(config)
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,8 @@ local images = import 'images.libsonnet';
|
||||||
local environment = import 'node_modules/@sigyl/jsonnet-drone-environment/environment.libsonnet';
|
local environment = import 'node_modules/@sigyl/jsonnet-drone-environment/environment.libsonnet';
|
||||||
|
|
||||||
function(config)
|
function(config)
|
||||||
function(overide)
|
|
||||||
function(secrets)
|
function(secrets)
|
||||||
images(config).docker(overide) {
|
images(config).docker {
|
||||||
name +: 'build:',
|
name +: 'build:',
|
||||||
environment +: environment.environmentSecrets(secrets),
|
environment +: environment.environmentSecrets(secrets),
|
||||||
volumes: [
|
volumes: [
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
function(config) {
|
function (config) {
|
||||||
docker(overide): {
|
docker: {
|
||||||
name: 'docker',
|
name: 'docker',
|
||||||
image: '%(registry)sdocker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f' % config,
|
image: '%(registry)sdocker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f' % config,
|
||||||
} + overide,
|
},
|
||||||
scp(overide): function(target) {
|
scp(target): {
|
||||||
name: 'scp',
|
name: 'scp',
|
||||||
image: '%(registry)sappleboy/drone-scp:1.6.2@sha256:bd37a55f4b97e7742b0de7333669b96220b3cc422d366e1fa8c34059b736ab47' % config,
|
image: '%(registry)sappleboy/drone-scp:1.6.2@sha256:bd37a55f4b97e7742b0de7333669b96220b3cc422d366e1fa8c34059b736ab47' % config,
|
||||||
settings +: {
|
settings +: {
|
||||||
|
@ -13,8 +13,8 @@ function(config) {
|
||||||
'.',
|
'.',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
} + overide,
|
},
|
||||||
ssh(overide): {
|
ssh: {
|
||||||
image: '%(registry)sappleboy/drone-ssh:1.6.2@sha256:b801dc2cd238c192b6e99acfa7bc3f5b9a03f312bd2feb1e10b3a7a28a1b80ea' % config,
|
image: '%(registry)sappleboy/drone-ssh:1.6.2@sha256:b801dc2cd238c192b6e99acfa7bc3f5b9a03f312bd2feb1e10b3a7a28a1b80ea' % config,
|
||||||
settings +: {
|
settings +: {
|
||||||
envs: [
|
envs: [
|
||||||
|
@ -26,12 +26,12 @@ function(config) {
|
||||||
],
|
],
|
||||||
script: [],
|
script: [],
|
||||||
},
|
},
|
||||||
} + overide,
|
},
|
||||||
wait(overide): function(delay) {
|
wait(delay): {
|
||||||
image: '%(registry)salpine:3.12.0@sha256:90baa0922fe90624b05cb5766fa5da4e337921656c2f8e2b13bd3c052a0baac1' % config,
|
image: '%(registry)salpine:3.12.0@sha256:90baa0922fe90624b05cb5766fa5da4e337921656c2f8e2b13bd3c052a0baac1' % config,
|
||||||
name: 'wait',
|
name: 'wait',
|
||||||
commands: [
|
commands: [
|
||||||
'sleep %s' % delay,
|
'sleep %s' % delay,
|
||||||
],
|
],
|
||||||
} + overide
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,114 @@
|
||||||
|
local build = import 'lib/build.libsonnet';
|
||||||
|
local images = import 'lib/images.libsonnet';
|
||||||
|
local environment = import 'lib/node_modules/@sigyl/jsonnet-drone-environment/environment.libsonnet';
|
||||||
|
local compose = import 'lib/node_modules/@sigyl/jsonnet-compose/compose.libsonnet';
|
||||||
|
local util = import 'lib/util.libsonnet';
|
||||||
|
|
||||||
|
function(config)
|
||||||
|
{
|
||||||
|
kind: 'pipeline',
|
||||||
|
type: 'docker',
|
||||||
|
name: 'registry',
|
||||||
|
clone: {
|
||||||
|
disable: false,
|
||||||
|
depth: 0,
|
||||||
|
},
|
||||||
|
services: [
|
||||||
|
images(config).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:[
|
||||||
|
images(config).docker {
|
||||||
|
name +: 'pull and save docker images:',
|
||||||
|
environment +: environment
|
||||||
|
.environmentSecrets([
|
||||||
|
'REGISTRY_PASSWORD',
|
||||||
|
'REGISTRY_DOMAIN',
|
||||||
|
'REGISTRY_PORT',
|
||||||
|
]),
|
||||||
|
volumes: [
|
||||||
|
{
|
||||||
|
name: 'dockersock',
|
||||||
|
path: '/var/run',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
commands: [
|
||||||
|
'set -e',
|
||||||
|
'export REGISTRY=$${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/',
|
||||||
|
'%(script)s $${REGISTRY} $${REGISTRY_PASSWORD}' % config,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
image_pull_secrets: [
|
||||||
|
'dockerconfigjson'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
local steps = import '../steps/steps.libsonnet';
|
||||||
|
local docker = import '../docker.libsonnet';
|
||||||
|
local images = import '../images.libsonnet';
|
||||||
|
local util = import '../util.libsonnet';
|
||||||
|
|
||||||
|
function(config)
|
||||||
|
function(trigger)
|
||||||
|
[
|
||||||
|
docker(config).pipeline {
|
||||||
|
name: 'registry',
|
||||||
|
trigger: trigger,
|
||||||
|
steps: [
|
||||||
|
images(config).docker {
|
||||||
|
name +: 'build docker images:',
|
||||||
|
environment +: util.environment([
|
||||||
|
'LOCAL_DOCKER_REGISTRY',
|
||||||
|
'LOCAL_REGISTRY_PASSWORD',
|
||||||
|
]),
|
||||||
|
volumes: [
|
||||||
|
{
|
||||||
|
name: 'dockersock',
|
||||||
|
path: '/var/run',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
commands: [
|
||||||
|
'set -e',
|
||||||
|
'sleep 40',
|
||||||
|
'docker login $${LOCAL_DOCKER_REGISTRY} --username client --password "$${LOCAL_REGISTRY_PASSWORD}"',
|
||||||
|
'sh jsonnet/lib/initialise-images.sh %(registry)s' % config,
|
||||||
|
'docker logout $${LOCAL_DOCKER_REGISTRY}',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
services +: [
|
||||||
|
docker(config).service,
|
||||||
|
],
|
||||||
|
volumes +: docker(config).volumes,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
*/
|
Loading…
Reference in New Issue