feat: registry

uses jsonnet-drone 0.3.0
This commit is contained in:
Giles Bradshaw 2020-09-24 14:08:36 +01:00
parent a87bfd0d8b
commit 9d29eeb26e
8 changed files with 106 additions and 8 deletions

View File

@ -4,9 +4,28 @@ local publicSecrets = import 'lib/public-secrets.libsonnet';
local deploy = import 'node_modules/@sigyl/jsonnet-drone/deploy.libsonnet';
local register = import 'node_modules/@sigyl/jsonnet-drone/register.libsonnet';
local registry = import 'node_modules/@sigyl/jsonnet-drone/registry.libsonnet';
local config = {
registry: '',
};
[
register,
deploy(
registry(
config {
script: 'sh .drone/scripts/initialise-images.sh',
},
) {
trigger +: {
event +: [
'promote',
],
target +: [
'registry',
],
},
},
deploy(config)(
'drone',
'/stack/',
[

View File

@ -15,6 +15,59 @@ trigger:
exclude:
- promote
---
kind: pipeline
type: docker
name: registry
platform:
os: linux
arch: amd64
steps:
- name: "dockerpull and save docker images:"
image: docker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f
commands:
- set -e
- export REGISTRY=$${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/
- sh .drone/scripts/initialise-images.sh $${REGISTRY} $${REGISTRY_PASSWORD}
environment:
REGISTRY_DOMAIN:
from_secret: registry-domain
REGISTRY_PASSWORD:
from_secret: registry-password
REGISTRY_PORT:
from_secret: registry-port
volumes:
- name: dockersock
path: /var/run
services:
- name: docker
image: docker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f
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
image_pull_secrets:
- dockerconfigjson
trigger:
event:
- promote
target:
- registry
---
kind: pipeline
type: docker

View File

@ -4,6 +4,6 @@
"build": "drone jsonnet --source drone-home.jsonnet --target drone-home.yml --stream"
},
"dependencies": {
"@sigyl/jsonnet-drone": "^0.1.1"
"@sigyl/jsonnet-drone": "^0.3.0"
}
}

View File

@ -0,0 +1,11 @@
n=0
while :
do
docker pull $2 \
&& docker tag $2 $1$2 \
&& docker push $1$2 && break # substitute your command here
n=$((n+1))
echo "retrying..$n"
sleep 1
done

View File

@ -0,0 +1,3 @@
sh $(dirname $0)/login.sh $1 "$2" \
&& sh $(dirname $0)/initialise-image.sh $1 drone/drone:1.9.0 \
&& sh $(dirname $0)/initialise-image.sh $1 drone/drone-runner-docker:1.5.0

12
.drone/scripts/login.sh Normal file
View File

@ -0,0 +1,12 @@
n=0
while :
do
docker login $1 --username client --password $2 \
&& break # substitute your command here
n=$((n+1))
echo "retrying login..$n"
sleep 1
done
sh $(dirname $0)/initialise-image.sh $1 drone/drone:1.9.0 \
&& sh $(dirname $0)/initialise-image.sh $1 drone/drone-runner-docker:1.5.0

View File

@ -12,10 +12,10 @@
resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone-environment/-/jsonnet-drone-environment-0.0.5.tgz#9ea85e08904777bd21a3e4b30b0b91461d0285ff"
integrity sha512-xVGmdMO1pOyozAWUbJm6mzKBgsLPJ+1hWnGCK3AxPkr7kkDh18hu30+TLzlcQtqq76s5jUfvJUztezsGj/mIcw==
"@sigyl/jsonnet-drone@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone/-/jsonnet-drone-0.1.1.tgz#37afda650e8420a664e89c762236a1e59aa485d9"
integrity sha512-GR7LXYaUJYjkcWRyyLlwrBX9Jw04Vlcc/XS32rNaSz4wtrD9opvnmESxNC1UTWXsT/3ybuQhLhCboEb2GiTWmw==
"@sigyl/jsonnet-drone@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone/-/jsonnet-drone-0.3.0.tgz#19a8ed693a040fee33d25f2ca0eec5d88b741a4a"
integrity sha512-c60nAupJ1eRQABKBwO8L9bHohkw6qlEWhPA9IthhHSCOFOzhkx/0N32aFdlSh6400nrieYZMYtQJ/28R9I3Wgg==
dependencies:
"@sigyl/jsonnet-compose" "^0.0.2"
"@sigyl/jsonnet-drone-environment" "0.0.5"

View File

@ -8,7 +8,7 @@ services:
replicas: 1
restart_policy:
condition: any
image: drone/drone:1.9.0
image: ${LOCAL_DOCKER_REGISTRY}drone/drone:1.9.0
volumes:
- drone:/var/lib/drone
- drone-data:/data
@ -37,7 +37,7 @@ services:
replicas: 1
restart_policy:
condition: any
image: drone/drone-runner-docker:1.5.0
image: ${LOCAL_DOCKER_REGISTRY}drone/drone-runner-docker:1.5.0
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment: