forked from woshidagouxiong/migr8-registry-gcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync-docker-registry.yml
77 lines (68 loc) · 1.96 KB
/
sync-docker-registry.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
resources:
- name: migrate-script
type: git
source:
branch: master
private_key: ((private_key_migrate_containers))
uri: [email protected]:aholyoake-bc/migr8-registry-gcloud
- name: daily
type: time
source: {interval: 24h}
jobs:
- name: sync-to-google-registry
plan:
- in_parallel:
- get: migrate-script
trigger: true
- get: daily
trigger: true
- task: sync
params:
GCLOUDPATH: "gcloud"
DOCKERPATH: "docker"
GCLOUD_URL: "eu.gcr.io/blockchain-internal"
REG_URL: "docker-registry.service.consul:5000"
REG_PROTOCOL: "http://"
DOCKER_HOST: unix:///var/run/docker.sock
SERVICE_ACCOUNT: ((container-sync-service-account))
privileged: true
config:
inputs:
- name: migrate-script
platform: linux
image_resource:
type: docker-image
source:
repository: google/cloud-sdk
run:
path: /bin/bash
args:
- -c
- |
#!/bin/bash
echo "${SERVICE_ACCOUNT}" > creds.json
apt-get update -y
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io
pip3 install requests
mkdir -p /etc/docker
cat << EOF > /etc/docker/daemon.json
{
"insecure-registries" : ["$REG_URL"]
}
EOF
dockerd &> dockerd.log &
gcloud auth activate-service-account --key-file=creds.json
python3 migrate-script/migrate.py