Compare commits

..

54 Commits

Author SHA1 Message Date
Giles Bradshaw e6f6783df2 chore(release): 1.0.0 2020-10-24 12:16:25 +01:00
Giles Bradshaw 2342b9a6fc feat: destination_registry parameter for save 2020-10-24 12:13:30 +01:00
Giles Bradshaw 9a5228e4be chore(release): 0.4.6 2020-10-23 20:20:47 +01:00
Giles Bradshaw 22d87f9487 feat:drone-images 2020-10-23 20:20:40 +01:00
Giles Bradshaw da35cfd775 chore(release): 0.4.5 2020-10-23 09:18:57 +01:00
Giles Bradshaw 3f87049590 fix: sve to save 2020-10-23 09:18:51 +01:00
Giles Bradshaw 314f2220e8 chore(release): 0.4.4 2020-10-23 09:04:53 +01:00
Giles Bradshaw cdc3e811f4 fix:minor 2020-10-23 09:04:48 +01:00
Giles Bradshaw 323b41a667 chore(release): 0.4.3 2020-10-23 08:56:54 +01:00
Giles Bradshaw b2e38605fd fix:step names too long 2020-10-23 08:56:44 +01:00
Giles Bradshaw 708eb3f32d chore(release): 0.4.2 2020-10-23 01:04:10 +01:00
Giles Bradshaw fd13fe0e03 feat: print, build, save
BREAKING_CHANGE: function parameters chaged
2020-10-23 01:03:07 +01:00
Giles Bradshaw 0aaec64873 chore(release): 0.4.1 2020-10-22 13:10:46 +01:00
Giles Bradshaw cce93724fe feat: docker service uses daemon.json from host 2020-10-22 13:10:13 +01:00
Giles Bradshaw 3b1ce6ed9f chore(release): 0.4.0 2020-10-06 19:39:29 +01:00
Giles Bradshaw 7b42336408 fix: registry_password in quotes
Copes with passwords containing spaces.
2020-10-06 19:38:37 +01:00
Giles Bradshaw 0000ce5a12 fix:version 2020-09-24 14:53:38 +01:00
Giles Bradshaw 412425fadb chore(release): 0.3.1 2020-09-24 14:52:45 +01:00
Giles Bradshaw cded64c558 fix: allow configured secrets to registry 2020-09-24 14:52:21 +01:00
Giles Bradshaw 6902ebf846 Merge branch 'develop' 2020-09-24 14:03:30 +01:00
Giles Bradshaw 75be869735 fix: version in package.json
not getting updated in release..
2020-09-24 14:01:35 +01:00
Giles Bradshaw dadd5c75ee chore(release): 0.2.2 2020-09-24 13:51:18 +01:00
Giles Bradshaw 2cfb3d7b3a chore(release): 0.3.0 2020-09-24 13:49:26 +01:00
Giles Bradshaw 39794f0368 feat: registry pipeline
BREAKING CHANGE: overide parameter removed
2020-09-24 13:48:43 +01:00
Giles a8cc1ce283 chore(release): 0.2.1 2020-09-23 20:23:18 +01:00
Giles b4a5dc8bb6 fix: wait image 2020-09-23 20:23:04 +01:00
Giles e9ef78bed4 chore(release): 0.2.0 2020-09-23 20:00:01 +01:00
Giles 527aa4128d feat: configured
BREAKING CHANGE: new api config function
2020-09-23 19:58:49 +01:00
Giles Bradshaw ebd87a2e0e chore(release): 0.1.1 2020-09-22 12:29:43 +01:00
Giles Bradshaw 354341178d fix: no longer settings for ssh and scp
These images get their settings from default environm,ent names
2020-09-22 12:29:01 +01:00
Giles Bradshaw c846f50184 chore(release): 0.1.0 2020-08-28 12:23:51 +01:00
Giles Bradshaw dca47ea050 feat: make images overideable
BREAKING CHANGE:
2020-08-28 12:22:28 +01:00
Giles Bradshaw 3055b928e9 chore(release): 0.0.14 2020-08-27 23:04:35 +01:00
Giles Bradshaw 2bb298ab12 fix: envs in wrong place 2020-08-27 23:04:27 +01:00
Giles Bradshaw 776a7ab96f chore(release): 0.0.13 2020-08-27 22:52:36 +01:00
Giles Bradshaw 2ee96ed5ad fix: dronesecrets should only be env for deploy 2020-08-27 22:52:14 +01:00
Giles Bradshaw 719a9b12c2 chore(release): 0.0.12 2020-08-27 22:19:20 +01:00
Giles Bradshaw 9f162c47aa fix: build with drone secrets 2020-08-27 22:18:55 +01:00
Giles Bradshaw be0a4654c7 chore(release): 0.0.11 2020-08-27 22:00:27 +01:00
Giles Bradshaw 9ca4e4c17b fix: still getting build and drone secrets right ..., 2020-08-27 22:00:02 +01:00
Giles Bradshaw f656137a17 chore(release): 0.0.10 2020-08-27 21:27:15 +01:00
Giles Bradshaw 9e3a3b686e fix: drone-secrets not build-secrets 2020-08-27 21:26:45 +01:00
Giles Bradshaw a6c7147d1d chore(release): 0.0.9 2020-08-27 21:11:41 +01:00
Giles Bradshaw d38db6f40f feat: added drone secrets 2020-08-27 21:11:22 +01:00
Giles Bradshaw 8286a17f17 chore(release): 0.0.8 2020-08-26 22:17:14 +01:00
Giles Bradshaw c7f3785432 ci: add register pipeline 2020-08-26 22:16:45 +01:00
Giles ac4b8b6699 chore(release): 0.0.7 2020-08-20 11:11:35 +01:00
Giles 336e775709 fix: deploy getting all buildSecrets 2020-08-20 11:11:18 +01:00
Giles dfc679747a chore(release): 0.0.6 2020-08-20 10:58:56 +01:00
Giles a5910ac334 fix: export buildSecrets for deploy 2020-08-20 10:58:28 +01:00
Giles 41958501cf chore(release): 0.0.5 2020-08-19 21:31:35 +01:00
Giles 721b63fec6 feat: print all secrets 2020-08-19 21:31:03 +01:00
Giles 01b781e24e chore(release): 0.0.4 2020-08-19 21:12:53 +01:00
Giles 3c31ed67b5 fix: wrong path 2020-08-19 21:12:35 +01:00
14 changed files with 713 additions and 1731 deletions

