mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] runbot: official docker file route
This route was already existing on runbot using a website page. Making it official
This commit is contained in:
parent
9c6124d645
commit
d051e68448
@ -662,3 +662,33 @@ class Runbot(Controller):
|
|||||||
'trigger': trigger_id,
|
'trigger': trigger_id,
|
||||||
'project': trigger_id.project_id,
|
'project': trigger_id.project_id,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@route([
|
||||||
|
'/runbot/dockerfile',
|
||||||
|
'/runbot/dockerfile/<int:dockerfile_id>',
|
||||||
|
'/runbot/dockerfile/tag/<string:docker_tag>',
|
||||||
|
'/runbot/dockerfile/version/<string:version>',
|
||||||
|
], type='http', auth='public', sitemap=False)
|
||||||
|
def dockerfile_content(self, dockerfile_id=None, version=None, docker_tag=None, **kwargs):
|
||||||
|
dockerfile_sudo = request.env['runbot.dockerfile'].sudo()
|
||||||
|
if 'id' in kwargs:
|
||||||
|
dockerfile_id = int(kwargs['id'])
|
||||||
|
if dockerfile_id: # keep 'id' for historical reasons
|
||||||
|
dockerfile = dockerfile_sudo.browse(dockerfile_id).exists()
|
||||||
|
elif docker_tag:
|
||||||
|
dockerfile = dockerfile_sudo.search([('image_tag', '=', docker_tag)])
|
||||||
|
elif version:
|
||||||
|
dockerfile = dockerfile_sudo.search([('version_ids.name', '=', version)])
|
||||||
|
else:
|
||||||
|
raise NotFound
|
||||||
|
|
||||||
|
if dockerfile.public_visibility:
|
||||||
|
return Response(response=dockerfile.layer_ids.render_layers({
|
||||||
|
'USERUID': '${USERUID}',
|
||||||
|
'USERGID': '${USERGID}',
|
||||||
|
'USERNAME': '${USERNAME}',
|
||||||
|
}), status=200, mimetype='text/plain')
|
||||||
|
|
||||||
|
if dockerfile:
|
||||||
|
_logger.error('Trying to access a non public docker image')
|
||||||
|
raise NotFound
|
||||||
|
@ -42,6 +42,11 @@ admin_passwd=running_master_password</field>
|
|||||||
<field name="value"></field>
|
<field name="value"></field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.config_parameter" id="runbot.runbot_dockerfile_public_by_default">
|
||||||
|
<field name="key">runbot.runbot_dockerfile_public_by_default</field>
|
||||||
|
<field name="value"></field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record model="ir.config_parameter" id="runbot.runbot_is_base_regex">
|
<record model="ir.config_parameter" id="runbot.runbot_is_base_regex">
|
||||||
<field name="key">runbot.runbot_is_base_regex</field>
|
<field name="key">runbot.runbot_is_base_regex</field>
|
||||||
<field name="value">^((master)|(saas-)?\d+\.\d+)$</field>
|
<field name="value">^((master)|(saas-)?\d+\.\d+)$</field>
|
||||||
|
@ -850,8 +850,7 @@ class BuildResult(models.Model):
|
|||||||
ro_volumes[f'/data/build/{dest}'] = source
|
ro_volumes[f'/data/build/{dest}'] = source
|
||||||
if 'image_tag' not in kwargs:
|
if 'image_tag' not in kwargs:
|
||||||
kwargs.update({'image_tag': self.params_id.dockerfile_id.image_tag})
|
kwargs.update({'image_tag': self.params_id.dockerfile_id.image_tag})
|
||||||
if kwargs['image_tag'] != 'odoo:DockerDefault':
|
self._log('Preparing', 'Using Dockerfile Tag [%s](/runbot/dockerfile/tag/%s)' % (kwargs['image_tag'], kwargs['image_tag']), log_type='markdown')
|
||||||
self._log('Preparing', 'Using Dockerfile Tag %s' % kwargs['image_tag'])
|
|
||||||
containers_memory_limit = self.env['ir.config_parameter'].sudo().get_param('runbot.runbot_containers_memory', 0)
|
containers_memory_limit = self.env['ir.config_parameter'].sudo().get_param('runbot.runbot_containers_memory', 0)
|
||||||
if containers_memory_limit and 'memory' not in kwargs:
|
if containers_memory_limit and 'memory' not in kwargs:
|
||||||
kwargs['memory'] = int(float(containers_memory_limit) * 1024 ** 3)
|
kwargs['memory'] = int(float(containers_memory_limit) * 1024 ** 3)
|
||||||
|
@ -140,7 +140,9 @@ class Dockerfile(models.Model):
|
|||||||
referencing_dockerlayer_ids = fields.One2many('runbot.docker_layer', 'reference_dockerfile_id', string='Layers referencing this one')
|
referencing_dockerlayer_ids = fields.One2many('runbot.docker_layer', 'reference_dockerfile_id', string='Layers referencing this one')
|
||||||
use_count = fields.Integer('Used count', compute="_compute_use_count", store=True)
|
use_count = fields.Integer('Used count', compute="_compute_use_count", store=True)
|
||||||
# maybe we should have global values here? branch version, chrome version, ... then use a os layer when possible (jammy, ...)
|
# maybe we should have global values here? branch version, chrome version, ... then use a os layer when possible (jammy, ...)
|
||||||
# we could also have a variant param, to use the version image in a specific trigger? Add a layer or change a param?
|
# we could also have a variant param, to use the version image in a specific trigger? Add a layer or change a param?
|
||||||
|
|
||||||
|
public_visibility = fields.Boolean('Public', default=lambda self: self.env['ir.config_parameter'].sudo().get_param('runbot.runbot_dockerfile_public_by_default'), help="Dockerfile is public and can be accessed by anyone with /runbot/dockerfile route")
|
||||||
|
|
||||||
_sql_constraints = [('runbot_dockerfile_name_unique', 'unique(name)', 'A Dockerfile with this name already exists')]
|
_sql_constraints = [('runbot_dockerfile_name_unique', 'unique(name)', 'A Dockerfile with this name already exists')]
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ class ResConfigSettings(models.TransientModel):
|
|||||||
runbot_forwardport_author = fields.Char('Forwardbot author')
|
runbot_forwardport_author = fields.Char('Forwardbot author')
|
||||||
runbot_organisation = fields.Char('Organisation')
|
runbot_organisation = fields.Char('Organisation')
|
||||||
runbot_disable_host_on_fetch_failure = fields.Boolean('Disable host on fetch failure')
|
runbot_disable_host_on_fetch_failure = fields.Boolean('Disable host on fetch failure')
|
||||||
|
runbot_dockerfile_public_by_default = fields.Boolean('Docker files are public by default')
|
||||||
runbot_use_ssl = fields.Boolean('Use ssl for workers', help="select if worker ressources (log, dump, ...) uses ssl or not.", config_parameter="runbot.use_ssl")
|
runbot_use_ssl = fields.Boolean('Use ssl for workers', help="select if worker ressources (log, dump, ...) uses ssl or not.", config_parameter="runbot.use_ssl")
|
||||||
|
|
||||||
runbot_db_gc_days = fields.Integer(
|
runbot_db_gc_days = fields.Integer(
|
||||||
@ -77,6 +78,7 @@ class ResConfigSettings(models.TransientModel):
|
|||||||
runbot_forwardport_author=get_param('runbot.runbot_forwardport_author', default=''),
|
runbot_forwardport_author=get_param('runbot.runbot_forwardport_author', default=''),
|
||||||
runbot_organisation=get_param('runbot.runbot_organisation', default=''),
|
runbot_organisation=get_param('runbot.runbot_organisation', default=''),
|
||||||
runbot_disable_host_on_fetch_failure=get_param('runbot.runbot_disable_host_on_fetch_failure', default=False),
|
runbot_disable_host_on_fetch_failure=get_param('runbot.runbot_disable_host_on_fetch_failure', default=False),
|
||||||
|
runbot_dockerfile_public_by_default=get_param('runbot.runbot_dockerfile_public_by_default', default=False),
|
||||||
)
|
)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@ -101,6 +103,7 @@ class ResConfigSettings(models.TransientModel):
|
|||||||
set_param('runbot.runbot_forwardport_author', self.runbot_forwardport_author)
|
set_param('runbot.runbot_forwardport_author', self.runbot_forwardport_author)
|
||||||
set_param('runbot.runbot_organisation', self.runbot_organisation)
|
set_param('runbot.runbot_organisation', self.runbot_organisation)
|
||||||
set_param('runbot.runbot_disable_host_on_fetch_failure', self.runbot_disable_host_on_fetch_failure)
|
set_param('runbot.runbot_disable_host_on_fetch_failure', self.runbot_disable_host_on_fetch_failure)
|
||||||
|
set_param('runbot.runbot_dockerfile_public_by_default', self.runbot_dockerfile_public_by_default)
|
||||||
|
|
||||||
@api.onchange('runbot_is_base_regex')
|
@api.onchange('runbot_is_base_regex')
|
||||||
def _on_change_is_base_regex(self):
|
def _on_change_is_base_regex(self):
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<field name="version_ids" widget="many2many_tags"/>
|
<field name="version_ids" widget="many2many_tags"/>
|
||||||
<field name="project_ids" widget="many2many_tags"/>
|
<field name="project_ids" widget="many2many_tags"/>
|
||||||
<field name="template_id"/>
|
<field name="template_id"/>
|
||||||
|
<field name="public_visibility"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
@ -105,6 +106,7 @@
|
|||||||
<field name="project_ids" widget="many2many_tags"/>
|
<field name="project_ids" widget="many2many_tags"/>
|
||||||
<field name="use_count"/>
|
<field name="use_count"/>
|
||||||
<field name="dockerfile" invisible="True"/>
|
<field name="dockerfile" invisible="True"/>
|
||||||
|
<field name="public_visibility"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
@ -37,6 +37,9 @@
|
|||||||
<setting>
|
<setting>
|
||||||
<field name="runbot_disable_host_on_fetch_failure"/>
|
<field name="runbot_disable_host_on_fetch_failure"/>
|
||||||
</setting>
|
</setting>
|
||||||
|
<setting>
|
||||||
|
<field name="runbot_dockerfile_public_by_default"/>
|
||||||
|
</setting>
|
||||||
</block>
|
</block>
|
||||||
|
|
||||||
<block title="Limits">
|
<block title="Limits">
|
||||||
|
Loading…
Reference in New Issue
Block a user