Compare commits
44 Commits
Author | SHA1 | Date |
---|---|---|
Giles Bradshaw | e6f6783df2 | |
Giles Bradshaw | 2342b9a6fc | |
Giles Bradshaw | 9a5228e4be | |
Giles Bradshaw | 22d87f9487 | |
Giles Bradshaw | da35cfd775 | |
Giles Bradshaw | 3f87049590 | |
Giles Bradshaw | 314f2220e8 | |
Giles Bradshaw | cdc3e811f4 | |
Giles Bradshaw | 323b41a667 | |
Giles Bradshaw | b2e38605fd | |
Giles Bradshaw | 708eb3f32d | |
Giles Bradshaw | fd13fe0e03 | |
Giles Bradshaw | 0aaec64873 | |
Giles Bradshaw | cce93724fe | |
Giles Bradshaw | 3b1ce6ed9f | |
Giles Bradshaw | 7b42336408 | |
Giles Bradshaw | 0000ce5a12 | |
Giles Bradshaw | 412425fadb | |
Giles Bradshaw | cded64c558 | |
Giles Bradshaw | 6902ebf846 | |
Giles Bradshaw | 75be869735 | |
Giles Bradshaw | dadd5c75ee | |
Giles Bradshaw | 2cfb3d7b3a | |
Giles Bradshaw | 39794f0368 | |
Giles | a8cc1ce283 | |
Giles | b4a5dc8bb6 | |
Giles | e9ef78bed4 | |
Giles | 527aa4128d | |
Giles Bradshaw | ebd87a2e0e | |
Giles Bradshaw | 354341178d | |
Giles Bradshaw | c846f50184 | |
Giles Bradshaw | dca47ea050 | |
Giles Bradshaw | 3055b928e9 | |
Giles Bradshaw | 2bb298ab12 | |
Giles Bradshaw | 776a7ab96f | |
Giles Bradshaw | 2ee96ed5ad | |
Giles Bradshaw | 719a9b12c2 | |
Giles Bradshaw | 9f162c47aa | |
Giles Bradshaw | be0a4654c7 | |
Giles Bradshaw | 9ca4e4c17b | |
Giles Bradshaw | f656137a17 | |
Giles Bradshaw | 9e3a3b686e | |
Giles Bradshaw | a6c7147d1d | |
Giles Bradshaw | d38db6f40f |
154
CHANGELOG.md
154
CHANGELOG.md
|
@ -2,6 +2,160 @@
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
|
### 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.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)
|
### [0.0.7](https://sigyl.com///compare/v0.0.6...v0.0.7) (2020-08-20)
|
||||||
|
|
|
@ -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',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
|
@ -3,13 +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(config)
|
||||||
function(
|
function(
|
||||||
name,
|
|
||||||
root,
|
|
||||||
buildSecrets,
|
buildSecrets,
|
||||||
publicSecrets,
|
publicSecrets,
|
||||||
secretSecrets
|
secretSecrets,
|
||||||
|
droneSecrets,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
kind: 'pipeline',
|
kind: 'pipeline',
|
||||||
|
@ -19,79 +21,37 @@ function(
|
||||||
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:[
|
||||||
compose(
|
images(config).scp(
|
||||||
std.map(
|
'/%(root)s/%(name)s' % config
|
||||||
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(buildSecrets),
|
|
||||||
compose(
|
compose(
|
||||||
std.map(
|
std.map(
|
||||||
function(secret) environment.envSet(secret),
|
function(secret) environment.envSet(secret),
|
||||||
publicSecrets + secretSecrets + buildSecrets,
|
publicSecrets + secretSecrets + buildSecrets,
|
||||||
),
|
),
|
||||||
)(
|
)(
|
||||||
images.ssh {
|
images(config).ssh() {
|
||||||
name: 'deploy',
|
name: 'deploy',
|
||||||
settings +: {
|
settings +: {
|
||||||
|
envs +: std.map(
|
||||||
|
environment.env,
|
||||||
|
droneSecrets,
|
||||||
|
),
|
||||||
script +:
|
script +:
|
||||||
std.map(
|
std.map(
|
||||||
function(secret)
|
function(secret)
|
||||||
'export %(env)s=$${%(env)s}' % {
|
'export %(env)s=$${%(env)s}' % {
|
||||||
env: environment.environment(secret)
|
env: environment.environment(secret)
|
||||||
},
|
},
|
||||||
secretSecrets + publicSecrets + buildSecrets,
|
secretSecrets + publicSecrets + buildSecrets + droneSecrets,
|
||||||
) +
|
) +
|
||||||
[
|
[
|
||||||
'set -e',
|
'set -e',
|
||||||
'cd %(root)s%(name)s' % { root: root, name: name },
|
'export NAME=%s' % config.name,
|
||||||
'sh .drone/login.sh',
|
'export ROOT=%s' % config.root,
|
||||||
|
'cd /%(root)s/%(name)s' % config,
|
||||||
|
login,
|
||||||
'sh .drone/pull.sh',
|
'sh .drone/pull.sh',
|
||||||
'sh .drone/deploy.sh',
|
'sh .drone/deploy.sh',
|
||||||
]
|
]
|
||||||
|
@ -99,6 +59,13 @@ function(
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
} {
|
||||||
|
trigger +: {
|
||||||
|
event +: [
|
||||||
|
'promote',
|
||||||
|
],
|
||||||
|
target +: [
|
||||||
|
'deploy',
|
||||||
|
],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
|
@ -1,8 +1,10 @@
|
||||||
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: [
|
||||||
|
@ -13,9 +15,10 @@ function(secrets)
|
||||||
],
|
],
|
||||||
commands: [
|
commands: [
|
||||||
'set -e',
|
'set -e',
|
||||||
'sh .drone/login.sh',
|
'export NAME=%s' % config.name,
|
||||||
|
'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',
|
|
||||||
],
|
],
|
||||||
}
|
}
|
|
@ -1,12 +1,11 @@
|
||||||
local settings = import 'settings.libsonnet';
|
function (config) {
|
||||||
{
|
docker(): {
|
||||||
docker: {
|
|
||||||
name: 'docker',
|
name: 'docker',
|
||||||
image: 'docker:dind',
|
image: '%(registry)sdocker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f' % config,
|
||||||
},
|
},
|
||||||
scp(target): settings.ssh {
|
scp(target = ''): {
|
||||||
name: 'scp',
|
name: 'scp',
|
||||||
image: 'appleboy/drone-scp:1.6.2',
|
image: '%(registry)sappleboy/drone-scp:1.6.2@sha256:bd37a55f4b97e7742b0de7333669b96220b3cc422d366e1fa8c34059b736ab47' % config,
|
||||||
settings +: {
|
settings +: {
|
||||||
command_timeout: '2m',
|
command_timeout: '2m',
|
||||||
target: target,
|
target: target,
|
||||||
|
@ -15,8 +14,8 @@ local settings = import 'settings.libsonnet';
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ssh: settings.ssh {
|
ssh(): {
|
||||||
image: 'appleboy/drone-ssh:1.6.2',
|
image: '%(registry)sappleboy/drone-ssh:1.6.2@sha256:b801dc2cd238c192b6e99acfa7bc3f5b9a03f312bd2feb1e10b3a7a28a1b80ea' % config,
|
||||||
settings +: {
|
settings +: {
|
||||||
envs: [
|
envs: [
|
||||||
'drone_tag',
|
'drone_tag',
|
||||||
|
@ -28,11 +27,4 @@ local settings = import 'settings.libsonnet';
|
||||||
script: [],
|
script: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wait(delay): {
|
|
||||||
image: 'alpine',
|
|
||||||
name: 'wait',
|
|
||||||
commands: [
|
|
||||||
'sleep %s' % delay,
|
|
||||||
],
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -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
|
||||||
|
|||
|
|
@ -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'),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@sigyl/jsonnet-drone",
|
"name": "@sigyl/jsonnet-drone",
|
||||||
"main": "deploy.libsonnet",
|
"main": "deploy.libsonnet",
|
||||||
"version": "0.0.8",
|
"version": "1.0.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",
|
||||||
|
|
|
@ -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',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
|
@ -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',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
|
@ -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',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
Loading…
Reference in New Issue