jsonnet-drone/registry.libsonnet

101 lines
2.4 KiB
Plaintext
Raw Permalink Normal View History

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: [
2020-10-23 19:20:40 +00:00
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(
2020-10-23 19:20:40 +00:00
function(def) images(config).docker() {
2020-10-23 07:56:44 +00:00
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',
],
},
}