Compare commits

..

11 Commits
master ... n80

Author SHA1 Message Date
Giles Bradshaw 3429f512b0 .
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details
2020-10-22 18:01:21 +01:00
Giles Bradshaw b1e21bf238 .
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details
2020-10-22 17:54:49 +01:00
Giles Bradshaw 5f2379b9ab .
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details
2020-10-22 17:32:52 +01:00
Giles Bradshaw d074d183ff .
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is failing Details
2020-10-22 17:29:53 +01:00
Giles Bradshaw d6abd8898e .
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details
2020-10-22 17:13:12 +01:00
Giles Bradshaw 65270d533c .
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details
2020-10-22 17:08:40 +01:00
Giles Bradshaw 5d5728c88c .
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is failing Details
2020-10-22 17:06:15 +01:00
Giles Bradshaw 5ee2f74699 .
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is failing Details
2020-10-22 17:03:53 +01:00
Giles Bradshaw 9143a4e12e .
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is failing Details
2020-10-22 17:02:43 +01:00
Giles Bradshaw fb57269ce5 .
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is failing Details
2020-10-22 16:57:33 +01:00
Giles Bradshaw ea90a7cd27 . 2020-10-22 16:57:27 +01:00
14 changed files with 104 additions and 202 deletions

View File

@ -1 +1 @@
echo 'nothing to build' echo 'noting to build'

View File

@ -1,4 +1,4 @@
export LOCAL_DOCKER_REGISTRY=${REGISTRY_DOMAIN}:${REGISTRY_PORT}/${ROOT}/${NAME}/ \ export LOCAL_DOCKER_REGISTRY=${REGISTRY_DOMAIN}:${REGISTRY_PORT}/ \
&& docker stack rm portainer \ && docker stack rm portainer \
&& echo 'sleeping...60' \ && echo 'sleeping...60' \
&& sleep 60 \ && sleep 60 \

View File

