docker-compose 安装Ghost

    xiaoxiao2023-10-08  155

    一、依赖

        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

     

    最新回复(0)