Compare commits

..

No commits in common. "master" and "v0.0.9" have entirely different histories.

14 changed files with 1734 additions and 661 deletions

View File

@ -2,153 +2,6 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [1.0.0](https://sigyl.com///compare/v0.4.6...v1.0.0) (2020-10-24)
### Features
* destination_registry parameter for save ([2342b9a](https://sigyl.com///commit/2342b9a6fc1f7927ba93938b0233092c1fe1f844))
### [0.4.6](https://sigyl.com///compare/v0.4.5...v0.4.6) (2020-10-23)
### [0.4.5](https://sigyl.com///compare/v0.4.4...v0.4.5) (2020-10-23)
### Bug Fixes
* sve to save ([3f87049](https://sigyl.com///commit/3f87049590036054844998b5b5e93c58757961af))
### [0.4.4](https://sigyl.com///compare/v0.4.3...v0.4.4) (2020-10-23)
### [0.4.3](https://sigyl.com///compare/v0.4.2...v0.4.3) (2020-10-23)
### [0.4.2](https://sigyl.com///compare/v0.4.1...v0.4.2) (2020-10-23)
### Features
* print, build, save ([fd13fe0](https://sigyl.com///commit/fd13fe0e03711f0a67be11f72736b056ab9bb4c4))
### [0.4.1](https://sigyl.com///compare/v0.4.0...v0.4.1) (2020-10-22)
### Features
* docker service uses daemon.json from host ([cce9372](https://sigyl.com///commit/cce93724fee636e32846870a8fe3e43f60d22c84))
## [0.4.0](https://sigyl.com///compare/v0.1.1...v0.4.0) (2020-10-06)
### ⚠ BREAKING CHANGES
* overide parameter removed
* new api config function
### Features
* configured ([527aa41](https://sigyl.com///commit/527aa4128da897dd0690ee16fa2627ab67a927a7))
* registry pipeline ([39794f0](https://sigyl.com///commit/39794f03688f9fcdb37abf1937fe0738e41b1700))
### Bug Fixes
* allow configured secrets to registry ([cded64c](https://sigyl.com///commit/cded64c558de384e182cdfce6def20035788c1d8))
* registry_password in quotes ([7b42336](https://sigyl.com///commit/7b423364086d14b7ad5b3ea02652670bf8929bd4))
* version in package.json ([75be869](https://sigyl.com///commit/75be869735874aac89be358f5f48b0ca1ad98ccb))
* wait image ([b4a5dc8](https://sigyl.com///commit/b4a5dc8bb681fc9d9e5303a6bfff9221c30a141e))
### [0.3.1](https://sigyl.com///compare/v0.2.2...v0.3.1) (2020-09-24)
### Bug Fixes
* allow configured secrets to registry ([cded64c](https://sigyl.com///commit/cded64c558de384e182cdfce6def20035788c1d8))
* version in package.json ([75be869](https://sigyl.com///commit/75be869735874aac89be358f5f48b0ca1ad98ccb))
### [0.2.2](https://sigyl.com///compare/v0.3.0...v0.2.2) (2020-09-24)
## [0.3.0](https://sigyl.com///compare/v0.2.1...v0.3.0) (2020-09-24)
### ⚠ BREAKING CHANGES
* overide parameter removed
### Features
* registry pipeline ([39794f0](https://sigyl.com///commit/39794f03688f9fcdb37abf1937fe0738e41b1700))
### [0.2.1](https://sigyl.com///compare/v0.2.0...v0.2.1) (2020-09-23)
### Bug Fixes
* wait image ([b4a5dc8](https://sigyl.com///commit/b4a5dc8bb681fc9d9e5303a6bfff9221c30a141e))
## [0.2.0](https://sigyl.com///compare/v0.1.1...v0.2.0) (2020-09-23)
### ⚠ BREAKING CHANGES
* new api config function
### Features
* configured ([527aa41](https://sigyl.com///commit/527aa4128da897dd0690ee16fa2627ab67a927a7))
### [0.1.1](https://sigyl.com///compare/v0.1.0...v0.1.1) (2020-09-22)
### Bug Fixes
* no longer settings for ssh and scp ([3543411](https://sigyl.com///commit/354341178d14c0631be9d33af00bc2ecfa039723))
## [0.1.0](https://sigyl.com///compare/v0.0.14...v0.1.0) (2020-08-28)
### ⚠ BREAKING CHANGES
*
### Features
* make images overideable ([dca47ea](https://sigyl.com///commit/dca47ea05016d374dcdc8151373889788b3b91e2))
### [0.0.14](https://sigyl.com///compare/v0.0.13...v0.0.14) (2020-08-27)
### Bug Fixes
* envs in wrong place ([2bb298a](https://sigyl.com///commit/2bb298ab12d668d1d6d6dbb34a0cdcd09bbbcdcb))
### [0.0.13](https://sigyl.com///compare/v0.0.12...v0.0.13) (2020-08-27)
### Bug Fixes
* dronesecrets should only be env for deploy ([2ee96ed](https://sigyl.com///commit/2ee96ed5adc2b14f136128ad4588ba15a3d4fba8))
### [0.0.12](https://sigyl.com///compare/v0.0.11...v0.0.12) (2020-08-27)
### Bug Fixes
* build with drone secrets ([9f162c4](https://sigyl.com///commit/9f162c47aadbdf438d6bcaf6801be232a608963c))
### [0.0.11](https://sigyl.com///compare/v0.0.10...v0.0.11) (2020-08-27)
### Bug Fixes
* still getting build and drone secrets right ..., ([9ca4e4c](https://sigyl.com///commit/9ca4e4c17bdeb6602a7849ae6a58b055214cef2e))
### [0.0.10](https://sigyl.com///compare/v0.0.9...v0.0.10) (2020-08-27)
### Bug Fixes
* drone-secrets not build-secrets ([9e3a3b6](https://sigyl.com///commit/9e3a3b686ea813f92a9ff2ca23f0efaae4127142))
### [0.0.9](https://sigyl.com///compare/v0.0.8...v0.0.9) (2020-08-27) ### [0.0.9](https://sigyl.com///compare/v0.0.8...v0.0.9) (2020-08-27)

View File

@ -1,70 +0,0 @@
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';
local login = import 'lib/login.libsonnet';
function(config)
function(
buildSecrets,
)
{
kind: 'pipeline',
type: 'docker',
name: 'build',
clone: {
disable: false,
depth: 0,
},
services: [
images(config).docker() {
privileged: true,
volumes: [
{
name: 'dockersock',
path: '/var/run',
},
{
name: 'ca',
path: '/etc/docker/certs.d',
},
{
name: 'daemonjson',
path: '/etc/docker/daemon.json',
},
],
},
],
volumes: [
{
name: 'dockersock',
temp: {},
},
{
name: 'ca',
host: {
path: '/etc/docker/certs.d',
},
},
{
name: 'daemonjson',
host: {
path: '/etc/docker/daemon.json',
},
},
],
steps:[
build(config)(buildSecrets),
],
} {
trigger +: {
event +: [
'promote',
],
target +: [
'build',
],
},
}

View File

@ -3,16 +3,15 @@ local images = import 'lib/images.libsonnet';
local environment = import 'lib/node_modules/@sigyl/jsonnet-drone-environment/environment.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 compose = import 'lib/node_modules/@sigyl/jsonnet-compose/compose.libsonnet';
local util = import 'lib/util.libsonnet'; local util = import 'lib/util.libsonnet';
local login = import 'lib/login.libsonnet';
function(
function(config) name,
function( root,
buildSecrets, buildSecrets,
publicSecrets, publicSecrets,
secretSecrets, secretSecrets,
droneSecrets, droneSecrets
) )
{ {
kind: 'pipeline', kind: 'pipeline',
type: 'docker', type: 'docker',
@ -21,23 +20,67 @@ function(config)
disable: false, disable: false,
depth: 0, 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:[ steps:[
images(config).scp( compose(
'/%(root)s/%(name)s' % config std.map(
function(secret) util.printEnv('env-%s' % name, secret),
buildSecrets +
publicSecrets +
secretSecrets
)
)
(
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),
build(droneSecrets),
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() { images.ssh {
name: 'deploy', name: 'deploy',
settings +: { settings +: {
envs +: std.map(
environment.env,
droneSecrets,
),
script +: script +:
std.map( std.map(
function(secret) function(secret)
@ -48,10 +91,8 @@ function(config)
) + ) +
[ [
'set -e', 'set -e',
'export NAME=%s' % config.name, 'cd %(root)s%(name)s' % { root: root, name: name },
'export ROOT=%s' % config.root, 'sh .drone/login.sh',
'cd /%(root)s/%(name)s' % config,
login,
'sh .drone/pull.sh', 'sh .drone/pull.sh',
'sh .drone/deploy.sh', 'sh .drone/deploy.sh',
] ]
@ -59,13 +100,6 @@ function(config)
}, },
), ),
], ],
} {
trigger +: {
event +: [
'promote',
],
target +: [
'deploy',
],
},
} }

View File

@ -1,63 +0,0 @@
local images = import 'lib/images.libsonnet';
function(config)
{
kind: 'pipeline',
type: 'docker',
name: 'drone-images',
clone: {
disable: true,
},
steps: [
images(config).ssh() {
settings +: {
script +: [
'mkdir -p /%(root)s/.images/%(name)s/drone-images' % config,
'rm -f /%(root)s/.images/%(name)s/drone-images/*.*' % config,
],
},
}
{
name: 'mkdir',
},
] +
std.map(
function(key)
images(config).ssh() {
settings +: {
envs +: [
'registry_domain',
'registry_port',
'registry_password',
],
script +: [
'docker pull %s' % images(config)[key]().image,
'docker save %(image)s -o /%(root)s/.images/%(name)s/drone-images/%(key)s.tar' % (
config +
{
image: images(config)[key]().image,
key: key,
}
),
'echo "docker load %(key)s.tar" >> /%(root)s/.images/%(name)s/drone-images/load.sh' % (
config +
{
key: key,
}
)
],
},
name: key,
},
std.objectFields(images(config)),
)
} {
trigger +: {
event +: [
'promote',
],
target +: [
'drone-images',
],
},
}

View File

@ -1,10 +1,8 @@
local images = import 'images.libsonnet'; 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';
local login = import 'login.libsonnet';
function(config) function(secrets)
function(secrets) images.docker {
images(config).docker() {
name +: 'build:', name +: 'build:',
environment +: environment.environmentSecrets(secrets), environment +: environment.environmentSecrets(secrets),
volumes: [ volumes: [
@ -15,10 +13,9 @@ function(config)
], ],
commands: [ commands: [
'set -e', 'set -e',
'export NAME=%s' % config.name, 'sh .drone/login.sh',
'export ROOT=%s' % config.root,
login,
'sh .drone/build.sh', 'sh .drone/build.sh',
'sh .drone/push.sh', 'sh .drone/push.sh',
'sh .drone/logout.sh',
], ],
} }

View File

@ -1,11 +1,12 @@
function (config) { local settings = import 'settings.libsonnet';
docker(): { {
docker: {
name: 'docker', name: 'docker',
image: '%(registry)sdocker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f' % config, image: 'docker:dind',
}, },
scp(target = ''): { scp(target): settings.ssh {
name: 'scp', name: 'scp',
image: '%(registry)sappleboy/drone-scp:1.6.2@sha256:bd37a55f4b97e7742b0de7333669b96220b3cc422d366e1fa8c34059b736ab47' % config, image: 'appleboy/drone-scp:1.6.2',
settings +: { settings +: {
command_timeout: '2m', command_timeout: '2m',
target: target, target: target,
@ -14,8 +15,8 @@ function (config) {
], ],
}, },
}, },
ssh(): { ssh: settings.ssh {
image: '%(registry)sappleboy/drone-ssh:1.6.2@sha256:b801dc2cd238c192b6e99acfa7bc3f5b9a03f312bd2feb1e10b3a7a28a1b80ea' % config, image: 'appleboy/drone-ssh:1.6.2',
settings +: { settings +: {
envs: [ envs: [
'drone_tag', 'drone_tag',
@ -27,4 +28,11 @@ function (config) {
script: [], script: [],
}, },
}, },
wait(delay): {
image: 'alpine',
name: 'wait',
commands: [
'sleep %s' % delay,
],
}
} }

View File

@ -1,15 +0,0 @@
|||
n=0
while :
do
docker login $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/ --username client --password "$${REGISTRY_PASSWORD}" \\
&& break # substitute your command here
n=$((n+1))
if [ $n -ge 10 ]; then
echo "login failed"
exit 1
fi
echo "retrying login..$n"
sleep 5
done
|||

11
lib/settings.libsonnet Normal file
View File

@ -0,0 +1,11 @@
local environment = import 'node_modules/@sigyl/jsonnet-drone-environment/environment.libsonnet';
{
ssh: {
settings +: {
host: environment.fromSecret('ssh-host'),
port: environment.fromSecret('ssh-port'),
username: environment.fromSecret('ssh-user'),
key: environment.fromSecret('ssh-key'),
},
},
}

View File

@ -1,7 +1,7 @@
{ {
"name": "@sigyl/jsonnet-drone", "name": "@sigyl/jsonnet-drone",
"main": "deploy.libsonnet", "main": "deploy.libsonnet",
"version": "1.0.0", "version": "0.0.9",
"description": "jsonnet to build and deploy with drone", "description": "jsonnet to build and deploy with drone",
"scripts": { "scripts": {
"publish-npm": "git push --follow-tags origin master && npm publish", "publish-npm": "git push --follow-tags origin master && npm publish",

View File

@ -1,53 +0,0 @@
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';
local login = import 'lib/login.libsonnet';
function(config)
function(
buildSecrets,
publicSecrets,
secretSecrets,
)
{
kind: 'pipeline',
type: 'docker',
name: 'print',
clone: {
disable: false,
depth: 0,
},
steps:[
compose(
std.map(
function(secret) util.printEnv('env-%s' % config.name, secret),
buildSecrets +
publicSecrets +
secretSecrets
)
)
(
images(config).ssh() {
settings +: {
script +: [
'rm -f env-%s' % config.name,
],
},
},
) {
name: 'print env',
},
],
} {
trigger +: {
event +: [
'promote',
],
target +: [
'print',
],
},
}

View File

@ -1,100 +0,0 @@
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';
local login = import 'lib/login.libsonnet';
function(config)
{
kind: 'pipeline',
type: 'docker',
name: 'registry',
clone: {
disable: true,
},
services: [
images(config).docker() {
privileged: true,
volumes: [
{
name: 'dockersock',
path: '/var/run',
},
{
name: 'ca',
path: '/etc/docker/certs.d',
},
{
name: 'daemonjson',
path: '/etc/docker/daemon.json',
},
],
},
],
volumes: [
{
name: 'dockersock',
temp: {},
},
{
name: 'ca',
host: {
path: '/etc/docker/certs.d',
},
},
{
name: 'daemonjson',
host: {
path: '/etc/docker/daemon.json',
},
},
],
steps:
std.map(
function(def) images(config).docker() {
name: def.save,
environment +: environment
.environmentSecrets(config.secrets),
volumes: [
{
name: 'dockersock',
path: '/var/run',
},
],
commands: [
'set -e',
login,
|||
n=0
while :
do
docker pull %(load)s \\
&& docker tag %(load)s $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/%(root)s/%(name)s/%(save)s \\
&& docker push $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/%(root)s/%(name)s/%(save)s && break
n=$((n+1))
if [ $n -ge 10 ]; then
echo "initialise failed"
exit 1
fi
echo "retrying..$n"
sleep 5
done
||| % (config + def),
],
},
config.images,
),
image_pull_secrets: [
'dockerconfigjson'
]
} {
trigger +: {
event +: [
'promote',
],
target +: [
'registry',
],
},
}

View File

@ -1,121 +0,0 @@
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';
local login = import 'lib/login.libsonnet';
function(config)
function(
defs,
builtDefs,
)
{
kind: 'pipeline',
type: 'docker',
name: 'save',
clone: {
disable: true,
},
steps: [
images(config).ssh() {
settings +: {
script +: [
'mkdir -p /%(root)s/.images/%(name)s/built' % config,
'rm -f /%(root)s/.images/%(name)s/*.*' % config,
'rm -f /%(root)s/.images/%(name)s/built/*.*' % config,
],
},
}
{
name: 'mkdir',
},
] +
std.map(
function(def)
images(config).ssh() {
settings +: {
envs +: [
'registry_domain',
'registry_port',
'registry_password',
'destination_registry'
],
script +: [
login,
'docker pull $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/%(root)s/%(name)s/%(save)s' % (config + def),
'docker save $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/%(root)s/%(name)s/%(save)s -o /%(root)s/.images/%(name)s/%(out)s.tar' % (
config + def +
{
out: std.strReplace(def.save, '/', '_'),
}
),
'echo "docker load < %(out)s.tar" >> /%(root)s/.images/%(name)s/load.sh' % (
config + {
out: std.strReplace(def.save, '/', '_'),
}
),
'echo "docker tag $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/%(root)s/%(name)s/%(pull)s $${DESTINATION_REGISTRY}/%(root)s/%(name)s/%(pull)s" >> /%(root)s/.images/%(name)s/load.sh' % (
config +
{
pull: def.save,
}
),
],
},
} +
{
name: def.save,
},
defs
) +
std.map(
function(def)
images(config).ssh() {
settings +: {
envs +: [
'registry_domain',
'registry_port',
'registry_password',
'destination_registry',
],
script +: [
login,
'docker pull $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/%(root)s/%(name)s/%(save)s' % (config + { save: def }),
'docker save $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/%(root)s/%(name)s/%(save)s -o /%(root)s/.images/%(name)s/built/%(out)s.tar' % (
config +
{
save: def,
out: std.strReplace(def, '/', '_'),
}
),
'echo "docker load %(out)s.tar" >> /%(root)s/.images/%(name)s/built/load.sh' % (
config + {
out: std.strReplace(def, '/', '_'),
}
),
'echo "docker tag $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/%(root)s/%(name)s/%(pull)s ${DESINATION_REGISTRY}/%(root)s/%(name)s/%(pull)s" >> /%(root)s/.images/%(name)s/built/load.sh' % (
config +
{
pull: def,
}
),
],
},
} +
{
name: def,
},
builtDefs
),
} {
trigger +: {
event +: [
'promote',
],
target +: [
'save',
],
},
}

Binary file not shown.

1592
yarn.lock Normal file

File diff suppressed because it is too large Load Diff