Compare commits

...

4 Commits
n80 ... master

Author SHA1 Message Date
Giles Bradshaw c69da15402 feat: save parameter
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details
2020-10-24 13:37:41 +01:00
Giles Bradshaw ad2b757d29 feat: save parameter
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details
2020-10-24 13:02:36 +01:00
Giles Bradshaw 7108a37068 feat: promotion print, registry, build, save, deploy
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details
2020-10-23 10:43:56 +01:00
Giles Bradshaw c1f9684a3f feat: initialise images
continuous-integration/drone/push Build is passing Details
images are now initialised with shell script
2020-10-22 18:45:45 +01:00
11 changed files with 265 additions and 66 deletions

View File

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

View File

@ -1,4 +1,5 @@
docker stack rm portainer
echo 'sleeping...60'
sleep 60
docker stack deploy -c docker-compose.yml portainer
export LOCAL_DOCKER_REGISTRY=${REGISTRY_DOMAIN}:${REGISTRY_PORT}/${ROOT}/${NAME}/ \
&& docker stack rm portainer \
&& echo 'sleeping...60' \
&& sleep 60 \
&& docker stack deploy -c docker-compose.yml portainer --with-registry-auth

View File

@ -4,11 +4,52 @@ 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 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 = {
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,
deploy(
'portainer',
'/stack/',
registry(
config {
secrets: [],
images: defs,
},
),
save(config)(
defs,
[],
),
print(config)(
[],
publicSecrets,
secretSecrets,
),
build(config)(
[],
),
deploy(config)(
[],
publicSecrets,
secretSecrets,

View File

@ -18,7 +18,144 @@ trigger:
---
kind: pipeline
type: docker
name: deploy
name: registry
platform:
os: linux
arch: amd64
clone:
disable: true
steps:
- name: portainer/portainer-ce:2.0.0-alpine
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/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"
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:
- 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
- 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
image_pull_secrets:
- dockerconfigjson
trigger:
event:
- promote
target:
- registry
---
kind: pipeline
type: docker
name: save
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:
os: linux
@ -34,44 +171,84 @@ steps:
- drone_build_number
- drone_repo_name
- drone_repo_namespace
host: ${SSH_HOST}
key: ${SSH_KEY}
passphrase: ${SSH_PASSPHRASE}
port: ${SSH_PORT}
script:
- rm -f env-portainer
username: ${SSH_USER}
- name: scp
image: appleboy/drone-scp:1.6.2@sha256:bd37a55f4b97e7742b0de7333669b96220b3cc422d366e1fa8c34059b736ab47
settings:
command_timeout: 2m
host: ${SSH_HOST}
key: ${SSH_KEY}
passphrase: ${SSH_PASSPHRASE}
port: ${SSH_PORT}
source:
- .
target: /stack/portainer
username: ${SSH_USER}
trigger:
event:
- promote
target:
- print
- name: wait
image: alpine:3.12.0@sha256:90baa0922fe90624b05cb5766fa5da4e337921656c2f8e2b13bd3c052a0baac1
commands:
- sleep 15
---
kind: pipeline
type: docker
name: build
platform:
os: linux
arch: amd64
steps:
- name: "dockerbuild:"
image: docker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f
commands:
- set -e
- sh .drone/login.sh
- export NAME=portainer
- 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/push.sh
- sh .drone/logout.sh
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
- 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
trigger:
event:
- promote
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:
@ -85,43 +262,25 @@ steps:
- registry_domain
- registry_port
- registry_password
host: ${SSH_HOST}
key: ${SSH_KEY}
passphrase: ${SSH_PASSPHRASE}
port: ${SSH_PORT}
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
- sh .drone/login.sh
- "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
username: ${SSH_USER}
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
trigger:
event:
- promote
- promote
target:
- deploy
- production
...

View File

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

View File

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

View File

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

View File

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

View File

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

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.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone/-/jsonnet-drone-0.1.0.tgz#feda1797e8e9ef799cad72e65f7163ca26a9e3a5"
integrity sha512-QY/ngucxFOtLfL8Mt0f2bxN4fQDUOGOFtaRpSH2cNyg84xADkzehT0ORZtbLitr+AwhyF5KN/zAGvzkyNAoqPw==
"@sigyl/jsonnet-drone@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone/-/jsonnet-drone-1.0.0.tgz#943bd8a1abc8a916026944816709f5ed1d8e7ef8"
integrity sha512-ubyVC1/nAM584wTnnRBZTOP18z28Yy7SRApvSuo/3y2arngKlNI1FwOzKTFt/7L9+rNy19dRO/g0obEkyR3KmA==
dependencies:
"@sigyl/jsonnet-compose" "^0.0.2"
"@sigyl/jsonnet-drone-environment" "0.0.5"

View File

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