fix: deploy
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Giles Bradshaw 2020-08-05 09:01:03 +01:00
parent 032c77497c
commit cc19e18b51
4 changed files with 20 additions and 66 deletions

View File

@ -44,46 +44,24 @@ local publicSecrets = import 'lib/public-secrets.libsonnet';
'/stack/squid' '/stack/squid'
), ),
images.wait(15), images.wait(15),
compose( images.ssh {
std.map( name: 'deploy squid',
function(s) util.envSet(s), settings +: {
publicSecrets + secretSecrets //username: util.fromSecret("ssh-root-user"),
) + //password: util.fromSecret("ssh-root-password"),
std.map( script +: [
function(s) function(step) step { 'set -e',
settings +: { "docker network prune -f",
script +: [ "cd /stack/squid/myCA",
'openssl genrsa -out CA_key.pem 2048',
'export %(env)s="$${%(env)s}"' % { 'openssl req -x509 -days 600 -new -nodes -key CA_key.pem -out CA_crt.pem -extensions v3_ca -config openssl.cnf -subj "/C=US/ST=California/L=Mountain View/O=Google/OU=Enterprise/CN=MyCA"',
env: util.environment(s), 'cd ..',
}, "docker stack rm squid",
'echo "$${%s}"' % util.environment(s), "sleep 31",
], "docker stack deploy -c docker-compose.yml squid",
}, ]
},
publicSecrets + secretSecrets
)
)
(
images.ssh {
name: 'deploy squid',
settings +: {
//username: util.fromSecret("ssh-root-user"),
//password: util.fromSecret("ssh-root-password"),
script +: [
'set -e',
"docker network prune -f",
"cd /stack/squid/myCA",
'openssl genrsa -out CA_key.pem 2048',
'openssl req -x509 -days 600 -new -nodes -key CA_key.pem -out CA_crt.pem -extensions v3_ca -config openssl.cnf -subj "/C=US/ST=California/L=Mountain View/O=Google/OU=Enterprise/CN=MyCA"',
'cd ..',
"docker stack rm squid",
"sleep 30",
"docker stack deploy -c docker-compose.yml squid",
]
}
} }
), }
], ],
} }
] ]

View File

@ -38,11 +38,6 @@ steps:
- drone_build_number - drone_build_number
- drone_repo_name - drone_repo_name
- drone_repo_namespace - drone_repo_namespace
- ssh_host
- ssh_user
- ssh_root_user
- ssh_password
- ssh_key
host: host:
from_secret: ssh-host from_secret: ssh-host
key: key:
@ -57,31 +52,10 @@ steps:
- openssl req -x509 -days 600 -new -nodes -key CA_key.pem -out CA_crt.pem -extensions v3_ca -config openssl.cnf -subj "/C=US/ST=California/L=Mountain View/O=Google/OU=Enterprise/CN=MyCA" - openssl req -x509 -days 600 -new -nodes -key CA_key.pem -out CA_crt.pem -extensions v3_ca -config openssl.cnf -subj "/C=US/ST=California/L=Mountain View/O=Google/OU=Enterprise/CN=MyCA"
- cd .. - cd ..
- docker stack rm squid - docker stack rm squid
- sleep 30 - sleep 31
- docker stack deploy -c docker-compose.yml squid - docker stack deploy -c docker-compose.yml squid
- 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}"
- export SSH_KEY="$${SSH_KEY}"
- echo "$${SSH_KEY}"
username: username:
from_secret: ssh-user from_secret: ssh-user
environment:
SSH_HOST:
from_secret: ssh-host
SSH_KEY:
from_secret: ssh-key
SSH_PASSWORD:
from_secret: ssh-password
SSH_ROOT_USER:
from_secret: ssh-root-user
SSH_USER:
from_secret: ssh-user
services: services:
- name: docker - name: docker

View File

@ -2,4 +2,5 @@
'ssh-host', 'ssh-host',
'ssh-user', 'ssh-user',
'ssh-root-user', 'ssh-root-user',
'local-docker-registry',
] ]

View File

@ -1,4 +1,5 @@
[ [
'ssh-password', 'ssh-password',
'ssh-key', 'ssh-key',
'local-registry-password',
] ]