Sign inSign up

stratosgear/readthedocs-docker

By stratosgear

•Updated almost 9 years ago

Host a local version of the readthedocs server

Image
2

764

stratosgear/readthedocs-docker repository overview

⁠ReadTheDocs in Docker

A Docker⁠ container for ReadTheDocs⁠ (RTD) which works and with many goodies.

⁠Features

  • Optional database backend
  • Optional Redis+Celery support
  • Optional ElasticSearch support (untested)
  • Painless subdomain serving (i.e. {project}.docs.domain.com)
  • Correctly handles alternative domain names for projects
  • Want more? Open an issue or submit a pull request!

⁠Installation

⁠Standalone

Simply launch a docker run with relevant params.

$ docker run \
    -e RTD_PRODUCTION_DOMAIN=example.com \
    -e RTD_USE_SUBDOMAIN=true \
    -e RTD_ALLOW_PRIVATE_REPOS=true \
    -p 8000:80 \
    -d \
    floross/docker-readthedocs
⁠Compose

Create a compose file:

$ cp docker-compose.yml{.example,}

Adjust to your desired configuration, then start:

$ docker-compose up

⁠Configurations / Environments

You can configure RTD's comportment with a bunch of environment variables described below.

⁠Read the docs environment

All the RTD environment are prefixed with RTD_

NameDescriptionDefault valueRTD config.py target (if any)
RTD_DEBUGStart RTD in debug mode'false'DEBUG
RTD_ALLOW_PRIVATE_REPOSConfigure RTD to let you use private repository (with credential inside the url)'false'ALLOW_PRIVATE_REPOS
RTD_ACCOUNT_EMAIL_VERIFICATIONIf none turn off email verification'none'ACCOUNT_EMAIL_VERIFICATION
RTD_PRODUCTION_DOMAINThe production domain use for nginx and RTD to configure the urls'localhost:8000'PRODUCTION_DOMAIN
RTD_PUBLIC_DOMAINThe public domain of the applicationValue of RTD_PRODUCTION_DOMAINPUBLIC DOMAIN
RTD_USE_SUBDOMAINDisable the /docs/<project> RTD routes and use only the subdomain'false'USE_SUBDOMAIN
RTD_GLOBAL_ANALYTICS_CODEYour analytics code''GLOBAL_ANALYTICS_CODE
RTD_ADMIN_USERNAMEThe username of the superuser account to create'admin'-
RTD_ADMIN_PASSWORDThe password of the superuser account to create'admin'-
RTD_ADMIN_EMAILThe email address of the superuser account to create'{RTD_ADMIN_USERNAME}@localhost-
RTD_SLUMBER_USERNAMEThe username of the Slumber API account to create'slumber'SLUMBER_USERNAME
RTD_SLUMBER_PASSWORDThe password of the Slumber API account to create'slumber'SLUMBER_PASSWORD
RTD_SLUMBER_EMAILThe email address of the Slumber API account to create'{RTD_SLUMBER_USERNAME}@localhost-
RTD_SLUMBER_API_HOSTConfigure the host of the RTD slumber api'http://localhost:8000'SLUMBER_API_HOST
RTD_HAS_DATABASEConfigure Django with a database if 'true' (see below)'false'-
RTD_HAS_ELASTICSEARCHConfigure the app with an ElasticSearch endpoint if 'true' (see below)'false'-
RTD_HAS_REDISConfigure the app with a Redis endpoint if 'true' (see below)'false'-

To enable a postgre database, an elasticsearch server or a redis you will need to configure this following environment variable to true: RTD_HAS_DATABASE, RTD_HAS_ELASTICSEARCH, RTD_HAS_REDIS

⁠Database (if $RTD_HAS_DATABASE == 'true')

These vars are automatically assigned by docker-compose from the env vars of the db container (i.e. db's DB_NAME env var is accessible by readthedocs as DB_ENV_DB_NAME). If you're not using docker-compose, feel free to set these directly for the readthedocs container if you wish to connect to a database.

NameDescriptionDefault valueRTD config.py target (if any)
DB_ENV_ENGINEDjango DB engine'django.db.backends.postgresql_psycopg2'DATABASES['default']['ENGINE']
DB_ENV_DB_NAMEDB name'readthedocs'DATABASES['default']['NAME']
DB_ENV_DB_USERDB user'root'DATABASES['default']['USER']
DB_ENV_DB_PASSDB passwordNoneDATABASES['default']['PASSWORD']
DB_ENV_HOSTDB host'localhost'DATABASES['default']['HOST']
DB_ENV_PORTDB port5432DATABASES['default']['PORT']

These settings are ignored if the env var RTD_HAS_DATABASE is not set to 'true'.

⁠ElasticSearch (UNTESTED) (if $RTD_HAS_ELASTICSEARCH == 'true')

These vars are automatically assigned by docker-compose from the env vars of the elasticsearch container (i.e. elasticsearch's HOST env var is accessible by readthedocs as ELASTICSEARCH_ENV_HOST). If you're not using docker-compose, feel free to set these directly for the readthedocs container if you wish to use elasticsearch.

NameDescriptionDefault valueRTD config.py target (if any)
ELASTICSEARCH_ENV_HOSTElasticsearch host'localhost'ES_HOSTS[0] (as {host}:{port})
ELASTICSEARCH_ENV_PORTElasticsearch port'9200'ES_HOSTS[0] (as {host}:{port})

These settings are ignored if the env var RTD_HAS_ELASTICSEARCH is not set to 'true'.

⁠Redis (if $RTD_HAS_REDIS == 'true')

These vars are automatically assigned by docker-compose from the env vars of the redis container (i.e. redis's HOST env var is accessible by readthedocs as REDIS_ENV_HOST). If you're not using docker-compose, feel free to set these directly for the readthedocs container if you wish to use redis.

Using Redis will start a celery worker on readthedocs to handle build tasks.

NameDescriptionDefault valueRTD config.py target (if any)
REDIS_ENV_HOSTRedis host'localhost'REDIS['host']
REDIS_ENV_PORTRedis port'6379'REDIS['port']
REDIS_ENV_DBRedis database'0'REDIS['db']

Enabling Redis will start a celery worker on readthedocs to handle build tasks. It will also set the following flags on config.py:

  • BROKER_URL is set to 'redis://{host}:{port}/{db}' ;
  • CELERY_RESULT_BACKEND is set to 'redis://{host}:{port}/{db}' ;
  • CELERY_ALWAYS_EAGER is set to False.

These settings are ignored if the env var RTD_HAS_REDIS is not set to 'true'.


Credits to moul/docker-readthedocs⁠

Credits to vassilvk/readthedocs-docker⁠

Tag summary

Content type

Image

Digest

Size

1.3 GB

Last updated

almost 9 years ago

docker pull stratosgear/readthedocs-docker