2020-07-30 14:32:27 +00:00
|
|
|
---
|
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
|
|
|
name: build
|
|
|
|
|
|
|
|
platform:
|
|
|
|
os: linux
|
|
|
|
arch: amd64
|
|
|
|
|
|
|
|
steps:
|
2020-08-06 14:09:33 +00:00
|
|
|
- name: print env
|
|
|
|
image: appleboy/drone-ssh
|
|
|
|
settings:
|
|
|
|
envs:
|
|
|
|
- drone_tag
|
|
|
|
- drone_commit
|
|
|
|
- drone_build_number
|
|
|
|
- drone_repo_name
|
|
|
|
- drone_repo_namespace
|
2020-08-06 14:23:26 +00:00
|
|
|
- ssh_host
|
|
|
|
- ssh_user
|
|
|
|
- ssh_root_user
|
|
|
|
- local_docker_registry
|
2020-08-06 14:09:33 +00:00
|
|
|
- ca_crt
|
|
|
|
host:
|
|
|
|
from_secret: ssh-host
|
|
|
|
key:
|
|
|
|
from_secret: ssh-key
|
|
|
|
port:
|
|
|
|
from_secret: ssh-port
|
|
|
|
script:
|
2020-08-06 14:23:26 +00:00
|
|
|
- rm -f env-squid
|
|
|
|
- "echo \"export SSH_HOST='$${SSH_HOST}'\" >> env-squid # \"ssh-host\""
|
|
|
|
- "echo \"export SSH_USER='$${SSH_USER}'\" >> env-squid # \"ssh-user\""
|
|
|
|
- "echo \"export SSH_ROOT_USER='$${SSH_ROOT_USER}'\" >> env-squid # \"ssh-root-user\""
|
|
|
|
- "echo \"export LOCAL_DOCKER_REGISTRY='$${LOCAL_DOCKER_REGISTRY}'\" >> env-squid # \"local-docker-registry\""
|
|
|
|
- "echo \"export CA_CRT='$${CA_CRT}'\" >> env-squid # \"ca-crt\""
|
2020-08-06 14:09:33 +00:00
|
|
|
username:
|
|
|
|
from_secret: ssh-user
|
|
|
|
environment:
|
|
|
|
CA_CRT:
|
|
|
|
from_secret: ca-crt
|
2020-08-06 14:23:26 +00:00
|
|
|
LOCAL_DOCKER_REGISTRY:
|
|
|
|
from_secret: local-docker-registry
|
|
|
|
SSH_HOST:
|
|
|
|
from_secret: ssh-host
|
|
|
|
SSH_ROOT_USER:
|
|
|
|
from_secret: ssh-root-user
|
|
|
|
SSH_USER:
|
|
|
|
from_secret: ssh-user
|
2020-08-06 14:09:33 +00:00
|
|
|
|
2020-07-30 14:32:27 +00:00
|
|
|
- name: scp
|
|
|
|
image: appleboy/drone-scp
|
|
|
|
settings:
|
|
|
|
command_timeout: 2m
|
2020-08-05 07:49:09 +00:00
|
|
|
host:
|
|
|
|
from_secret: ssh-host
|
|
|
|
key:
|
|
|
|
from_secret: ssh-key
|
|
|
|
port:
|
|
|
|
from_secret: ssh-port
|
2020-07-30 14:32:27 +00:00
|
|
|
source:
|
|
|
|
- .
|
|
|
|
target: /stack/squid
|
2020-08-05 07:49:09 +00:00
|
|
|
username:
|
|
|
|
from_secret: ssh-user
|
2020-07-30 14:32:27 +00:00
|
|
|
|
|
|
|
- name: wait
|
|
|
|
image: alpine
|
|
|
|
commands:
|
|
|
|
- sleep 15
|
|
|
|
|
2020-08-06 17:10:19 +00:00
|
|
|
- name: "dockerbuild docker:dind image:"
|
2020-08-06 15:33:26 +00:00
|
|
|
image: docker:dind
|
|
|
|
commands:
|
|
|
|
- set -e
|
|
|
|
- sleep 15
|
2020-08-06 17:10:19 +00:00
|
|
|
- docker login $${LOCAL_DOCKER_REGISTRY} --username client --password "$${LOCAL_REGISTRY_PASSWORD}"
|
|
|
|
- cd docker-dind
|
2020-08-06 17:12:04 +00:00
|
|
|
- echo "$${CA_CRT}" > CA_crt.crt
|
2020-08-06 17:10:19 +00:00
|
|
|
- docker build . -t $${LOCAL_DOCKER_REGISTRY}docker:dind
|
|
|
|
- docker push $${LOCAL_DOCKER_REGISTRY}docker:dind
|
|
|
|
- docker logout $${LOCAL_DOCKER_REGISTRY}
|
2020-08-06 15:33:26 +00:00
|
|
|
environment:
|
2020-08-06 17:10:19 +00:00
|
|
|
CA_CRT:
|
|
|
|
from_secret: ca-crt
|
2020-08-06 15:33:26 +00:00
|
|
|
LOCAL_DOCKER_REGISTRY:
|
|
|
|
from_secret: local-docker-registry
|
|
|
|
LOCAL_REGISTRY_PASSWORD:
|
|
|
|
from_secret: local-registry-password
|
|
|
|
volumes:
|
|
|
|
- name: dockersock
|
|
|
|
path: /var/run
|
|
|
|
|
2020-08-06 10:05:40 +00:00
|
|
|
- name: deploy squid
|
|
|
|
image: appleboy/drone-ssh
|
|
|
|
settings:
|
|
|
|
envs:
|
|
|
|
- drone_tag
|
|
|
|
- drone_commit
|
|
|
|
- drone_build_number
|
|
|
|
- drone_repo_name
|
|
|
|
- drone_repo_namespace
|
|
|
|
- local_docker_registry
|
|
|
|
- local_registry_password
|
2020-08-06 14:23:26 +00:00
|
|
|
- ca_crt
|
|
|
|
- ca_key
|
2020-08-06 10:05:40 +00:00
|
|
|
host:
|
|
|
|
from_secret: ssh-host
|
|
|
|
key:
|
|
|
|
from_secret: ssh-key
|
|
|
|
port:
|
|
|
|
from_secret: ssh-port
|
|
|
|
script:
|
2020-08-06 14:23:26 +00:00
|
|
|
- rm -f -R /stack/squid/.secrets
|
|
|
|
- mkdir -p /stack/squid/.secrets
|
2020-08-06 14:29:28 +00:00
|
|
|
- echo "$${CA_CRT}" > /stack/squid/.secrets/ca.crt
|
|
|
|
- echo "$${CA_KEY}" > /stack/squid/.secrets/ca.key
|
2020-08-06 10:05:40 +00:00
|
|
|
- set -e
|
|
|
|
- cd /stack/squid/myCA
|
|
|
|
- cd ..
|
|
|
|
- docker stack deploy -c docker-compose.yml squid
|
|
|
|
username:
|
|
|
|
from_secret: ssh-user
|
2020-08-05 11:31:43 +00:00
|
|
|
environment:
|
2020-08-06 14:23:26 +00:00
|
|
|
CA_CRT:
|
|
|
|
from_secret: ca-crt
|
|
|
|
CA_KEY:
|
|
|
|
from_secret: ca-key
|
2020-08-05 11:31:43 +00:00
|
|
|
LOCAL_DOCKER_REGISTRY:
|
|
|
|
from_secret: local-docker-registry
|
|
|
|
LOCAL_REGISTRY_PASSWORD:
|
|
|
|
from_secret: local-registry-password
|
2020-07-30 14:32:27 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-08-06 15:06:53 +00:00
|
|
|
image_pull_secrets:
|
|
|
|
- dockerconfigjson
|
|
|
|
|
2020-07-30 14:32:27 +00:00
|
|
|
...
|