File tree 7 files changed +60
-6
lines changed
7 files changed +60
-6
lines changed Original file line number Diff line number Diff line change @@ -12,12 +12,9 @@ progress of longer tasks.
12
12
13
13
- Deploy fleet manager to home server
14
14
15
-
15
+ <!--
16
16
## Medium priority: quality of life
17
-
18
- ** deploy/**
19
-
20
- - Deal with DockerHub rate limits: set up Docker proxy on the gateway?
17
+ -->
21
18
22
19
23
20
## Low priority: nice to have
Original file line number Diff line number Diff line change 33
33
caddy_config : /etc/caddy/Caddyfile
34
34
firewall_auto_config : no
35
35
tasks :
36
+ - name : create systemd service for Docker Hub proxy
37
+ template :
38
+ src : /etc/provision/gateway/dockerhub.service
39
+ dest : /etc/systemd/system/dockerhub.service
40
+ mode : ' 0644'
41
+ owner : root
42
+ - name : enable systemd service for Docker Hub proxy
43
+ systemd :
44
+ name : dockerhub.service
45
+ enabled : yes
46
+ state : started
47
+ daemon_reload : yes
48
+
36
49
# HTTP reverse proxy (Caddy)
37
50
# nginx is too quirky with dynamic reverse proxy destinations:
38
51
# - requires static resolver IP
Original file line number Diff line number Diff line change
1
+ # I know that systemd service will own only docker client process, not the
2
+ # container process itself.
3
+ #
4
+ # Typically this is less than ideal (and this is where alternative tools like
5
+ # Podman truly shine) but for current usecase it's acceptable. Gateway is not
6
+ # expected to live long (it will be destroyed if there were no CI jobs within
7
+ # last hour) and there is only a slight chance that we will encounter a
8
+ # failure not handled either by systemd or by docker in that short time.
9
+
10
+ [Unit]
11
+ Description =Docker Hub caching proxy
12
+ After =docker.service
13
+ Requires =docker.service
14
+
15
+ [Service]
16
+ Environment =REMOTE_IMAGE =registry:2
17
+ Environment =LOCAL_CONTAINER =dockerhub
18
+ Environment =LOCAL_USER =1912:1954
19
+ Environment =LOCAL_STORAGE =/dockerhub
20
+ ExecStop =-/usr/bin/docker stop ${LOCAL_CONTAINER}
21
+ ExecStop =-/usr/bin/docker rm ${LOCAL_CONTAINER}
22
+ ExecStartPre =/bin/mkdir -p ${LOCAL_STORAGE}
23
+ ExecStartPre =/bin/chown -R ${LOCAL_USER} ${LOCAL_STORAGE}
24
+ ExecStartPre =-/usr/bin/docker stop ${LOCAL_CONTAINER}
25
+ ExecStartPre =-/usr/bin/docker rm ${LOCAL_CONTAINER}
26
+ ExecStart =/usr/bin/docker run \
27
+ --name ${LOCAL_CONTAINER} \
28
+ --env REGISTRY_PROXY_REMOTEURL =https://registry-1.docker.io \
29
+ --volume ${LOCAL_STORAGE}:/var/lib/registry \
30
+ --publish {{ inner_ip }}:5000:5000 \
31
+ --user ${LOCAL_USER} \
32
+ --restart unless-stopped \
33
+ ${REMOTE_IMAGE}
34
+ TimeoutStartSec =0
35
+ Restart =always
36
+
37
+ [Install]
38
+ WantedBy =default.target
Original file line number Diff line number Diff line change 53
53
vars :
54
54
new :
55
55
storage-driver : overlay2
56
+ registry-mirrors :
57
+ - ' http://{{ gateway_ip }}:5000'
56
58
old : ' {{ docker_config.content|b64decode|from_json }}'
57
59
copy :
58
60
content : |
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ write_files:
9
9
hosts:
10
10
localhost:
11
11
inner_subnet: ${inner_subnet}
12
+ inner_ip: ${inner_ip}
12
13
13
14
runcmd :
14
15
- /usr/bin/make -C /etc/provision gateway
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ write_files:
11
11
all:
12
12
hosts:
13
13
localhost:
14
+ gateway_ip: ${gateway_ip}
14
15
gitlab_runner_token: ${gitlab_runner_token}
15
16
gitlab_runner_tag: ${gitlab_runner_tag}
16
17
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ resource "yandex_compute_instance" "gateway" {
16
16
auto_delete = true
17
17
initialize_params {
18
18
image_id = yandex_compute_image. base [0 ]. id
19
- size = 10
19
+ size = 25
20
20
}
21
21
}
22
22
network_interface {
@@ -31,6 +31,7 @@ resource "yandex_compute_instance" "gateway" {
31
31
serial-port-enable = 1
32
32
user-data = templatefile (" cloud-config/gateway.yml" , {
33
33
inner_subnet = var.inner_cidr[0 ],
34
+ inner_ip = local.gateway_ip,
34
35
})
35
36
}
36
37
}
@@ -64,6 +65,7 @@ resource "yandex_compute_instance" "runner" {
64
65
metadata = {
65
66
serial-port-enable = 1
66
67
user-data = templatefile (" cloud-config/runner.yml" , {
68
+ gateway_ip = local.gateway_ip,
67
69
gitlab_runner_tag = var.gitlab_runner_tag,
68
70
gitlab_runner_token = var.gitlab_runner_token,
69
71
})
You can’t perform that action at this time.
0 commit comments