@ -4,52 +4,35 @@ local publicSecrets = import 'lib/public-secrets.libsonnet';
local deploy = import 'node_modules/@sigyl/jsonnet-drone/deploy.libsonnet'; local deploy = import 'node_modules/@sigyl/jsonnet-drone/deploy.libsonnet';
local register = import 'node_modules/@sigyl/jsonnet-drone/register.libsonnet'; local register = import 'node_modules/@sigyl/jsonnet-drone/register.libsonnet';
local deploy = import 'node_modules/@sigyl/jsonnet-drone/deploy.libsonnet';
local registry = import 'node_modules/@sigyl/jsonnet-drone/registry.libsonnet'; local registry = import 'node_modules/@sigyl/jsonnet-drone/registry.libsonnet';
local save = import 'node_modules/@sigyl/jsonnet-drone/save.libsonnet';
local build = import 'node_modules/@sigyl/jsonnet-drone/build.libsonnet';
local print = import 'node_modules/@sigyl/jsonnet-drone/print.libsonnet';
local config = { local config = {
registry: '', registry: '',
name: 'portainer',
root: 'stack',
}; };
local defs = [
{
load: 'portainer/portainer-ce:2.0.0-alpine@sha256:5555e1538aa4bc56d7ae85787278e4b972573b205e2ae260717ef17985e0e24f',
save: 'portainer/portainer-ce:2.0.0-alpine'
},
{
load: 'portainer/agent:2.0.0@sha256:8f994457bc32480bff351f0b1d371557238e69f5902037addfe76fa7bd930b9d',
save: 'portainer/agent:2.0.0'
},
];
[ [
register, register,
registry( registry(
config { config {
script: 'sh .drone/scripts/initialise-images.sh',
secrets: [], secrets: [],
images: defs,
}, },
), ) {
save(config)( trigger +: {
defs, event +: [
[], 'promote',
), ],
print(config)( target +: [
[], 'registry',
publicSecrets, ],
secretSecrets, },
), },
build(config)(
[],
),
deploy(config)( deploy(config)(
'portainer',
'/stack/',
[], [],
publicSecrets, publicSecrets,
secretSecrets, secretSecrets,

View File

@ -24,26 +24,13 @@ platform:
os: linux os: linux
arch: amd64 arch: amd64
clone:
disable: true
steps: steps:
- name: portainer/portainer-ce:2.0.0-alpine - name: "dockerpull and save docker images:"
image: docker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f image: docker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f
commands: commands:
- set -e - set -e
- "n=0\nwhile :\ndo\n docker login $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/ --username client --password \"$${REGISTRY_PASSWORD}\" \\\\\n && break # substitute your command here\n n=$((n+1))\n if [ $n -ge 10 ]; then\n echo \"login failed\"\n exit 1\n fi\n echo \"retrying login..$n\"\n sleep 5\ndone\n" - export REGISTRY=$${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/
- "n=0\nwhile :\ndo\n docker pull portainer/portainer-ce:2.0.0-alpine@sha256:5555e1538aa4bc56d7ae85787278e4b972573b205e2ae260717ef17985e0e24f \\\\\n && docker tag portainer/portainer-ce:2.0.0-alpine@sha256:5555e1538aa4bc56d7ae85787278e4b972573b205e2ae260717ef17985e0e24f $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/stack/portainer/portainer/portainer-ce:2.0.0-alpine \\\\\n && docker push $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/stack/portainer/portainer/portainer-ce:2.0.0-alpine && break\n n=$((n+1))\n if [ $n -ge 10 ]; then\n echo \"initialise failed\"\n exit 1\n fi\n echo \"retrying..$n\"\n sleep 5\ndone\n" - sh .drone/scripts/initialise-images.sh $${REGISTRY} "$${REGISTRY_PASSWORD}"
volumes:
- name: dockersock
path: /var/run
- name: portainer/agent:2.0.0
image: docker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f
commands:
- set -e
- "n=0\nwhile :\ndo\n docker login $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/ --username client --password \"$${REGISTRY_PASSWORD}\" \\\\\n && break # substitute your command here\n n=$((n+1))\n if [ $n -ge 10 ]; then\n echo \"login failed\"\n exit 1\n fi\n echo \"retrying login..$n\"\n sleep 5\ndone\n"
- "n=0\nwhile :\ndo\n docker pull portainer/agent:2.0.0@sha256:8f994457bc32480bff351f0b1d371557238e69f5902037addfe76fa7bd930b9d \\\\\n && docker tag portainer/agent:2.0.0@sha256:8f994457bc32480bff351f0b1d371557238e69f5902037addfe76fa7bd930b9d $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/stack/portainer/portainer/agent:2.0.0 \\\\\n && docker push $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/stack/portainer/portainer/agent:2.0.0 && break\n n=$((n+1))\n if [ $n -ge 10 ]; then\n echo \"initialise failed\"\n exit 1\n fi\n echo \"retrying..$n\"\n sleep 5\ndone\n"
volumes: volumes:
- name: dockersock - name: dockersock
path: /var/run path: /var/run
@ -82,80 +69,7 @@ trigger:
--- ---
kind: pipeline kind: pipeline
type: docker type: docker
name: save name: deploy
platform:
os: linux
arch: amd64
clone:
disable: true
steps:
- name: mkdir
image: appleboy/drone-ssh:1.6.2@sha256:b801dc2cd238c192b6e99acfa7bc3f5b9a03f312bd2feb1e10b3a7a28a1b80ea
settings:
envs:
- drone_tag
- drone_commit
- drone_build_number
- drone_repo_name
- drone_repo_namespace
script:
- mkdir -p /stack/.images/portainer/built
- rm -f /stack/.images/portainer/*.*
- rm -f /stack/.images/portainer/built/*.*
- name: portainer/portainer-ce:2.0.0-alpine
image: appleboy/drone-ssh:1.6.2@sha256:b801dc2cd238c192b6e99acfa7bc3f5b9a03f312bd2feb1e10b3a7a28a1b80ea
settings:
envs:
- drone_tag
- drone_commit
- drone_build_number
- drone_repo_name
- drone_repo_namespace
- registry_domain
- registry_port
- registry_password
- destination_registry
script:
- "n=0\nwhile :\ndo\n docker login $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/ --username client --password \"$${REGISTRY_PASSWORD}\" \\\\\n && break # substitute your command here\n n=$((n+1))\n if [ $n -ge 10 ]; then\n echo \"login failed\"\n exit 1\n fi\n echo \"retrying login..$n\"\n sleep 5\ndone\n"
- docker pull $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/stack/portainer/portainer/portainer-ce:2.0.0-alpine
- docker save $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/stack/portainer/portainer/portainer-ce:2.0.0-alpine -o /stack/.images/portainer/portainer_portainer-ce:2.0.0-alpine.tar
- echo "docker load < portainer_portainer-ce:2.0.0-alpine.tar" >> /stack/.images/portainer/load.sh
- echo "docker tag $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/stack/portainer/portainer/portainer-ce:2.0.0-alpine $${DESTINATION_REGISTRY}/stack/portainer/portainer/portainer-ce:2.0.0-alpine" >> /stack/.images/portainer/load.sh
- name: portainer/agent:2.0.0
image: appleboy/drone-ssh:1.6.2@sha256:b801dc2cd238c192b6e99acfa7bc3f5b9a03f312bd2feb1e10b3a7a28a1b80ea
settings:
envs:
- drone_tag
- drone_commit
- drone_build_number
- drone_repo_name
- drone_repo_namespace
- registry_domain
- registry_port
- registry_password
- destination_registry
script:
- "n=0\nwhile :\ndo\n docker login $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/ --username client --password \"$${REGISTRY_PASSWORD}\" \\\\\n && break # substitute your command here\n n=$((n+1))\n if [ $n -ge 10 ]; then\n echo \"login failed\"\n exit 1\n fi\n echo \"retrying login..$n\"\n sleep 5\ndone\n"
- docker pull $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/stack/portainer/portainer/agent:2.0.0
- docker save $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/stack/portainer/portainer/agent:2.0.0 -o /stack/.images/portainer/portainer_agent:2.0.0.tar
- echo "docker load < portainer_agent:2.0.0.tar" >> /stack/.images/portainer/load.sh
- echo "docker tag $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/stack/portainer/portainer/agent:2.0.0 $${DESTINATION_REGISTRY}/stack/portainer/portainer/agent:2.0.0" >> /stack/.images/portainer/load.sh
trigger:
event:
- promote
target:
- save
---
kind: pipeline
type: docker
name: print
platform: platform:
os: linux os: linux
@ -174,35 +88,55 @@ steps:
script: script:
- rm -f env-portainer - rm -f env-portainer
trigger: - name: scp
event: image: appleboy/drone-scp:1.6.2@sha256:bd37a55f4b97e7742b0de7333669b96220b3cc422d366e1fa8c34059b736ab47
- promote settings:
target: command_timeout: 2m
- print source:
- .
target: /stack/portainer
--- - name: wait
kind: pipeline image: alpine:3.12.0@sha256:90baa0922fe90624b05cb5766fa5da4e337921656c2f8e2b13bd3c052a0baac1
type: docker commands:
name: build - sleep 15
platform:
os: linux
arch: amd64
steps:
- name: "dockerbuild:" - name: "dockerbuild:"
image: docker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f image: docker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f
commands: commands:
- set -e - set -e
- export NAME=portainer - sh .drone/login.sh
- export ROOT=stack
- "n=0\nwhile :\ndo\n docker login $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/ --username client --password \"$${REGISTRY_PASSWORD}\" \\\\\n && break # substitute your command here\n n=$((n+1))\n if [ $n -ge 10 ]; then\n echo \"login failed\"\n exit 1\n fi\n echo \"retrying login..$n\"\n sleep 5\ndone\n"
- sh .drone/build.sh - sh .drone/build.sh
- sh .drone/push.sh - sh .drone/push.sh
- sh .drone/logout.sh
volumes: volumes:
- name: dockersock - name: dockersock
path: /var/run path: /var/run
- name: deploy
image: appleboy/drone-ssh:1.6.2@sha256:b801dc2cd238c192b6e99acfa7bc3f5b9a03f312bd2feb1e10b3a7a28a1b80ea
settings:
envs:
- drone_tag
- drone_commit
- drone_build_number
- drone_repo_name
- drone_repo_namespace
- domain
- registry_domain
- registry_port
- registry_password
script:
- export DOMAIN=$${DOMAIN}
- export REGISTRY_DOMAIN=$${REGISTRY_DOMAIN}
- export REGISTRY_PORT=$${REGISTRY_PORT}
- export REGISTRY_PASSWORD=$${REGISTRY_PASSWORD}
- set -e
- cd /stack/portainer
- sh .drone/login.sh
- sh .drone/pull.sh
- sh .drone/deploy.sh
services: services:
- name: docker - name: docker
image: docker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f image: docker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f
@ -229,58 +163,6 @@ trigger:
event: event:
- promote - promote
target: target:
- build
---
kind: pipeline
type: docker
name: deploy
platform:
os: linux
arch: amd64
steps:
- name: scp
image: appleboy/drone-scp:1.6.2@sha256:bd37a55f4b97e7742b0de7333669b96220b3cc422d366e1fa8c34059b736ab47
settings:
command_timeout: 2m
source:
- .
target: /stack/portainer
- name: deploy
image: appleboy/drone-ssh:1.6.2@sha256:b801dc2cd238c192b6e99acfa7bc3f5b9a03f312bd2feb1e10b3a7a28a1b80ea
settings:
envs:
- drone_tag
- drone_commit
- drone_build_number
- drone_repo_name
- drone_repo_namespace
- domain
- registry_domain
- registry_port
- registry_password
script:
- export DOMAIN=$${DOMAIN}
- export REGISTRY_DOMAIN=$${REGISTRY_DOMAIN}
- export REGISTRY_PORT=$${REGISTRY_PORT}
- export REGISTRY_PASSWORD=$${REGISTRY_PASSWORD}
- set -e
- export NAME=portainer
- export ROOT=stack
- cd /stack/portainer
- "n=0\nwhile :\ndo\n docker login $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/ --username client --password \"$${REGISTRY_PASSWORD}\" \\\\\n && break # substitute your command here\n n=$((n+1))\n if [ $n -ge 10 ]; then\n echo \"login failed\"\n exit 1\n fi\n echo \"retrying login..$n\"\n sleep 5\ndone\n"
- sh .drone/pull.sh
- sh .drone/deploy.sh
trigger:
event:
- promote
- promote
target:
- deploy
- production - production
... ...

1
.drone/login.sh Normal file
View File

@ -0,0 +1 @@
docker login ${REGISTRY_DOMAIN}:${REGISTRY_PORT} --username client --password "${REGISTRY_PASSWORD}"

1
.drone/logout.sh Normal file
View File

@ -0,0 +1 @@
docker logout ${REGISTRY_DOMAIN}:${REGISTRY_PORT}

View File

@ -1,6 +1,6 @@
{ {
"private": true, "private": true,
"dependencies": { "dependencies": {
"@sigyl/jsonnet-drone": "^1.0.0" "@sigyl/jsonnet-drone": "^0.4.1"
} }
} }

View File

@ -1 +1 @@
echo 'nothing to pull' echo 'noting to pull'

View File

@ -1 +1 @@
echo 'nothing to push' echo 'noting to push'

View File

@ -0,0 +1,15 @@
n=0
while :
do
docker pull $2 \
&& docker tag $2 $1$3 \
&& docker push $1$3 && break # substitute your command here
n=$((n+1))
if [ $n -ge 10 ]; then
echo "initialise failed"
exit 1
fi
echo "retrying..$n"
sleep 5
done

View File

@ -0,0 +1,7 @@
sh $(dirname $0)/login.sh $1 "$2" \
&& sh $(dirname $0)/initialise-image.sh $1 \
portainer/portainer-ce:2.0.0-alpine@sha256:5555e1538aa4bc56d7ae85787278e4b972573b205e2ae260717ef17985e0e24f \
sigyl.stack.portainer_portainer/portainer-ce:2.0.0-alpine \
&& sh $(dirname $0)/initialise-image.sh $1 \
portainer/agent:2.0.0@sha256:8f994457bc32480bff351f0b1d371557238e69f5902037addfe76fa7bd930b9d \
sigyl.stack.portainer_portainer/agent:2.0.0

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

@ -0,0 +1,13 @@
n=0
while :
do
docker login $1 --username client --password "$2" \
&& 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

View File

@ -12,10 +12,10 @@
resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone-environment/-/jsonnet-drone-environment-0.0.5.tgz#9ea85e08904777bd21a3e4b30b0b91461d0285ff" resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone-environment/-/jsonnet-drone-environment-0.0.5.tgz#9ea85e08904777bd21a3e4b30b0b91461d0285ff"
integrity sha512-xVGmdMO1pOyozAWUbJm6mzKBgsLPJ+1hWnGCK3AxPkr7kkDh18hu30+TLzlcQtqq76s5jUfvJUztezsGj/mIcw== integrity sha512-xVGmdMO1pOyozAWUbJm6mzKBgsLPJ+1hWnGCK3AxPkr7kkDh18hu30+TLzlcQtqq76s5jUfvJUztezsGj/mIcw==
"@sigyl/jsonnet-drone@^1.0.0": "@sigyl/jsonnet-drone@^0.4.1":
version "1.0.0" version "0.4.1"
resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone/-/jsonnet-drone-1.0.0.tgz#943bd8a1abc8a916026944816709f5ed1d8e7ef8" resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone/-/jsonnet-drone-0.4.1.tgz#3527edb00f8bb860de1658f4c9fa6f81f932d3b7"
integrity sha512-ubyVC1/nAM584wTnnRBZTOP18z28Yy7SRApvSuo/3y2arngKlNI1FwOzKTFt/7L9+rNy19dRO/g0obEkyR3KmA== integrity sha512-+TOx51KJG1RxrPRZ2lPpia7a6Ms5UvkyLIuXuumPtenyxJ/pivY1TdcLvSAvFgVZHMjh9CxBCuOu8vNT1fPy2A==
dependencies: dependencies:
"@sigyl/jsonnet-compose" "^0.0.2" "@sigyl/jsonnet-compose" "^0.0.2"
"@sigyl/jsonnet-drone-environment" "0.0.5" "@sigyl/jsonnet-drone-environment" "0.0.5"

View File

@ -1,7 +1,7 @@
version: "3.7" version: "3.7"
services: services:
portainer: portainer:
image: ${LOCAL_DOCKER_REGISTRY}portainer/portainer-ce:2.0.0-alpine image: ${LOCAL_DOCKER_REGISTRY}sigyl.stack.portainer_portainer/portainer-ce:2.0.0-alpine
command: -H tcp://tasks.portainer-agent:9001 --tlsskipverify command: -H tcp://tasks.portainer-agent:9001 --tlsskipverify
# command: -H unix:///var/run/docker.sock # command: -H unix:///var/run/docker.sock
deploy: deploy:
@ -18,7 +18,7 @@ services:
- appnet - appnet
- externalnet - externalnet
portainer-agent: portainer-agent:
image: ${LOCAL_DOCKER_REGISTRY}portainer/agent:2.0.0 image: ${LOCAL_DOCKER_REGISTRY}sigyl.stack.portainer_portainer/agent:2.0.0
environment: environment:
# REQUIRED: Should be equal to the service name prefixed by "tasks." when # REQUIRED: Should be equal to the service name prefixed by "tasks." when
# deployed inside an overlay network # deployed inside an overlay network