Compare commits
No commits in common. "master" and "v0.2.0" have entirely different histories.
83
CHANGELOG.md
83
CHANGELOG.md
|
@ -2,89 +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)
|
## [0.2.0](https://sigyl.com///compare/v0.1.1...v0.2.0) (2020-09-23)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -3,15 +3,19 @@ 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';
|
|
||||||
|
|
||||||
|
local overide = function(overides, name)
|
||||||
|
({ [name]: {}} + overides)[name];
|
||||||
|
|
||||||
function(config)
|
function(config)
|
||||||
function(
|
function(
|
||||||
|
name,
|
||||||
|
root,
|
||||||
buildSecrets,
|
buildSecrets,
|
||||||
publicSecrets,
|
publicSecrets,
|
||||||
secretSecrets,
|
secretSecrets,
|
||||||
droneSecrets,
|
droneSecrets,
|
||||||
|
imageOverides = {},
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
kind: 'pipeline',
|
kind: 'pipeline',
|
||||||
|
@ -21,17 +25,65 @@ function(config)
|
||||||
disable: false,
|
disable: false,
|
||||||
depth: 0,
|
depth: 0,
|
||||||
},
|
},
|
||||||
|
services: [
|
||||||
|
images(config).docker(overide(imageOverides, '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(config).ssh(overide(imageOverides, 'ssh')) {
|
||||||
|
settings +: {
|
||||||
|
script +: [
|
||||||
|
'rm -f env-%s' % name,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
name: 'print env',
|
||||||
|
},
|
||||||
|
images(config).scp(overide(imageOverides, 'scp'))(
|
||||||
|
'%(root)s%(name)s' % { root: root, name: name }
|
||||||
),
|
),
|
||||||
|
images(config).wait(overide(imageOverides, 'alpine'))(15),
|
||||||
|
build(config)(overide(imageOverides, 'docker'))(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() {
|
images(config).ssh(overide(imageOverides, 'ssh')) {
|
||||||
name: 'deploy',
|
name: 'deploy',
|
||||||
settings +: {
|
settings +: {
|
||||||
envs +: std.map(
|
envs +: std.map(
|
||||||
|
@ -48,10 +100,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 +109,6 @@ function(config)
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
} {
|
}
|
||||||
trigger +: {
|
|
||||||
event +: [
|
|
||||||
'promote',
|
|
||||||
],
|
|
||||||
target +: [
|
|
||||||
'deploy',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
|
@ -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',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -1,24 +1,23 @@
|
||||||
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(config)
|
||||||
function(secrets)
|
function(overide)
|
||||||
images(config).docker() {
|
function(secrets)
|
||||||
name +: 'build:',
|
images(config).docker(overide) {
|
||||||
environment +: environment.environmentSecrets(secrets),
|
name +: 'build:',
|
||||||
volumes: [
|
environment +: environment.environmentSecrets(secrets),
|
||||||
{
|
volumes: [
|
||||||
name: 'dockersock',
|
{
|
||||||
path: '/var/run',
|
name: 'dockersock',
|
||||||
},
|
path: '/var/run',
|
||||||
],
|
},
|
||||||
commands: [
|
],
|
||||||
'set -e',
|
commands: [
|
||||||
'export NAME=%s' % config.name,
|
'set -e',
|
||||||
'export ROOT=%s' % config.root,
|
'sh .drone/login.sh',
|
||||||
login,
|
'sh .drone/build.sh',
|
||||||
'sh .drone/build.sh',
|
'sh .drone/push.sh',
|
||||||
'sh .drone/push.sh',
|
'sh .drone/logout.sh',
|
||||||
],
|
],
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
function (config) {
|
function(config) {
|
||||||
docker(): {
|
docker(overide): {
|
||||||
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(target = ''): {
|
scp(overide): function(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(): {
|
ssh(overide): {
|
||||||
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,5 +26,12 @@ function (config) {
|
||||||
],
|
],
|
||||||
script: [],
|
script: [],
|
||||||
},
|
},
|
||||||
},
|
} + overide,
|
||||||
|
wait(overide): function(delay) {
|
||||||
|
image: '%(registry)salpine:3.12.0@sha256:90baa0922fe90624b05cb5766fa5da4e337921656c2f8e2b13bd3c052a0baac1',
|
||||||
|
name: 'wait',
|
||||||
|
commands: [
|
||||||
|
'sleep %s' % delay,
|
||||||
|
],
|
||||||
|
} + overide
|
||||||
}
|
}
|
|
@ -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
|
|
||||||
|||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@sigyl/jsonnet-drone",
|
"name": "@sigyl/jsonnet-drone",
|
||||||
"main": "deploy.libsonnet",
|
"main": "deploy.libsonnet",
|
||||||
"version": "1.0.0",
|
"version": "0.2.0",
|
||||||
"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",
|
||||||
|
|
|
@ -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',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -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',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
121
save.libsonnet
121
save.libsonnet
|
@ -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',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
Loading…
Reference in New Issue