diff --git a/docs/development/buildenvironments.rst b/docs/development/buildenvironments.rst index a6804680ffb..66f885f5684 100644 --- a/docs/development/buildenvironments.rst +++ b/docs/development/buildenvironments.rst @@ -35,9 +35,17 @@ option. After this image is downloaded, you can update your settings to use the new image -- see `Configuration`_. +.. warning:: + + There is a known bug when using our Docker images on Linux to build project's documentation that uses Conda. + In case you need to work locally with projects that need Conda to build, + you will need to re-build our Docker image to adjust some filesystem user persmissions. + See our `current work in progress guide`_ for more information. + .. _`Docker`: http://docker.com .. _`Docker Hub repository`: https://hub.docker.com/r/readthedocs/build/ .. _`container image repo`: https://github.com/rtfd/readthedocs-docker-images +.. _`current work in progress guide`: https://github.com/rtfd/readthedocs.org/pull/4608 Configuration ------------- diff --git a/readthedocs/doc_builder/environments.py b/readthedocs/doc_builder/environments.py index 4d9fcb65e50..3460176271c 100644 --- a/readthedocs/doc_builder/environments.py +++ b/readthedocs/doc_builder/environments.py @@ -1041,6 +1041,7 @@ def create_container(self): host_config=self.get_container_host_config(), detach=True, environment=self.environment, + user=settings.DOCKER_USER, ) client.start(container=self.container_id) except ConnectionError: diff --git a/readthedocs/settings/base.py b/readthedocs/settings/base.py index f4f55635be8..3e12571e04f 100644 --- a/readthedocs/settings/base.py +++ b/readthedocs/settings/base.py @@ -340,6 +340,15 @@ def USE_PROMOS(self): # noqa # This settings has been deprecated in favor of DOCKER_IMAGE_SETTINGS DOCKER_BUILD_IMAGES = None DOCKER_LIMITS = {'memory': '200m', 'time': 600} + + # User used to create the container. + # In production we use the same user than the one defined by the + # ``USER docs`` instruction inside the Dockerfile. + # In development, we can use the "UID:GID" of the current user running the + # instance to avoid file permissions issues. + # https://docs.docker.com/engine/reference/run/#user + DOCKER_USER = 'docs:docs' + DOCKER_DEFAULT_IMAGE = 'readthedocs/build' DOCKER_VERSION = 'auto' DOCKER_DEFAULT_VERSION = 'latest' diff --git a/readthedocs/settings/dev.py b/readthedocs/settings/dev.py index 48c6e13ae36..cbe0b0a24c7 100644 --- a/readthedocs/settings/dev.py +++ b/readthedocs/settings/dev.py @@ -54,6 +54,10 @@ def DATABASES(self): # noqa # Disable password validators on development AUTH_PASSWORD_VALIDATORS = [] + # UID and GID used to create the Docker container. It defaults to the + # current UID and GID that it's running the Django app. + DOCKER_USER = f'{os.geteuid()}:{os.getegid()}' + @property def LOGGING(self): # noqa - avoid pep8 N802 logging = super().LOGGING