Creates a docker registry for storing built images.
Created
November 27, 2017 07:52
-
-
Save blackandred/17c2a384ad56e5de1248ff0afb7f5a72 to your computer and use it in GitHub Desktop.
Ansible: Own docker registry (ARM)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Create required directory /deploy/registry | |
become: yes | |
file: | |
path: /deploy/registry | |
state: directory | |
- name: Install htpasswd tool | |
become: yes | |
apt: | |
name: apache2-utils | |
state: installed | |
- name: Copy configuration files | |
become: yes | |
template: | |
src: "{{ item.src }}" | |
dest: "{{ item.dest }}" | |
with_items: | |
- { src: "docker-compose.yml.j2", dest: "/deploy/registry/docker-compose.yml" } | |
- { src: "restart.sh", dest: "/deploy/registry/restart.sh" } | |
- { src: "stop.sh", dest: "/deploy/registry/stop.sh" } | |
- { src: "registry.service", dest: "/lib/systemd/system/registry.service" } | |
- name: Add executable permissions for restart.sh and stop.sh | |
become: yes | |
file: dest="/deploy/registry/{{ item }}" mode=a+x | |
with_items: | |
- "restart.sh" | |
- "stop.sh" | |
- name: Generate basic auth password | |
become: yes | |
shell: "htpasswd -c -b /deploy/registry/htpasswd '{{ REGISTRY_LOGIN }}' '{{ REGISTRY_PASSWORD }}'" | |
- name: Enable systemd entry and run the service | |
become: yes | |
systemd: | |
name: registry | |
enabled: yes | |
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2.0' | |
services: | |
registry: | |
#restart: always | |
image: budry/registry-arm:v2.6.2 | |
ports: | |
- 5000:5000 | |
environment: | |
# The registry will be behind a reverse-proxy providing a SSL certificate | |
#REGISTRY_HTTP_TLS_CERTIFICATE: /deploy/registry/certs/domain.crt | |
#REGISTRY_HTTP_TLS_KEY: /deploy/registry/certs/domain.key | |
REGISTRY_AUTH: htpasswd | |
REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd | |
REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm | |
volumes: | |
- {{ REGISTRY_DIRECTORY }}:/var/lib/registry | |
- /deploy/registry:/auth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Docker registry | |
Requires=docker.service | |
After=docker.service | |
[Service] | |
Restart=always | |
ExecStart=/deploy/registry/restart.sh | |
ExecStop=/deploy/registry/stop.sh | |
[Install] | |
WantedBy=local.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd /deploy/registry | |
docker-compose down | |
docker-compose up -d | |
sleep 15 && systemctl restart reverse_proxy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd /deploy/registry && docker-compose down |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment