Compare commits

...

55 Commits

Author SHA1 Message Date
Giles Bradshaw 502700b6de build jsonnet to yml
continuous-integration/drone/push Build is passing Details
2020-07-29 12:07:46 +01:00
Giles 7153c383f9 deploy jsonnet
continuous-integration/drone/push Build is passing Details
2020-07-28 20:11:18 +01:00
Giles c6bda81782 .
continuous-integration/drone/push Build is failing Details
2020-07-28 19:35:48 +01:00
Giles 44640be0c6 .
continuous-integration/drone/push Build is failing Details
2020-07-28 19:31:36 +01:00
Giles 030758687a .
continuous-integration/drone/push Build is passing Details
2020-07-28 19:01:12 +01:00
Giles bff36e5e37 .
continuous-integration/drone/push Build is passing Details
2020-07-28 18:59:18 +01:00
Giles 85c4cc9986 .
continuous-integration/drone/push Build is passing Details
2020-07-28 18:57:35 +01:00
Giles bd0c8c631c .
continuous-integration/drone/push Build is passing Details
2020-07-28 18:55:42 +01:00
Giles 3d484408d0 .
continuous-integration/drone/push Build is passing Details
2020-07-28 18:53:57 +01:00
Giles 6131b0bdbf .
continuous-integration/drone/push Build is passing Details
2020-07-28 18:51:02 +01:00
Giles 9faf86302e .
continuous-integration/drone/push Build is failing Details
2020-07-28 18:49:04 +01:00
Giles c69a15eccb .
continuous-integration/drone/push Build is passing Details
2020-07-28 18:43:54 +01:00
Giles 0e93a886bd .
continuous-integration/drone/push Build is passing Details
2020-07-28 18:35:37 +01:00
Giles 5aa7994e53 .
continuous-integration/drone/push Build is passing Details
2020-07-28 18:34:09 +01:00
Giles 44d1938a51 .
continuous-integration/drone/push Build is passing Details
2020-07-28 18:27:52 +01:00
Giles Bradshaw 088e469a00 composed envsets
continuous-integration/drone/push Build is passing Details
2020-07-28 18:05:43 +01:00
Giles Bradshaw cdbf8bf1c2 composed envsets
continuous-integration/drone/push Build is passing Details
2020-07-28 18:03:08 +01:00
Giles Bradshaw 82eeeba210 composed envsets
continuous-integration/drone/push Build is passing Details
2020-07-28 18:01:17 +01:00
Giles Bradshaw 1692c835e2 composed envsets
continuous-integration/drone/push Build is passing Details
2020-07-28 17:59:11 +01:00
Giles Bradshaw 9eb234182b composed envsets
continuous-integration/drone/push Build is passing Details
2020-07-28 17:56:59 +01:00
Giles Bradshaw f2a83c2069 composed envsets
continuous-integration/drone/push Build is passing Details
2020-07-28 17:54:00 +01:00
Giles Bradshaw 09cdaa61db composed envsets
continuous-integration/drone/push Build is passing Details
2020-07-28 17:51:50 +01:00
Giles Bradshaw f66460a092 composed envsets
continuous-integration/drone/push Build is passing Details
2020-07-28 17:48:15 +01:00
Giles Bradshaw 917d518299 composed envsets
continuous-integration/drone/push Build is passing Details
2020-07-28 17:46:34 +01:00
Giles Bradshaw 03665f3a6a composed envsets
continuous-integration/drone/push Build is passing Details
2020-07-28 17:45:30 +01:00
Giles Bradshaw 649f6bac47 composed envsets
continuous-integration/drone/push Build is passing Details
2020-07-28 17:42:39 +01:00
Giles Bradshaw 6f75f22094 composed envsets
continuous-integration/drone/push Build is passing Details
2020-07-28 17:38:37 +01:00
Giles Bradshaw e44de99707 composed envsets
continuous-integration/drone/push Build is passing Details
2020-07-28 17:38:11 +01:00
Giles Bradshaw 031dc15083 .
continuous-integration/drone/push Build is passing Details
2020-07-28 17:30:59 +01:00
Giles Bradshaw d66b2f3e97 .
continuous-integration/drone/push Build is passing Details
2020-07-28 17:24:06 +01:00
Giles Bradshaw 534548dd70 Merge branch 'home-deploy' of https://sigyl.com/git/giles/portainer into home-deploy
continuous-integration/drone/push Build is passing Details
2020-07-28 17:22:24 +01:00
Giles Bradshaw 190c393af5 Merge branch 'home-deploy' of https://sigyl.com/git/giles/portainer into home-deploy 2020-07-28 17:22:13 +01:00
Giles Bradshaw 9807f15f72 Merge branch 'home-deploy' of https://sigyl.com/git/giles/portainer into home-deploy
continuous-integration/drone/push Build is passing Details
2020-07-28 17:20:40 +01:00
Giles Bradshaw 4324045b10 composed secret printing 2020-07-28 17:20:20 +01:00
Giles Bradshaw 3b40d8c44b composed secret printing
continuous-integration/drone/push Build is passing Details
2020-07-28 17:16:15 +01:00
Giles Bradshaw 4ba904839d composed secret printing
continuous-integration/drone/push Build is passing Details
2020-07-28 17:11:24 +01:00
Giles Bradshaw a535706098 composed secret printing
continuous-integration/drone/push Build is passing Details
2020-07-28 17:10:36 +01:00
Giles Bradshaw 5e803aa57e composed secret printing
continuous-integration/drone/push Build is passing Details
2020-07-28 17:09:34 +01:00
Giles Bradshaw a49d20dc90 composed secret printing
continuous-integration/drone/push Build is passing Details
2020-07-28 16:38:12 +01:00
Giles Bradshaw 56d5fda038 mend
continuous-integration/drone/push Build is passing Details
2020-07-28 16:35:16 +01:00
Giles Bradshaw e25ca5057f mend
continuous-integration/drone/push Build is passing Details
2020-07-28 16:34:37 +01:00
Giles Bradshaw 50f728e77e mend
continuous-integration/drone/push Build is passing Details
2020-07-28 16:09:56 +01:00
Giles Bradshaw 0fba89d95c mend
continuous-integration/drone/push Build is passing Details
2020-07-28 16:08:05 +01:00
Giles Bradshaw 5416ee6a9e mend
continuous-integration/drone/push Build is failing Details
2020-07-28 16:07:41 +01:00
Giles Bradshaw 22f59b648a mend
continuous-integration/drone/push Build is passing Details
2020-07-28 16:06:47 +01:00
Giles Bradshaw 2b86e1e751 mend
continuous-integration/drone/push Build is passing Details
2020-07-28 16:02:26 +01:00
Giles Bradshaw aba96f4413 ssh print an env
continuous-integration/drone/push Build is passing Details
2020-07-28 16:01:03 +01:00
Giles Bradshaw 39692236de ssh nothing
continuous-integration/drone/push Build is passing Details
2020-07-28 15:44:13 +01:00
Giles Bradshaw afea79d33b wait step
continuous-integration/drone/push Build is passing Details
2020-07-28 15:35:58 +01:00
Giles Bradshaw ece961ed00 scp step
continuous-integration/drone/push Build is passing Details
2020-07-28 15:32:32 +01:00
Giles Bradshaw cb901db134 jsonnet
continuous-integration/drone/push Build is passing Details
2020-07-28 14:09:17 +01:00
Giles Bradshaw ae38779355 jsonnet
continuous-integration/drone/push Build is passing Details
2020-07-28 14:08:13 +01:00
Giles Bradshaw 7a89383b66 jsonnet
continuous-integration/drone/push Build is passing Details
2020-07-28 14:05:29 +01:00
Giles Bradshaw d59ad3269b jsonnet
continuous-integration/drone/push Build is passing Details
2020-07-28 14:03:09 +01:00
Giles Bradshaw a34548c293 Deploy portainer on do
continuous-integration/drone/push Build is passing Details
2020-05-11 10:33:16 +01:00
5 changed files with 664 additions and 0 deletions

