[IMP] runbot: allow override global docker registry on a host

This commit is contained in:
Christophe Monniez 2024-11-13 16:17:42 +01:00 committed by xdo
parent 3197f75e45
commit 2697a28e54
2 changed files with 4 additions and 1 deletions

View File

@ -47,6 +47,7 @@ class Host(models.Model):
profile = fields.Boolean('Profile', help='Enable profiling on this host')
use_remote_docker_registry = fields.Boolean('Use remote Docker Registry', default=False, help="Use docker registry for pulling images")
docker_registry_url = fields.Char('Registry Url', help="Override global registry URL for this host.")
def _compute_nb(self):
groups = self.env['runbot.build'].read_group(
@ -125,6 +126,7 @@ class Host(models.Model):
self.ensure_one()
icp = self.env['ir.config_parameter']
docker_registry_host = self.browse(int(icp.get_param('runbot.docker_registry_host_id', default=0)))
registry_url = self.registry_url.strip('/') if self.registry_url else f'dockerhub.{docker_registry_host.name}'
# pull all images from the runbot docker registry
is_registry = docker_registry_host == self
all_docker_files = self.env['runbot.dockerfile'].search([])
@ -133,7 +135,7 @@ class Host(models.Model):
_logger.info('Pulling docker images...')
total_duration = 0
for dockerfile in all_docker_files.filtered('always_pull'):
remote_tag = f'dockerhub.{docker_registry_host.name}/{dockerfile.image_tag}'
remote_tag = f'{registry_url}/{dockerfile.image_tag}'
result = docker_pull(remote_tag)
if result['success']:
result['image'].tag(dockerfile.image_tag)

View File

@ -12,6 +12,7 @@
<field name="disp_name"/>
<field name="active"/>
<field name="use_remote_docker_registry"/>
<field name="docker_registry_url"/>
<field name="last_start_loop" readonly='1'/>
<field name="last_end_loop" readonly='1'/>
<field name="last_success" readonly='1'/>