Code Monkey home page Code Monkey logo

docker-stack's Introduction

docker-stack

基于 Docker 的个人服务器一键环境。

License Author

使用方法 Usage

DNMP

本项目的 DNMP 包含了以下容器:

  • Nginx:负责反向代理所有容器站点,也可以运行静态站点,按需求配置
  • Apache:负责运行静态和 PHP 站点
  • PHP-FPM:负责运行 PHP 程序,同时支持运行 Swoole。
  • MySQL & PostgreSQL:数据库

容器中服务的配置都存储于 service 文件夹中,数据都存储于 data 文件夹中,日志都存储于 logs 下,web/wwwroot 为网站目录,share 为所有容器中的共享目录,如果有需要在各容器中或宿主机**享文件或文件夹,可以存储于该文件夹。

启动

  1. 先修改下 bin/dnmp 脚本内的 DNMP_DIR 变量为你的 dnmp 目录。
  2. 然后在 dnmp 下运行 docker-compose up -d 或者运行 bin/dnmp up 即可完成启动。

配置

Apache 和 Nginx 配置使用 devilbox/vhost-gen,具体命令见下方:

  • 创建静态站点(Nginx,HttpOnly)
bin/nginx-vg -p /data/wwwroot/<you_host> -n <you_host> -s
docker restart nginx
  • 创建 PHP 站点(Apache,HttpOnly)
bin/apache-vg -p /data/wwwroot/<you_host> -n <you_host> -s
bin/nginx-vg -r http://apache:80 -n <you_host> -l / -s
docker restart apache
docker restart nginx
  • 创建 Https 站点(Nginx,Https)

使用文件验证方法

# 先创建一个临时的 Http 站点用于申请 ssl 证书
bin/nginx-vg -p /data/wwwroot/<you_host> -n <you_host> -s
docker restart nginx
# 申请 ssl 证书(使用文件验证方法)
bin/acme --issue -d <you_host> --webroot /data/wwwroot/<you_host>
# 将站点升级为 Https
bin/nginx-vg -p /data/wwwroot/<you_host> -n <you_host> -s -m let
docker restart nginx

使用 DNS 验证方法(DNSPod 为例)

# 修改 .env 下的 DP_ID, DP_KEY 这是对应 DNS 提供商的 API,按 ACME 的文档进行设置
# 申请 ssl 证书
bin/acme --issue --dns dns_dp -d <you_host>
# 创建 Nginx 反代或者静态站点
bin/nginx-vg -p /data/wwwroot/lincdn.top -n lincdn.top -m let -s
bin/nginx-vg -r <proxy_url> -n <you_host> -m let -l / -s
docker restart nginx
  • 创建 Https 站点(Apache,Https)

使用文件验证方法

# 先创建一个临时的 Http 站点用于申请 ssl 证书
bin/nginx-vg -p /data/wwwroot/<you_host> -n <you_host> -s
docker restart nginx
# 申请 ssl 证书(使用文件验证方法)
bin/acme --issue -d <you_host> --webroot /data/wwwroot/<you_host>
# 创建 Apache 站点
bin/apache-vg -p /data/wwwroot/<you_host> -n <you_host> -s -m let
# 将 Nginx 反代升级为 Https
bin/nginx-vg -r https://apache:443 -n <you_host> -l / -s -m let
docker restart apache
docker restart nginx

使用 DNS 验证方法(DNSPod 为例)

# 修改 .env 下的 DP_ID, DP_KEY 这是对应 DNS 提供商的 API,按 ACME 的文档进行设置
# 申请 ssl 证书
bin/acme --issue --dns dns_dp -d <you_host>
# 创建 Nginx 反代和 Apache 站点
bin/nginx-vg -r https://apache:443 -n <you_host> -m let -l / -s
bin/apache-vg -p /data/wwwroot/<you_host> -n <you_host> -m let -s
docker restart apache
docker restart nginx

数据库密码,各种服务的版本,PHP 插件等配置修改 .env 文件中的环境变量即可。

后续增加服务

DNMP 启动后,我们可以很方便的添加额外的服务到 DNMP 网络中。在 apps 下一个 Portainer Docker 管理面板的案例,你可以参考该样例进行后续服务的添加。

# 请注意为所有需要加入 DNMP 网络的 docker-compose.yml 文件中都加入这些配置
networks:
  default:
    external:
      name: dnmp

额外的容器启动后,我们可以到 NPM 中配置反向代理即可完成服务的添加。

维护者 Maintainer

docker-stack 由 Otstar Lin 和下列 贡献者 的帮助下撰写和维护。

Otstar Lin - Personal Website · Blog · Github

许可证 License

License

根据 MIT License 许可证开源。

docker-stack's People

Contributors

syfxlin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.