14
.drone-do.star Normal file
View File

@ -0,0 +1,14 @@
load("@this//portainer:drone.star", "drone")
load("@this//portainer:stack-name.star", "stackName")
load("@this//portainer:stack-root.star", "stackRoot")
def main(ctx):
return drone(
ctx,
"do",
stackRoot,
stackName,
[]
)

256
.drone-home.jsonnet Normal file
View File

@ -0,0 +1,256 @@
local publicSecrets = [
'ssh-host',
'ssh-user',
'ssh-root-user',
];
local secretSecrets = [
'ssh-password',
];
local util = {
// the head of an array
head(array): array[0],
// the tail of an array
tail(array): std.makeArray(
std.length(array) -1,
function(x) array[x + 1],
),
// compose an array of functions
compose(functions):
local compose(functions) =
if std.length(functions) == 0
then
local ret(object) = object;
ret
else
local ret(object) = compose(
util.tail(
functions,
)
)(
util.head(
functions,
)(object)
);
ret;
compose(functions),
fromSecret(secret): {
from_secret: secret,
},
secret(secret): std.asciiLower(
std.strReplace(
secret,
'_',
'-',
),
),
environment(secret): std.asciiUpper(
std.strReplace(
secret,
'-',
'_',
),
),
env(secret): std.asciiLower(
std.strReplace(
secret,
'-',
'_',
),
),
envSet(env): function(step) step {
environment +: {
[util.environment(env)]: util.fromSecret(
util.secret(env)
),
},
settings +: {
envs +: [
util.env(env),
],
},
},
printEnv(file, env): function(step) util.compose([
util.envSet(env),
function(step) step {
settings +: {
script +: [
'echo "export %(environment)s=\'$${%(environment)s}\'" >> %(file)s # "%(secret)s"' % {
environment: util.environment(env),
file: file,
secret: util.secret(env),
},
],
},
},
])(step),
};
local images = {
docker: {
name: 'docker',
image: 'docker:dind',
},
scp(target): {
name: 'scp',
image: 'appleboy/drone-scp',
settings: {
host: {
from_secret: 'ssh-host',
},
username: {
from_secret: 'ssh-user',
},
password: {
from_secret: 'ssh-password',
},
port: {
from_secret: 'ssh-port',
},
command_timeout: '2m',
target: target,
source: [
'.',
],
},
},
ssh: {
image: 'appleboy/drone-ssh',
settings: {
host: util.fromSecret("ssh-host"),
port: util.fromSecret("ssh-port"),
username: util.fromSecret("ssh-user"),
password: util.fromSecret("ssh-password"),
envs: [
'drone_tag',
'drone_commit',
'drone_build_number',
'drone_repo_name',
'drone_repo_namespace',
'DRONE_GITEA_SERVER',
],
script: [],
},
},
wait(delay): {
image: 'alpine',
name: 'wait',
commands: [
'sleep %s' % delay,
],
}
};
[
{
kind: 'pipeline',
type: 'docker',
name: 'build',
clone: {
disable: false,
depth: 0,
},
services: [
images.docker {
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',
},
},
],
steps:[
images.scp(
'/stack/root'
),
images.wait(15),
util.compose(
std.map(
function(secret) util.printEnv('afile', secret),
publicSecrets,
)
)(
images.ssh {
name: 'will print ssh-host again',
settings +: {
script +: [
'rm afile'
],
},
},
),
util.compose(
std.map(
function(s) util.envSet(s),
publicSecrets + secretSecrets
) +
std.map(
function(s) function(step) step {
settings +: {
script +: [
'export %(env)s="$${%(env)s}"' % {
env: util.environment(s),
},
'echo "$${%s}"' % util.environment(s),
],
},
},
publicSecrets + secretSecrets
)
)
(
images.ssh {
name: 'deploy portainer',
settings +: {
//username: util.fromSecret("ssh-root-user"),
//password: util.fromSecret("ssh-root-password"),
script +: [
'set -e',
'echo go',
" echo $${DRONE_GITEA_SERVER} > thefile",
] /*+
map(export, secrets) +
[
"export DRONE_REPO_LINK=$${{DRONE_GITEA_SERVER}}/{namespace}/{name}".format(name=ctx.repo.name, namespace=ctx.repo.namespace),
"export DRONE_COMMIT={commit}".format(commit=ctx.build.commit),
"docker network prune -f",
"cd {folder}".format(folder=folder),
"docker stack rm {name}".format(name = name),
"sleep 30",
"docker stack deploy -c {filename} {name}".format(name= name, filename = filename),
] + commands */
}
}
) {
settings +: {
script +: [
//"export DRONE_REPO_LINK=$${{DRONE_GITEA_SERVER}}/$${DRONE_REPO_NAMESPACE}/$${DRONE_REPO_NAME}",
//"export DRONE_COMMIT={commit}".format(commit=ctx.build.commit),
"docker network prune -f",
"cd /stack/portainer",
"docker stack rm portainer",
"sleep 30",
"docker stack deploy -c docker-compose.yml portainer",
],
},
},
],
}
]

