今天给大家介绍“Read the Fuck Document”,现在真的有人做了这个站点,提供项目文档托管服务,大致是想提供一站式的文档阅读服务。
目前看到知名的文档项目托管者有 Flask、Django-cms等。特色功能:
支持使用版本控制系统(SVN/HG/Git…)的更新;
提供文档的短地址,比如 flask.rtfd.org,看见这个我就笑了;
提供多版本兼容;
用 Dajngo 搭建的系统,该系统是开源的;
readthedocs这个网站还真不错,提供了文档托管服务,让很多开源项目的文档变得很完善下面请看怎么快速部署,下面就是通过docker快速部署它。
目录结构如下:
dockerfile如下
FROM docker.io/centos:latest
MAINTAINER zailing
RUN yum clean all
RUN yum install -y yum-plugin-fastestmirror yum-utils epel-release
RUN yum update -y
# utils
RUN yum install -y git hostname sudo less iproute psmisc net-tools \
bash unzip which tar passwd ed m4 patch rsync wget curl tcpdump telnet \
tar bzip2 unzip strace supervisor openssl openssh openssh-server \
openssh-clients util-linux inotify-tools
# dev
RUN yum install -y gcc-c++ libtool make gdb mariadb-devel snappy-devel \
boost-devel lz4-devel zlib-devel libcurl-devel libevent-devel \
libesmtp-devel libuuid-devel libcsv-devel cyrus-sasl-devel \
bzip2-devel libpqxx-devel libxml2-devel libxslt-devel libxslt-python \
libpng-devel jemalloc-devel fontconfig-devel pcre-devel
# deps
RUN yum install -y redis sqlite mariadb mariadb-server postgresql
# python
RUN yum install -y python-pip python-devel python-lxml python-setuptools
# misc
RUN yum install -y expat gettext texlive* graphviz dvipng nodejs doxygen doxygen-latex
RUN mkdir /var/run/sshd
RUN ssh-keygen -t rsa -q -f /etc/ssh/ssh_host_rsa_key -P ""
RUN ssh-keygen -t dsa -q -f /etc/ssh/ssh_host_dsa_key -P ""
RUN ssh-keygen -t rsa -q -f /root/.ssh/id_rsa -P ""
RUN cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys && chmod 600 /root/.ssh/authorized_keys
RUN echo 'root:123123' chpasswd
RUN sed -i 's/.*session.*required.*pam_loginuid.so.*/session optional pam_loginuid.so/g' /etc/pam.d/sshd
RUN echo -e "LANG=\"en_US.UTF-8\"" > /etc/default/local
RUN localedef -i en_US -f UTF-8 en_US.UTF-8
RUN cp /usr/lib64/mysql/libmysqlclient* /usr/lib64/
RUN rm -rf etc/localtime && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo "bind '\"\e[A\":history-search-backward'" >> /root/.bashrc
RUN echo "bind '\"\e[B\":history-search-forward'" >> /root/.bashrc
RUN echo "export HISTTIMEFORMAT='%F %T '" >> /root/.bashrc
EXPOSE 22
RUN chmod u+s /usr/bin/ping
ENV APPDIR=/app/opt/readthedocs
ENV DJANGO_SETTINGS_MODULE=readthedocs.settings.config
COPY ./readthedocs.org-master.zip /tmp/
RUN cd /tmp/ && unzip ./readthedocs.org-master.zip && mv readthedocs.org-master readthedocs
RUN pip install --upgrade pip
RUN cd /tmp/readthedocs/ && pip install -r requirements.txt
RUN pip install sphinx sphinx-autobuild
RUN cd /tmp && git clone https://github.com/mysql/mysql-connector-python.git \
&& cd mysql-connector-python/ && python ./setup.py build && python ./setup.py install
# wget http://mirrors.ustc.edu.cn/CTAN/macros/latex/contrib/upquote.zip
RUN for i in cmap fancybox titlesec framed threeparttable mdwtools wrapfig parskip multirow filemod; do \
curl -L -o /tmp/$i.zip http://mirrors.ustc.edu.cn/CTAN/macros/latex/contrib/$i.zip && unzip -o -d /usr/share/texlive/texmf-dist/tex/latex/ /tmp/$i.zip; texhash; \
done
RUN for i in ifplatform fancyvrb float upquote capt-of needspace eqparbox environ pstool trimspaces; do \
curl -L -o /tmp/$i.zip http://mirrors.ustc.edu.cn/CTAN/macros/latex/contrib/$i.zip && unzip -o -d /usr/share/texlive/texmf-dist/tex/latex/ /tmp/$i.zip; \
cd /usr/share/texlive/texmf-dist/tex/latex/$i && rm -rf $i.sty && latex $i.ins && cd - ;\
texhash; \
done
RUN cd /usr/share/texlive/texmf-dist/tex/latex/trimspaces && cp pstool.sty trimspaces.sty && texhash
ADD ./config.py /root/
COPY ./readthedocs.org-master.zip /root/
RUN rm -rf /tmp/*.zip
EXPOSE 8000
ENV RTD_HAS_ELASTICSEARCH=false
ENV ELASTICSEARCH_ENV_HOST=localhost
ENV ELASTICSEARCH_ENV_PORT=9200
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
VOLUME ["/opt/app"]
RUN yum clean all
ADD container-files /
RUN chmod +x /config/bootstrap.sh
RUN chmod +x -f /config/init/*.sh; exit 0
docker-compose的书写格式如下 docker-compose.yml
version: '2'
services:
readthedocs:
build: .
image: zailing/readthedocs
container_name: readthedocs
hostname: readthedocs
privileged: true
read_only: false
tty: false
network_mode: "bridge"
ulimits:
nofile:
soft: 102400
hard: 102400
ports:
- "123.56.116.82:2243:22"
- "8000:8000"
volumes:
- /opt/docker/readthedocs:/opt/app
environment:
- RTD_HAS_ELASTICSEARCH=true
- ELASTICSEARCH_ENV_HOST=123.56.116.82
- ELASTICSEARCH_ENV_PORT=9200
领取专属 10元无门槛券
私享最新 技术干货