View File

@ -2,6 +2,190 @@
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)
### Features
* added drone secrets ([d38db6f](https://sigyl.com///commit/d38db6f40fa59cc12d36dba0a88166f06fe90569))
### [0.0.8](https://sigyl.com///compare/v0.0.7...v0.0.8) (2020-08-26)
### [0.0.7](https://sigyl.com///compare/v0.0.6...v0.0.7) (2020-08-20)
### Bug Fixes
* deploy getting all buildSecrets ([336e775](https://sigyl.com///commit/336e7757091dfe2b3e0d26c38264eddfbd5ccbf9))
### [0.0.6](https://sigyl.com///compare/v0.0.5...v0.0.6) (2020-08-20)
### Bug Fixes
* export buildSecrets for deploy ([a5910ac](https://sigyl.com///commit/a5910ac334a37079fb2f1b32f236e7b93224b929))
### [0.0.5](https://sigyl.com///compare/v0.0.4...v0.0.5) (2020-08-19)
### Features
* print all secrets ([721b63f](https://sigyl.com///commit/721b63fec67cd877d1969e6605178b64cd6e43e2))
### [0.0.4](https://sigyl.com///compare/v0.0.3...v0.0.4) (2020-08-19)
### Bug Fixes
* wrong path ([3c31ed6](https://sigyl.com///commit/3c31ed67b5ae4ed2d96aa0aa4109c3705c054ece))
### [0.0.3](https://sigyl.com///compare/v0.0.2...v0.0.3) (2020-08-19)

70
build.libsonnet Normal file
View File

@ -0,0 +1,70 @@
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

@ -1,102 +1,71 @@
local build = import 'lib/build.libsonnet';
local images = import 'lib/images.libsonnet';
local environment = import '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 util = import 'lib/util.libsonnet';
local login = import 'lib/login.libsonnet';
function(
name,
root,
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',
},
],
function(config)
function(
buildSecrets,
publicSecrets,
secretSecrets,
droneSecrets,
)
{
kind: 'pipeline',
type: 'docker',
name: 'deploy',
clone: {
disable: false,
depth: 0,
},
],
volumes: [
{
name: 'dockersock',
temp: {},
},
{
name: 'ca',
host: {
path: '/etc/docker/certs.d',
},
},
],
steps:[
compose(
std.map(
function(secret) util.printEnv('env-%s' % name, secret),
publicSecrets,
)
)
(
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(buildSecrets),
compose(
std.map(
function(secret) environment.envSet(secret),
publicSecrets + secretSecrets,
steps:[
images(config).scp(
'/%(root)s/%(name)s' % config
),
)(
images.ssh {
name: 'deploy',
settings +: {
script +:
std.map(
function(secret)
'export %(env)s=$${%(env)s}' % {
env: environment.environment(secret)
},
secretSecrets + publicSecrets,
) +
[
'set -e',
'cd %(root)s%(name)s' % { root: root, name: name },
'sh .drone/login.sh',
'sh .drone/pull.sh',
'sh .drone/deploy.sh',
]
}
},
),
],
compose(
std.map(
function(secret) environment.envSet(secret),
publicSecrets + secretSecrets + buildSecrets,
),
)(
images(config).ssh() {
name: 'deploy',
settings +: {
envs +: std.map(
environment.env,
droneSecrets,
),
script +:
std.map(
function(secret)
'export %(env)s=$${%(env)s}' % {
env: environment.environment(secret)
},
secretSecrets + publicSecrets + buildSecrets + droneSecrets,
) +
[
'set -e',
'export NAME=%s' % config.name,
'export ROOT=%s' % config.root,
'cd /%(root)s/%(name)s' % config,
login,
'sh .drone/pull.sh',
'sh .drone/deploy.sh',
]
}
},
),
],
} {
trigger +: {
event +: [
'promote',
],
target +: [
'deploy',
],
},
}

63
drone-images.libsonnet Normal file
View File

@ -0,0 +1,63 @@
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,21 +1,24 @@
local images = import 'images.libsonnet';
local environment = import 'node_modules/@sigyl/jsonnet-drone-environment/environment.libsonnet';
local login = import 'login.libsonnet';
function(secrets)
images.docker {
name +: 'build:',
environment +: environment.environmentSecrets(secrets),
volumes: [
{
name: 'dockersock',
path: '/var/run',
},
],
commands: [
'set -e',
'sh .drone/login.sh',
'sh .drone/build.sh',
'sh .drone/push.sh',
'sh .drone/logout.sh',
],
}
function(config)
function(secrets)
images(config).docker() {
name +: 'build:',
environment +: environment.environmentSecrets(secrets),
volumes: [
{
name: 'dockersock',
path: '/var/run',
},
],
commands: [
'set -e',
'export NAME=%s' % config.name,
'export ROOT=%s' % config.root,
login,
'sh .drone/build.sh',
'sh .drone/push.sh',
],
}

View File

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

15
lib/login.libsonnet Normal file
View File

@ -0,0 +1,15 @@
|||
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
|||

View File

@ -1,11 +0,0 @@
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",
"main": "deploy.libsonnet",
"version": "0.0.3",
"version": "1.0.0",
"description": "jsonnet to build and deploy with drone",
"scripts": {
"publish-npm": "git push --follow-tags origin master && npm publish",

53
print.libsonnet Normal file
View File

@ -0,0 +1,53 @@
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',
],
},
}

15
register.libsonnet Normal file
View File

@ -0,0 +1,15 @@
{
kind: 'pipeline',
type: 'docker',
name: 'register',
clone: {
disable: true,
},
trigger +: {
event +: {
exclude: [
'promote',
],
},
},
}

100
registry.libsonnet Normal file
View File

@ -0,0 +1,100 @@
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',
],
},
}

121
save.libsonnet Normal file
View File

@ -0,0 +1,121 @@
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',
],
},
}

1592
yarn.lock

File diff suppressed because it is too large Load Diff