256
jsonnet/.drone-home.jsonnet Normal file
View File

@ -0,0 +1,256 @@
local publicSecrets = [
'ssh-host',
'ssh-user',
'ssh-root-user',
];
local secretSecrets = [
'ssh-password',
];
local util = {
// the head of an array
head(array): array[0],
// the tail of an array
tail(array): std.makeArray(
std.length(array) -1,
function(x) array[x + 1],
),
// compose an array of functions
compose(functions):
local compose(functions) =
if std.length(functions) == 0
then
local ret(object) = object;
ret
else
local ret(object) = compose(
util.tail(
functions,
)
)(
util.head(
functions,
)(object)
);
ret;
compose(functions),
fromSecret(secret): {
from_secret: secret,
},
secret(secret): std.asciiLower(
std.strReplace(
secret,
'_',
'-',
),
),
environment(secret): std.asciiUpper(
std.strReplace(
secret,
'-',
'_',
),
),
env(secret): std.asciiLower(
std.strReplace(
secret,
'-',
'_',
),
),
envSet(env): function(step) step {
environment +: {
[util.environment(env)]: util.fromSecret(
util.secret(env)
),
},
settings +: {
envs +: [
util.env(env),
],
},
},
printEnv(file, env): function(step) util.compose([
util.envSet(env),
function(step) step {
settings +: {
script +: [
'echo "export %(environment)s=\'$${%(environment)s}\'" >> %(file)s # "%(secret)s"' % {
environment: util.environment(env),
file: file,
secret: util.secret(env),
},
],
},
},
])(step),
};
local images = {
docker: {
name: 'docker',
image: 'docker:dind',
},
scp(target): {
name: 'scp',
image: 'appleboy/drone-scp',
settings: {
host: {
from_secret: 'ssh-host',
},
username: {
from_secret: 'ssh-user',
},
password: {
from_secret: 'ssh-password',
},
port: {
from_secret: 'ssh-port',
},
command_timeout: '2m',
target: target,
source: [
'.',
],
},
},
ssh: {
image: 'appleboy/drone-ssh',
settings: {
host: util.fromSecret("ssh-host"),
port: util.fromSecret("ssh-port"),
username: util.fromSecret("ssh-user"),
password: util.fromSecret("ssh-password"),
envs: [
'drone_tag',
'drone_commit',
'drone_build_number',
'drone_repo_name',
'drone_repo_namespace',
'DRONE_GITEA_SERVER',
],
script: [],
},
},
wait(delay): {
image: 'alpine',
name: 'wait',
commands: [
'sleep %s' % delay,
],
}
};
[
{
kind: 'pipeline',
type: 'docker',
name: 'build',
clone: {
disable: false,
depth: 0,
},
services: [
images.docker {
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',
},
},
],
steps:[
images.scp(
'/stack/root'
),
images.wait(15),
util.compose(
std.map(
function(secret) util.printEnv('afile', secret),
publicSecrets,
)
)(
images.ssh {
name: 'will print ssh-host again',
settings +: {
script +: [
'rm afile'
],
},
},
),
util.compose(
std.map(
function(s) util.envSet(s),
publicSecrets + secretSecrets
) +
std.map(
function(s) function(step) step {
settings +: {
script +: [
'export %(env)s="$${%(env)s}"' % {
env: util.environment(s),
},
'echo "$${%s}"' % util.environment(s),
],
},
},
publicSecrets + secretSecrets
)
)
(
images.ssh {
name: 'deploy portainer',
settings +: {
//username: util.fromSecret("ssh-root-user"),
//password: util.fromSecret("ssh-root-password"),
script +: [
'set -e',
'echo go',
" echo $${DRONE_GITEA_SERVER} > thefile",
] /*+
map(export, secrets) +
[
"export DRONE_REPO_LINK=$${{DRONE_GITEA_SERVER}}/{namespace}/{name}".format(name=ctx.repo.name, namespace=ctx.repo.namespace),
"export DRONE_COMMIT={commit}".format(commit=ctx.build.commit),
"docker network prune -f",
"cd {folder}".format(folder=folder),
"docker stack rm {name}".format(name = name),
"sleep 30",
"docker stack deploy -c {filename} {name}".format(name= name, filename = filename),
] + commands */
}
}
) {
settings +: {
script +: [
//"export DRONE_REPO_LINK=$${{DRONE_GITEA_SERVER}}/$${DRONE_REPO_NAMESPACE}/$${DRONE_REPO_NAME}",
//"export DRONE_COMMIT={commit}".format(commit=ctx.build.commit),
"docker network prune -f",
"cd /stack/portainer",
"docker stack rm portainer",
"sleep 30",
"docker stack deploy -c docker-compose.yml portainer",
],
},
},
],
}
]

