docker-compose 安装Ghost

一、依赖

    1、ghost:latest     应用程序

    2、nginx:latest    监听80端口将请求转发到ghost 处理

   3、mysql:5.7.15   ghost 的数据存储

二、准备工作

    1、data 存放mysql 数据与日志相关

    2、ghost存放Dockerfile文件与config.js

    3、nginx存放Dockerfile文件与nginx.conf

mkdir -p /data/docker/ghost/data

mkdir -p /data/docker/ghost/ghost
cd /date/docker/ghost
touch Dockerfile
touch config.js

mkdir -p /data/docker/ghost/ngix
cd /data/docker/nginx
touch Dockerfiler
touch nginx.conf

cd /data/docker/ghost
touch docker-compose.yml


三、相关文件内容

    1、ghost

        Dockerfile

FROM ghost
COPY ./config.js /var/lib/ghost/content/config.js
EXPOSE 2368

         config.js

var path = require(‘path’),
config;
config={
        production: {
                url: 'http://mytestblog.com',
                mail: {},
                database: {
                        client: 'mysql',
                        connection:  {
                                host: 'db',
                                user: 'ghost',
                                password: 'ghost',
                                database: 'ghost',
                                port: '3306',
                                charset: 'utf-8'
                        },
                        debug: false
                }
                paths: {
                        contentPath:path.join(process.evn.GHOST_CONTENT,'/')
                },
                server:{
                        host:'0.0.0.0',
                        port:'2368'
                }
        }
};
module.exports=config

    2、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;
                }
        }
}

    3、docker-compose

        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"

 

四、构建、运行、停止、删除

cd /data/docker/ghost

# 第一次运行无需build、不要-d 则可以看到运行的全部过程。退出时docker-compose 也会退出
docker-compose up -d

# 停止
docker-compose stop

# 删除
docker-compose rm

# 构建
docker-compose build

# 运行
docker-compose up -d

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值