zuul-jobs/util-tasks/run-docker-registry.yaml
Albin Vass 06e35b2125 Test multiarch release builds and use temp registry with buildx
When using docker buildx to build a container image, use a temporary
registry to receive the built image instead of requiring a buildset
registry.

A multi-arch test is also added with a publication registry
using the same task list to reduce duplication.

Change-Id: Ib20d1c97f6cb63e0ff9d8888ea792d1941cd8690
Co-Authored-By: James E. Blair <jeblair@redhat.com>
2020-07-01 10:29:31 -07:00

51 lines
1.2 KiB
YAML

# Required vars:
# registry:
# host: "{{ ansible_host }}"
# port: 5000
# username: zuul
# password: testpassword
# container_command: docker
- name: Install container system
include_role:
name: "ensure-{{ container_command }}"
- name: Create temporary registry working directory
tempfile:
state: directory
register: registry_tempdir
- name: Create auth directory
file:
path: "{{ registry_tempdir.path }}/auth"
state: directory
- name: Install passlib for htpasswd
become: true
package:
name:
- python3-passlib
- python3-bcrypt
state: present
- name: Write htpasswd file
htpasswd:
create: true
crypt_scheme: bcrypt
path: "{{ registry_tempdir.path }}/auth/htpasswd"
name: "{{ registry.username }}"
password: "{{ registry.password }}"
- name: Start registry with basic auth
command: >-
{{ container_command }} run -d \
-p {{ registry.port }}:5000
--restart=always
-v {{ registry_tempdir.path }}/auth:/auth \
-e "REGISTRY_AUTH=htpasswd" \
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
registry:2
args:
chdir: "{{ registry_tempdir.path }}"