Docker 部署 ghost + nginx + mysql
程序员文章站
2024-03-12 08:29:32
...
部署前先分层:
用户–>nginx–>ghost(app)–>mysql
创建 3 个容器
层级目录
|── data
├── docker-compose.yml
├── ghost
│ ├── Dockerfile
│ └── config.production.json
└── nginx
├── Dockerfile
└── nginx.conf
ghost
Deckerfile
FROM ghost
COPY ./config.production.json /var/lib/ghost/content/config.production.json
EXPOSE 2368
#CMD ["npm","start","--production"]
config.production.json
{
"url": "http://localhost:2368/",
"server": {
"port": 2368,
"host": "0.0.0.0"
},
"database": {
"client": "mysql",
"connection": {
"host": "db",
"user": "ghost",
"password": "ghost",
"database": "ghost",
"port": 3306,
"charset": "utf8"
}
},
"mail": {
"transport": "Direct"
},
"logging": {
"transports": [
"file",
"stdout"
]
},
"process": "systemd",
"paths": {
"contentPath": "/var/lib/ghost/content"
}
}
nginx
Dockerfile
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
nginx.conf
worker_processes 4;
events {worker_connections 1024;}
http {
server {
listen 80;
location / {
proxy_pass http://ghost-app:2368;
}
}
}
data
用于存放数据库
docker-compose.yml
version: '2'
networks:
ghost:
services:
ghost-app:
build: ghost
networks:
- ghost
depends_on:
- db
ports:
- "2368:2368"
nginx:
build: nginx
networks:
- ghost
depends_on:
- ghost-app
ports:
- "80:80"
db:
image: "mysql:5.7.15"
networks:
- ghost
environment:
MYSQL_ROOT_PASSWORD: mysqlroot
MYSQL_USER: ghost
MYSQL_PASSWORD: ghost
volumes:
- $PWD/data:/var/lib/mysql
ports:
- "3306:3306"
创建好文件后,直接在当前目录下构建应用并运行
docker-compose up
推荐阅读
-
Docker 部署 ghost + nginx + mysql
-
docker部署nginx,redis,mysql
-
Centos 5.5 VPS下部署Rails3环境,RubyEE,+nginx+Passenger+mysql
-
php+mysql+nginx在linux上的环境部署_MySQL
-
Ubuntu下快速部署安装 Nginx + PHP + MySQL 笔记
-
docker-compose入门示例:一键部署 Nginx+Tomcat+Mysql
-
使用Docker部署Nginx+Flask+Mongo的应用
-
基于Docker、Nginx和Jenkins实现前端自动化部署
-
Docker部署MySQL8集群(一主二从)的实现步骤
-
docker完整配置nginx+php+mysql的方法步骤