php的web项目的docker部署

使用docker-composer。

version: '3.7'

x-logging: &default-logging
  driver: "json-file"
  options:
    max-size: "20m"
    max-file: "10"

services:
  ### Nginx container ##########################################################
  nginx:
      image: nginx
      ports:
        - "80:80"
        - "443:443"
      volumes:
        - wwwroot:/var/www/html:ro
        - ./work/nginx/entrypoint.conf:/etc/nginx/nginx.conf:ro
        - ./work/nginx:/etc/nginx/conf.d:ro
        - ./work/logs:/var/log/nginx:rw
        - /etc/localtime:/etc/localtime:ro
      restart: always
      container_name: nginx
      depends_on:
        - mysql
        - redis
      logging: *default-logging


  ### PHP-FPM container ########################################################
  php-fpm:
      image: php7.3-fpm
      volumes:
        - wwwroot:/var/www/html:rw
        - ./work/php/php.ini:/usr/local/etc/php/php.ini:ro
        - ./work/php/php-fpm.conf:/usr/local/etc/php-fpm.d/www.conf:ro
        - ./work/logs:/var/log:rw
        - /etc/localtime:/etc/localtime:ro
      privileged: false
      container_name: php-fpm
      logging: *default-logging

  ### Mysql container ##########################################################
  mysql:
      image: mysql:5.7
      ports:
        - "127.0.0.1:3306:3306/tcp"
      secrets:
        - db_root_password
        - db_password
      volumes:
        - mysqldata:/var/lib/mysql:rw
        - ./work/mysql/mysql.cnf:/etc/mysql/my.cnf:ro
        - ./work/logs:/var/log/mysql:rw
        - /etc/localtime:/etc/localtime:ro
      restart: always
      container_name: mysql
      environment:
        MYSQL_USER: ${MYSQL_USER}
        MYSQL_DATABASE: ${MYSQL_DATABASE}
        MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password
        MYSQL_PASSWORD_FILE: /run/secrets/db_password
      logging: *default-logging

  ### Redis container ##########################################################
  redis:
      image: redis:5.0
      entrypoint:
        - redis-server
        - /usr/local/etc/redis/redis.conf
      volumes:
        - ./work/redis/redis.conf:/usr/local/etc/redis/redis.conf:ro
        - ./work/logs:/var/log/redis:rw
        - /etc/localtime:/etc/localtime:ro
      restart: always
      container_name: redis
      logging: *default-logging

volumes:
  wwwroot:
  mysqldata:

secrets:
  db_root_password:
    file: ./db_root_password.txt
  db_password:
    file: ./db_${MYSQL_USER}_password.txt

 

 

©️2020 CSDN 皮肤主题: 大白 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值