Skip to content

Commit

Permalink
[IMP] runbot: allow override global docker registry on a host
Browse files Browse the repository at this point in the history
  • Loading branch information
d-fence authored and Xavier-Do committed Nov 14, 2024
1 parent 3197f75 commit 2697a28
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion runbot/models/host.py
Original file line number Diff line number Diff line change
@@ -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 @@ def _docker_update_images(self):
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 @@ def _docker_update_images(self):
_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)
1 change: 1 addition & 0 deletions runbot/views/host_views.xml
Original file line number Diff line number Diff line change
@@ -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'/>

0 comments on commit 2697a28

Please sign in to comment.