132
jsonnet/.drone-home.yml Normal file
View File

@ -0,0 +1,132 @@
---
kind: pipeline
type: docker
name: build
platform:
os: linux
arch: amd64
steps:
- name: scp
image: appleboy/drone-scp
settings:
command_timeout: 2m
host:
from_secret: ssh-host
password:
from_secret: ssh-password
port:
from_secret: ssh-port
source:
- .
target: /stack/root
username:
from_secret: ssh-user
- name: wait
image: alpine
commands:
- sleep 15
- name: will print ssh-host again
image: appleboy/drone-ssh
settings:
envs:
- drone_tag
- drone_commit
- drone_build_number
- drone_repo_name
- drone_repo_namespace
- DRONE_GITEA_SERVER
- ssh_host
- ssh_user
- ssh_root_user
host:
from_secret: ssh-host
password:
from_secret: ssh-password
port:
from_secret: ssh-port
script:
- rm afile
- "echo \"export SSH_HOST='$${SSH_HOST}'\" >> afile # \"ssh-host\""
- "echo \"export SSH_USER='$${SSH_USER}'\" >> afile # \"ssh-user\""
- "echo \"export SSH_ROOT_USER='$${SSH_ROOT_USER}'\" >> afile # \"ssh-root-user\""
username:
from_secret: ssh-user
environment:
SSH_HOST:
from_secret: ssh-host
SSH_ROOT_USER:
from_secret: ssh-root-user
SSH_USER:
from_secret: ssh-user
- name: deploy portainer
image: appleboy/drone-ssh
settings:
envs:
- drone_tag
- drone_commit
- drone_build_number
- drone_repo_name
- drone_repo_namespace
- DRONE_GITEA_SERVER
- ssh_host
- ssh_user
- ssh_root_user
- ssh_password
host:
from_secret: ssh-host
password:
from_secret: ssh-password
port:
from_secret: ssh-port
script:
- set -e
- echo go
- " echo $${DRONE_GITEA_SERVER} > thefile"
- export SSH_HOST="$${SSH_HOST}"
- echo "$${SSH_HOST}"
- export SSH_USER="$${SSH_USER}"
- echo "$${SSH_USER}"
- export SSH_ROOT_USER="$${SSH_ROOT_USER}"
- echo "$${SSH_ROOT_USER}"
- export SSH_PASSWORD="$${SSH_PASSWORD}"
- echo "$${SSH_PASSWORD}"
- docker network prune -f
- cd /stack/portainer
- docker stack rm portainer
- sleep 30
- docker stack deploy -c docker-compose.yml portainer
username:
from_secret: ssh-user
environment:
SSH_HOST:
from_secret: ssh-host
SSH_PASSWORD:
from_secret: ssh-password
SSH_ROOT_USER:
from_secret: ssh-root-user
SSH_USER:
from_secret: ssh-user
services:
- name: docker
image: docker:dind
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
...

6
package.json Normal file
View File

@ -0,0 +1,6 @@
{
"private": true,
"scripts": {
"jsonnet:home": "drone jsonnet --source jsonnet/.drone-home.jsonnet --target jsonnet/.drone-home.yml --stream"
}
}