-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add docker image from the YAML config integration #3339
Changes from 6 commits
442c68a
961c18e
aa15e78
a705f9d
eb7c4b2
8d1a58d
c27686e
67d5595
5708f10
edfca36
d0ee0f7
da7ec2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,19 +80,20 @@ The ``build`` block configures specific aspects of the documentation build. | |
build.image | ||
``````````` | ||
|
||
* Default: ``2.0`` | ||
|
||
* Default: :djangosetting:`DOCKER_IMAGE` | ||
* Options: ``1.0``, ``2.0``, ``latest`` | ||
|
||
The docker image to use for specific builds. | ||
This lets users specify a more experimental builder, | ||
The build image to use for specific builds. | ||
This lets users specify a more experimental build image, | ||
if they want to be on the cutting edge. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency and clarity: "docker image" -> "build image" |
||
|
||
Certain Python versions require a certain builder, | ||
Certain Python versions require a certain build image, | ||
as defined here:: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same on "builder" here, builder is an internal term, this refers to the build image instead. |
||
|
||
* '1.0': 2, 2.7, 3, 3.4 | ||
* '2.0': 2, 2.7, 3, 3.5 | ||
* 'latest': 2, 2.7, 3, 3.3, 3.4, 3.5, 3.6 | ||
* `'1.0': 2, 2.7, 3, 3.4` | ||
* `'2.0': 2, 2.7, 3, 3.5` | ||
* `'latest': 2, 2.7, 3, 3.3, 3.4, 3.5, 3.6` | ||
|
||
.. code-block:: yaml | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
from readthedocs_build.config import load as load_config | ||
from readthedocs_build.config import BuildConfig, ConfigError, InvalidConfig | ||
|
||
from .constants import DOCKER_IMAGE_SETTINGS, DOCKER_IMAGE | ||
|
||
|
||
class ConfigWrapper(object): | ||
|
||
|
@@ -57,7 +59,7 @@ def python_interpreter(self): | |
list( | ||
filter( | ||
lambda x: x < ver + 1, | ||
self._yaml_config.PYTHON_SUPPORTED_VERSIONS, | ||
self._yaml_config.get_valid_python_versions(), | ||
))) | ||
return 'python{0}'.format(ver) | ||
|
||
|
@@ -110,10 +112,8 @@ def formats(self): | |
def build_image(self): | ||
if self._project.container_image: | ||
# Allow us to override per-project still | ||
assert 'readthedocs/build' in self._project.container_image, ( | ||
'container image must be fully qualified') | ||
return self._project.container_image | ||
return 'readthedocs/build:{}'.format(self._yaml_config['build']['image']) | ||
return self._yaml_config['build']['image'] | ||
|
||
# Not implemented until we figure out how to keep in sync with the webs. | ||
# Probably needs to be version-specific as well, not project. | ||
|
@@ -133,8 +133,24 @@ def load_yaml_config(version): | |
parsing consistent between projects. | ||
""" | ||
checkout_path = version.project.checkout_path(version.slug) | ||
env_config = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is not needed. You are re-creating it some lines below. |
||
|
||
# Get build image to set up the python version validation. Pass in the | ||
# build image python limitations to the loaded config so that the versions | ||
# can be rejected at validation | ||
|
||
img_name = version.project.container_image or DOCKER_IMAGE | ||
env_config = { | ||
'build': { | ||
'image': img_name, | ||
} | ||
} | ||
img_settings = DOCKER_IMAGE_SETTINGS.get(img_name, None) | ||
if img_settings: | ||
env_config.update(img_settings) | ||
|
||
try: | ||
sphinx_env_config = {} | ||
sphinx_env_config = env_config.copy() | ||
sphinx_env_config.update({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can just create the dict at this line instead of |
||
'output_base': '', | ||
'type': 'sphinx', | ||
|
@@ -148,9 +164,8 @@ def load_yaml_config(version): | |
# This is a subclass of ConfigError, so has to come first | ||
raise | ||
except ConfigError: | ||
# Just fall back to defaults | ||
config = BuildConfig( | ||
env_config={}, | ||
env_config=env_config, | ||
raw_config={}, | ||
source_file='empty', | ||
source_position=0, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,14 @@ | |
from __future__ import ( | ||
absolute_import, division, print_function, unicode_literals) | ||
|
||
import logging | ||
import os | ||
import re | ||
|
||
from django.conf import settings | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
SPHINX_TEMPLATE_DIR = os.path.join( | ||
settings.SITE_ROOT, | ||
'readthedocs', | ||
|
@@ -33,6 +36,13 @@ | |
) | ||
DOCKER_VERSION = getattr(settings, 'DOCKER_VERSION', 'auto') | ||
DOCKER_IMAGE = getattr(settings, 'DOCKER_IMAGE', 'readthedocs/build:2.0') | ||
DOCKER_IMAGE_SETTINGS = getattr(settings, 'DOCKER_IMAGE_SETTINGS', {}) | ||
|
||
old_config = getattr(settings, 'DOCKER_BUILD_IMAGES', None) | ||
if old_config: | ||
log.warning('Old config detected, DOCKER_BUILD_IMAGES->DOCKER_IMAGE_SETTINGS') | ||
DOCKER_IMAGE_SETTINGS.update(old_config) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This warning could be a good use of a django system check warning as well. |
||
|
||
DOCKER_LIMITS = {'memory': '200m', 'time': 600} | ||
DOCKER_LIMITS.update(getattr(settings, 'DOCKER_LIMITS', {})) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With settings re-enabled, this can be pulled from settings. See
settings.rst
anddoc_extensions.py
inconf/