├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── build.sh ├── docker-compose.yml ├── nginx └── typecho └── supervisor.conf /.gitignore: -------------------------------------------------------------------------------- 1 | /app.tar.gz 2 | /app 3 | /dbdata 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | MAINTAINER vizee 3 | 4 | ENV DEBIAN_FRONTEND noninteractive 5 | RUN mv /etc/apt/sources.list /tmp/ && cat /tmp/sources.list | sed 's/archive.ubuntu.com/mirrors.aliyun.com/' > /etc/apt/sources.list && apt-get update 6 | RUN apt-get install -y tzdata supervisor nginx php-fpm php-xml php-pgsql && rm -rf /var/lib/apt/lists/* 7 | 8 | RUN echo "Asia/Shanghai" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata 9 | 10 | COPY supervisor.conf /etc/supervisor/ 11 | COPY nginx/typecho /etc/nginx/sites-available/ 12 | RUN rm -f /etc/nginx/sites-enabled/default && ln -snf /etc/nginx/sites-available/typecho /etc/nginx/sites-enabled/typecho 13 | RUN mkdir -p /run/php 14 | 15 | EXPOSE 80 16 | 17 | CMD ["supervisord", "-n", "-c", "/etc/supervisor/supervisor.conf"] 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 vizee 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # typecho-docker 2 | typecho + pgsql 镜像 3 | 4 | ## 环境 5 | * docker 6 | * docker-compose 7 | 8 | **注意**: docker-compose 版本应与 docker 对应, 例如:docker-compose 1.3.x 对应 docker 1.6 以及以后版本 9 | 10 | ## 构建 11 | ``` 12 | ./build.sh 13 | ``` 14 | 15 | ## 配置 16 | 17 | ### 数据库 18 | 镜像中默认配置博客使用 PGSQL, 相关环境变量在 `docker-compose.yml` 中设置 19 | 20 | [postgres配置](https://hub.docker.com/_/postgres/) 21 | 22 | ### typecho 23 | 默认情况下 24 | * 博客程序保存在当前目录下 `app` 文件夹中 25 | * 数据库文件保存在 `dbdata` 中 26 | * 端口映射到主机 80 端口, 在 `docker-compose.yml` 中配置 27 | * 镜像中 nginx 配置为 `nginx/typecho` 28 | * 数据库默认地址 29 | 30 | **注意**: 在构建完成并且容器运行后, 需要运行向导后可能需要手动创建 `config.inc.php` 31 | 32 | [端口配置](https://docs.docker.com/compose/compose-file/#ports) 33 | 34 | #### url重写 35 | 已在nginx中配置, 直接在后台设置`设置/永久连接/是否使用地址重写功能`强制启用 36 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | # !/bin/bash 2 | 3 | set -e 4 | 5 | pushd `dirname $0` > /dev/null 6 | 7 | if [ ! -d app/ ]; then 8 | echo "downloading typecho" 9 | DOWNLOAD_URL=https://github.com/typecho/typecho/releases/download/v1.0-14.10.10-release/1.0.14.10.10.-release.tar.gz 10 | wget $DOWNLOAD_URL -O app.tar.gz 11 | tar xzf app.tar.gz 12 | mv build/ app/ 13 | fi 14 | 15 | docker-compose build 16 | 17 | popd > /dev/null 18 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | db: 2 | image: postgres:9.5 3 | environment: 4 | - POSTGRES_USER=typechoer 5 | - POSTGRES_PASSWORD=typechopwd 6 | - POSTGRES_DB=typechodb 7 | - PGDATA=/pgsql/dbdata 8 | volumes: 9 | - ./dbdata:/pgsql/dbdata 10 | typecho: 11 | build: . 12 | volumes: 13 | - ./app:/app/typecho 14 | ports: 15 | - "80:80" 16 | links: 17 | - db 18 | -------------------------------------------------------------------------------- /nginx/typecho: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | #listen [::]:80 default_server ipv6only=on; 4 | root /app/typecho/; 5 | index index.php; 6 | server_name localhost; 7 | location / { 8 | try_files $uri $uri/ /index.php?$query_string; 9 | } 10 | location ~ \.php$ { 11 | include snippets/fastcgi-php.conf; 12 | 13 | #fastcgi_split_path_info ^(.+\.php)(/.+)$; 14 | fastcgi_pass unix:/run/php/php7.0-fpm.sock; 15 | #fastcgi_index index.php; 16 | #include fastcgi_params; 17 | } 18 | location ~ /\. { 19 | deny all; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /supervisor.conf: -------------------------------------------------------------------------------- 1 | [unix_http_server] 2 | file=/var/run/supervisor.sock 3 | chmod=0700 4 | 5 | [supervisord] 6 | logfile=/var/log/supervisor/supervisord.log 7 | pidfile=/var/run/supervisord.pid 8 | childlogdir=/var/log/supervisor 9 | logfile_maxbytes=50MB 10 | logfile_backups=10 11 | user=root 12 | 13 | [rpcinterface:supervisor] 14 | supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface 15 | 16 | [supervisorctl] 17 | serverurl=unix:///var/run/supervisor.sock 18 | 19 | [program:nginx] 20 | command=/usr/sbin/nginx -g "daemon off;" 21 | autostart=true 22 | autorestart=true 23 | priority=888 24 | ;stdout_events_enabled=true 25 | ;stderr_events_enabled=true 26 | 27 | [program:php-fpm7.0] 28 | command=/usr/sbin/php-fpm7.0 -F 29 | autostart=true 30 | autorestart=true 31 | priority=777 32 | --------------------------------------------------------------------------------