ci:docker deploy from registry
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Giles Bradshaw 2020-08-05 12:31:43 +01:00
parent 4c00cf3eff
commit 38f7af0b5c
3 changed files with 35 additions and 39 deletions

View File

@ -44,7 +44,7 @@ local publicSecrets = import 'lib/public-secrets.libsonnet';
'/stack/squid'
),
images.wait(15),
images.docker {
/*images.docker {
name +: 'build docker image:',
environment +: environment.environmentSecrets([
'LOCAL_DOCKER_REGISTRY',
@ -66,7 +66,11 @@ local publicSecrets = import 'lib/public-secrets.libsonnet';
'docker push $${LOCAL_DOCKER_REGISTRY}squid',
'docker logout $${LOCAL_DOCKER_REGISTRY}',
],
},
},*/
compose([
environment.envSet('local-docker-registry'),
environment.envSet('local-registry-password'),
])(
images.ssh {
name: 'deploy squid',
settings +: {
@ -79,10 +83,13 @@ local publicSecrets = import 'lib/public-secrets.libsonnet';
'cd ..',
"docker stack rm squid",
"sleep 31",
'export SQUID_IMAGE=$${LOCAL_DOCKER_REGISTRY}squid',
'docker login $${LOCAL_DOCKER_REGISTRY} --username client --password "$${LOCAL_REGISTRY_PASSWORD}"',
"docker stack deploy -c docker-compose.yml squid",
]
}
}
},
),
],
}
]

View File

@ -29,26 +29,6 @@ steps:
commands:
- sleep 15
- name: "dockerbuild docker image:"
image: docker:dind
commands:
- set -e
- pwd
- sleep 15
- cd docker
- docker login $${LOCAL_DOCKER_REGISTRY} --username client --password "$${LOCAL_REGISTRY_PASSWORD}"
- docker build . -t $${LOCAL_DOCKER_REGISTRY}squid
- docker push $${LOCAL_DOCKER_REGISTRY}squid
- docker logout $${LOCAL_DOCKER_REGISTRY}
environment:
LOCAL_DOCKER_REGISTRY:
from_secret: local-docker-registry
LOCAL_REGISTRY_PASSWORD:
from_secret: local-registry-password
volumes:
- name: dockersock
path: /var/run
- name: deploy squid
image: appleboy/drone-ssh
settings:
@ -58,6 +38,8 @@ steps:
- drone_build_number
- drone_repo_name
- drone_repo_namespace
- local_docker_registry
- local_registry_password
host:
from_secret: ssh-host
key:
@ -73,9 +55,16 @@ steps:
- cd ..
- docker stack rm squid
- sleep 31
- export SQUID_IMAGE=$${LOCAL_DOCKER_REGISTRY}squid
- docker login $${LOCAL_DOCKER_REGISTRY} --username client --password "$${LOCAL_REGISTRY_PASSWORD}"
- docker stack deploy -c docker-compose.yml squid
username:
from_secret: ssh-user
environment:
LOCAL_DOCKER_REGISTRY:
from_secret: local-docker-registry
LOCAL_REGISTRY_PASSWORD:
from_secret: local-registry-password
services:
- name: docker

View File

@ -7,7 +7,7 @@ services:
replicas: 1
restart_policy:
condition: any
image: squid
image: ${SQUID_IMAGE}
volumes:
- squid-cache:/apps/squid/var/cache/squid
#- ./squid.intercept.conf:/etc/squid/squid.conf