├── .dockerignore ├── config ├── etc │ └── default │ │ ├── locale │ │ └── rtd-config.py └── bin │ ├── rtd-start.sh │ └── rtd-install.sh ├── .gitignore ├── .travis.yml ├── Makefile ├── README.md ├── docker-compose.yml ├── LICENSE └── Dockerfile /.dockerignore: -------------------------------------------------------------------------------- 1 | pgsql 2 | es 3 | user_build 4 | -------------------------------------------------------------------------------- /config/etc/default/locale: -------------------------------------------------------------------------------- 1 | LANG="fr_FR.UTF-8" 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *# 3 | .#* 4 | pgsql 5 | user_builds 6 | es 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | install: 2 | - curl -sLo - http://j.mp/install-travis-docker | sh -xe 3 | 4 | script: 5 | - ./run 'docker build -t moul/readthedocs . && docker run --entrypoint=bash moul/readthedocs -ec "echo Build succeed"' 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | NAME = moul/readthedocs 2 | 3 | build: 4 | docker build -t $(NAME) . 5 | 6 | release: 7 | docker push $(NAME) 8 | 9 | run: 10 | docker-compose run --service-ports --rm readthedocs 11 | debug-run: 12 | docker-compose run --service-ports --rm readthedocs bash 13 | debug-app: 14 | docker exec -ti dockerreadthedocs_readthedocs_run_9 bash 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Readthedocs in Docker 2 | 3 | A Docker container of Readthedocs (RTD). 4 | 5 | ## Usage 6 | 7 | Run using docker-compose: 8 | 9 | * start a readthedocs container + its dependencies (postgresql, elasticsearch and redis) 10 | 11 | ```console 12 | $ docker-compose run --service-ports --rm readthedocs 13 | # or 14 | $ make run 15 | ``` 16 | 17 | --- 18 | 19 | Run in debug mode (bash) : 20 | 21 | make debug-run 22 | # or 23 | docker run -it --rm --entrypoint=bash moul/readthedocs 24 | 25 | ## License 26 | 27 | MIT 28 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | db: 2 | image: sameersbn/postgresql:9.1-1 3 | environment: 4 | - DB_USER=docs 5 | - DB_PASS=secretpassword 6 | - DB_NAME=docs 7 | volumes: 8 | - ./pgsql:/var/lib/postgresql 9 | readthedocs: 10 | build: . 11 | ports: 12 | - "8000:8000" 13 | links: 14 | - db 15 | - elasticsearch 16 | - redis 17 | volumes: 18 | - ./user_builds:/app/user_builds 19 | elasticsearch: 20 | image: jfroche/elasticsearch 21 | ports: 22 | - "9200:9200" 23 | volumes: 24 | - ./es:/var/lib/elasticsearch 25 | redis: 26 | image: redis 27 | -------------------------------------------------------------------------------- /config/bin/rtd-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | curl -XPUT 'http://elasticsearch:9200/readthedocs/' 4 | 5 | cd /app/readthedocs 6 | ln -s ../manage.py . 7 | 8 | PYTHON=/venv/bin/python 9 | $PYTHON manage.py syncdb --noinput 10 | $PYTHON manage.py migrate 11 | echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'admin@localhost', 'admin')" | $PYTHON manage.py shell 12 | $PYTHON manage.py loaddata test_data 13 | $PYTHON manage.py makemessages --all 14 | $PYTHON manage.py compilemessages 15 | 16 | export C_FORCE_ROOT="true" 17 | /venv/bin/python manage.py celeryd -l INFO & 18 | /venv/bin/python manage.py runserver 0.0.0.0:8000 19 | -------------------------------------------------------------------------------- /config/etc/default/rtd-config.py: -------------------------------------------------------------------------------- 1 | from readthedocs.settings.dev import * 2 | 3 | import os 4 | environ = os.environ 5 | 6 | DATABASES = { 7 | 'default': { 8 | 'ENGINE': 'django.db.backends.postgresql_psycopg2', 9 | 'NAME': environ['DB_ENV_DB_NAME'], 10 | 'USER': environ['DB_ENV_DB_USER'], 11 | 'PASSWORD': environ['DB_ENV_DB_PASS'], 12 | 'HOST': 'db', 13 | 'PORT': 5432, 14 | } 15 | } 16 | SITE_ROOT = '/app' 17 | ES_HOSTS = ['elasticsearch:9200'] 18 | REDIS = { 19 | 'host': 'redis', 20 | 'port': 6379, 21 | 'db': 0, 22 | } 23 | BROKER_URL = 'redis://redis:6379/0' 24 | CELERY_RESULT_BACKEND = 'redis://redis:6379/0' 25 | DEBUG = True 26 | CELERY_ALWAYS_EAGER = False 27 | -------------------------------------------------------------------------------- /config/bin/rtd-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd $APPDIR 3 | 4 | set -e 5 | 6 | unzip /tmp/master.zip >/dev/null 2>/dev/null && \ 7 | mv readthedocs.org-master/* readthedocs.org-master/.??* . && \ 8 | rmdir readthedocs.org-master 9 | 10 | PYTHON=/venv/bin/python 11 | PIP=/venv/bin/pip 12 | 13 | cp -f /etc/default/rtd-config.py $APPDIR/readthedocs/config.py 14 | $PIP install -U \ 15 | --allow-external bzr --allow-unverified bzr \ 16 | -r $APPDIR/requirements.txt 17 | cd $APPDIR && /venv/bin/python setup.py develop 18 | cd $APPDIR/readthedocs 19 | chown -R py $APPDIR 20 | $PIP install psycopg2 21 | /usr/bin/pip install psycopg2 22 | /usr/bin/pip install git+https://github.com/rtfd/readthedocs-sphinx-ext.git 23 | ln -s /app/readthedocs/core/static /app/media/ 24 | mkdir -p /app/prod_artifacts/media 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Manfred Touron 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER Manfred Touron "m@42.am" 3 | 4 | ENV DEBIAN_FRONTEND noninteractive 5 | ENV APPDIR /app 6 | ENV DJANGO_SETTINGS_MODULE config 7 | ENV LANG en_US.UTF-8 8 | ENV LC_ALL en_US.UTF-8 9 | ENV VIRTUAL_ENV /venv 10 | ENV PATH /venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 11 | 12 | # Set locale to UTF-8 13 | RUN locale-gen en_US.UTF-8 && \ 14 | update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 15 | RUN locale-gen fr_FR.UTF-8 16 | # Update python 17 | RUN apt-get -qq update && \ 18 | apt-get -y -qq upgrade && \ 19 | apt-get install -y -qq \ 20 | python libxml2-dev libxslt1-dev expat libevent-dev wget python-dev \ 21 | texlive texlive-latex-extra language-pack-en unzip git python-pip \ 22 | zlib1g-dev lib32z1-dev libpq-dev gettext curl && \ 23 | apt-get clean 24 | 25 | # Install test dependencies 26 | RUN pip install -q \ 27 | virtualenv \ 28 | pep8 \ 29 | mock \ 30 | nose \ 31 | coverage \ 32 | pylint 33 | 34 | # Setting up virtualenv 35 | RUN virtualenv /venv 36 | 37 | # Add user py 38 | RUN adduser --gecos 'py' --disabled-password py 39 | 40 | RUN mkdir -p $APPDIR && cd /tmp && \ 41 | wget -q --no-check-certificate https://github.com/rtfd/readthedocs.org/archive/master.zip 42 | 43 | ADD config / 44 | 45 | RUN /bin/rtd-install.sh 46 | 47 | # Docker config 48 | EXPOSE 8000 49 | VOLUME ["/app"] 50 | CMD ["/bin/rtd-start.sh"] 51 | --------------------------------------------------------------------------------