2020-09-24 12:48:43 +00:00
|
|
|
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';
|
2020-10-23 00:03:07 +00:00
|
|
|
local login = import 'lib/login.libsonnet';
|
2020-09-24 12:48:43 +00:00
|
|
|
|
|
|
|
function(config)
|
|
|
|
{
|
|
|
|
kind: 'pipeline',
|
|
|
|
type: 'docker',
|
|
|
|
name: 'registry',
|
|
|
|
clone: {
|
2020-10-23 00:03:07 +00:00
|
|
|
disable: true,
|
2020-09-24 12:48:43 +00:00
|
|
|
},
|
|
|
|
services: [
|
|
|
|
images(config).docker {
|
|
|
|
privileged: true,
|
|
|
|
volumes: [
|
|
|
|
{
|
|
|
|
name: 'dockersock',
|
|
|
|
path: '/var/run',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'ca',
|
|
|
|
path: '/etc/docker/certs.d',
|
|
|
|
},
|
2020-10-22 12:10:13 +00:00
|
|
|
{
|
|
|
|
name: 'daemonjson',
|
|
|
|
path: '/etc/docker/daemon.json',
|
|
|
|
},
|
2020-09-24 12:48:43 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
volumes: [
|
|
|
|
{
|
|
|
|
name: 'dockersock',
|
|
|
|
temp: {},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'ca',
|
|
|
|
host: {
|
|
|
|
path: '/etc/docker/certs.d',
|
|
|
|
},
|
|
|
|
},
|
2020-10-22 12:10:13 +00:00
|
|
|
{
|
|
|
|
name: 'daemonjson',
|
|
|
|
host: {
|
|
|
|
path: '/etc/docker/daemon.json',
|
|
|
|
},
|
|
|
|
},
|
2020-09-24 12:48:43 +00:00
|
|
|
],
|
2020-10-23 00:03:07 +00:00
|
|
|
steps:
|
|
|
|
std.map(
|
|
|
|
function(def) images(config).docker {
|
2020-10-23 07:56:44 +00:00
|
|
|
name: def.save,
|
2020-09-24 12:48:43 +00:00
|
|
|
environment +: environment
|
2020-09-24 13:52:21 +00:00
|
|
|
.environmentSecrets(config.secrets),
|
2020-09-24 12:48:43 +00:00
|
|
|
volumes: [
|
|
|
|
{
|
|
|
|
name: 'dockersock',
|
|
|
|
path: '/var/run',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
commands: [
|
|
|
|
'set -e',
|
2020-10-23 00:03:07 +00:00
|
|
|
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),
|
2020-09-24 12:48:43 +00:00
|
|
|
],
|
|
|
|
},
|
2020-10-23 00:03:07 +00:00
|
|
|
config.images,
|
|
|
|
),
|
2020-09-24 12:48:43 +00:00
|
|
|
image_pull_secrets: [
|
|
|
|
'dockerconfigjson'
|
|
|
|
]
|
2020-10-23 00:03:07 +00:00
|
|
|
} {
|
|
|
|
trigger +: {
|
|
|
|
event +: [
|
|
|
|
'promote',
|
|
|
|
],
|
|
|
|
target +: [
|
|
|
|
'registry',
|
|
|
|
],
|
|
|
|
},
|
2020-09-24 12:48:43 +00:00
|
|
|
}
|