问答详情
源自:6-3 compose实战

20210323实验的文件附件

version: '3.1'

networks:

  ghost:

services:

  nginx:

    build: nginx

    networks:

      - ghost

    ports:

      - "80:80"

    depends_on:

      - ghost-app

  ghost-app:

    build: ghost

    networks:

      - ghost

    depends_on:

      - db

    restart: always

    ports:

      - 2368:2368

    environment:

      # see https://ghost.org/docs/config/#configuration-options

      database__client: mysql

      database__connection__host: db

      database__connection__user: root

      database__connection__password: example

      database__connection__database: ghost

      # this url value is just an example, and is likely wrong for your environment!

      # url: http://localhost:8080

      # contrary to the default mentioned in the linked documentation, this image defaults to NODE_ENV=production (so development mode needs to be explicitly specified if desired)

      #NODE_ENV: development

  db:

    image: mysql:5.7

    restart: always

    networks:

      - ghost

    volumes:

      - $PWD/data:/var/lib/mysql

    ports:

      - "3306:3306"

    environment:

      MYSQL_ROOT_PASSWORD: example



FROM ghost:3-alpine

EXPOSE 2368


FROM nginx

COPY nginx.conf /etc/nginx/nginx.conf

EXPOSE 80


worker_processes 4;

events {

    worker_connections 1024;

}

http {

    server {

        listen 80;

        location / {

            proxy_pass http://ghost-app:2368;

        }

    }

}


提问者:慕粉1474642376 2021-03-23 18:13

个回答