Skip to content

Commit 4a53579

Browse files
committed
Merge pull request #1596 from rtfd/add-project-container-image
Add per-project, admin-only container image configuration
2 parents 8b1af68 + 277e9c0 commit 4a53579

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

readthedocs/doc_builder/environments.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,12 @@ def update_build_from_container_state(self):
564564
def create_container(self):
565565
'''Create docker container'''
566566
client = self.get_client()
567+
image = self.container_image
568+
if self.project.container_image is not None:
569+
image = self.project.container_image
567570
try:
568571
self.container = client.create_container(
569-
image=self.container_image,
572+
image=image,
570573
command=('/bin/sh -c "sleep {time}; exit {exit}"'
571574
.format(time=self.container_time_limit,
572575
exit=DOCKER_TIMEOUT_EXIT_CODE)),
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import models, migrations
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('projects', '0003_project_cdn_enabled'),
11+
]
12+
13+
operations = [
14+
migrations.AddField(
15+
model_name='project',
16+
name='container_image',
17+
field=models.CharField(max_length=64, null=True, verbose_name='Alternative container image', blank=True),
18+
),
19+
]

readthedocs/projects/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ class Project(models.Model):
108108
help_text=_('Type of documentation you are building. <a href="http://'
109109
'sphinx-doc.org/builders.html#sphinx.builders.html.'
110110
'DirectoryHTMLBuilder">More info</a>.'))
111+
112+
# Project features
111113
allow_comments = models.BooleanField(_('Allow Comments'), default=False)
112114
comment_moderation = models.BooleanField(_('Comment Moderation)'), default=False)
113115
cdn_enabled = models.BooleanField(_('CDN Enabled'), default=False)
@@ -116,6 +118,8 @@ class Project(models.Model):
116118
help_text=_("Google Analytics Tracking ID "
117119
"(ex. <code>UA-22345342-1</code>). "
118120
"This may slow down your page loads."))
121+
container_image = models.CharField(
122+
_('Alternative container image'), max_length=64, null=True, blank=True)
119123

120124
# Sphinx specific build options.
121125
enable_epub_build = models.BooleanField(

0 commit comments

Comments
 (0)