mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +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,
|
||||
'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>
|
||||
</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">
|
||||
<field name="key">runbot.runbot_is_base_regex</field>
|
||||
<field name="value">^((master)|(saas-)?\d+\.\d+)$</field>
|
||||
|
@ -850,8 +850,7 @@ class BuildResult(models.Model):
|
||||
ro_volumes[f'/data/build/{dest}'] = source
|
||||
if 'image_tag' not in kwargs:
|
||||
kwargs.update({'image_tag': self.params_id.dockerfile_id.image_tag})
|
||||
if kwargs['image_tag'] != 'odoo:DockerDefault':
|
||||
self._log('Preparing', 'Using Dockerfile Tag %s' % kwargs['image_tag'])
|
||||
self._log('Preparing', 'Using Dockerfile Tag [%s](/runbot/dockerfile/tag/%s)' % (kwargs['image_tag'], kwargs['image_tag']), log_type='markdown')
|
||||
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:
|
||||
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')
|
||||
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, ...)
|
||||
# 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')]
|
||||
|
||||
|
@ -29,6 +29,7 @@ class ResConfigSettings(models.TransientModel):
|
||||
runbot_forwardport_author = fields.Char('Forwardbot author')
|
||||
runbot_organisation = fields.Char('Organisation')
|
||||
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_db_gc_days = fields.Integer(
|
||||
@ -77,6 +78,7 @@ class ResConfigSettings(models.TransientModel):
|
||||
runbot_forwardport_author=get_param('runbot.runbot_forwardport_author', 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_dockerfile_public_by_default=get_param('runbot.runbot_dockerfile_public_by_default', default=False),
|
||||
)
|
||||
return res
|
||||
|
||||
@ -101,6 +103,7 @@ class ResConfigSettings(models.TransientModel):
|
||||
set_param('runbot.runbot_forwardport_author', self.runbot_forwardport_author)
|
||||
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_dockerfile_public_by_default', self.runbot_dockerfile_public_by_default)
|
||||
|
||||
@api.onchange('runbot_is_base_regex')
|
||||
def _on_change_is_base_regex(self):
|
||||
|
@ -14,6 +14,7 @@
|
||||
<field name="version_ids" widget="many2many_tags"/>
|
||||
<field name="project_ids" widget="many2many_tags"/>
|
||||
<field name="template_id"/>
|
||||
<field name="public_visibility"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="description"/>
|
||||
@ -105,6 +106,7 @@
|
||||
<field name="project_ids" widget="many2many_tags"/>
|
||||
<field name="use_count"/>
|
||||
<field name="dockerfile" invisible="True"/>
|
||||
<field name="public_visibility"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -37,6 +37,9 @@
|
||||
<setting>
|
||||
<field name="runbot_disable_host_on_fetch_failure"/>
|
||||
</setting>
|
||||
<setting>
|
||||
<field name="runbot_dockerfile_public_by_default"/>
|
||||
</setting>
|
||||
</block>
|
||||
|
||||
<block title="Limits">
|
||||
|
Loading…
Reference in New Issue
Block a user