• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

mac m1 docker php 相关软件,后端开发 docker_compose.yml 已验证通过

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

  2020款 MacBook air m1 开发环境搭建。Apple silicon。

  docker环境执行开启。因为如果在本地装相关软件的话,会有各种坑。

  1.下载docker 适配于m1的。https://desktop.docker.com/mac/stable/arm64/60984/Docker.dmg

  2.docker_compose.yml  修改整理 执行 docker-compose up -d

  3.

 

 

  

version: "3"
services:
  nginx:
    build:
      context: ./services/nginx
      args:
        NGINX_VERSION: nginx:${NGINX_VERSION}
        CONTAINER_PACKAGE_URL: ${CONTAINER_PACKAGE_URL}
        NGINX_INSTALL_APPS: ${NGINX_INSTALL_APPS}
    #指定此 container_name 可以方便后期使用固定的 bash 命令别名进入容器
    container_name: ${DNMP_PROJECT}_nginx
    ports:
      - "${NGINX_HTTP_HOST_PORT}:80"
      - "${NGINX_HTTPS_HOST_PORT}:443"
      - "${DEMO_PROJECT_PORT}:${DEMO_PROJECT_PORT}"
    volumes:
      - ${SOURCE_DIR}:/www/:rw
      # use delegated to improve file sync performance
      - ${PROJECT_DIR}:${PROJECT_DIR}:rw,delegated
      - ${NGINX_SSL_CERTIFICATE_DIR}:/ssl:rw
      - ${NGINX_CONFD_DIR}:/etc/nginx/conf.d/:rw
      - ${NGINX_CONF_FILE}:/etc/nginx/nginx.conf:ro
      - ${NGINX_FASTCGI_PHP_CONF}:/etc/nginx/fastcgi-php.conf:ro
      - ${NGINX_FASTCGI_PARAMS}:/etc/nginx/fastcgi_params:ro
      - ${NGINX_LOG_DIR}:/var/log/nginx/:rw
    environment:
      TZ: "${TZ}"
    restart: always
    networks:
      - default

  php:
    # user: "${UID}:${GID}" # we added this line to get a specific user / group id
    # uid in container share uid pool within host kernel
    # use specified uid to avoid security/permission vulnerability which leads corruption of host system
    # uncomment this to allow exec high privilege commands in container, such as apk add ..
    user: "1000:1000"
    build:
      context: ./services/php
      args:
        PHP_VERSION: php:${PHP_VERSION}-fpm-alpine
        CONTAINER_PACKAGE_URL: ${CONTAINER_PACKAGE_URL}
        PHP_EXTENSIONS: ${PHP_EXTENSIONS}
        TZ: "${TZ}"
    container_name: ${DNMP_PROJECT}_php
    expose:
      - 9501
    extra_hosts:
      - "www.site1.com:172.17.0.1"
    volumes:
      - ${SOURCE_DIR}:/www/:rw
      # php container also need to use this volume mapping, otherwise nginx 404
      - ${PROJECT_DIR}:${PROJECT_DIR}:rw,delegated
      - ${PHP_PHP_CONF_FILE}:/usr/local/etc/php/php.ini:ro
      - ${PHP_FPM_CONF_FILE}:/usr/local/etc/php-fpm.d/www.conf:rw
      - ${PHP_LOG_DIR}:/var/log/php:rw
      - ${DATA_DIR}/composer:/tmp/composer
    restart: always
    cap_add:
      - SYS_PTRACE
    networks:
      - default



#  mysql:
#    image: mysql:${MYSQL_VERSION}
#    container_name: ${DNMP_PROJECT}_mysql
#    ports:
#      - "${MYSQL_HOST_PORT}:3306"
#    volumes:
#      - ${MYSQL_CONF_FILE}:/etc/mysql/conf.d/mysql.cnf:ro
#      - ${DATA_DIR}/mysql:/var/lib/mysql/:rw
#    restart: always
#    networks:
#      - default
#    environment:
#      MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
#      TZ: "$TZ"

  mysql5:
    #platform: linux/amd64
    platform: linux/x86_64
    image: mysql:${MYSQL5_VERSION}
    container_name: ${DNMP_PROJECT}_mysql5
    ports:
      - "${MYSQL5_HOST_PORT}:3306"
    volumes:
      - ${MYSQL5_CONF_FILE}:/etc/mysql/conf.d/mysql.cnf:ro
      - ${DATA_DIR}/mysql5:/var/lib/mysql/:rw
    restart: always
    networks:
      - default
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

#  openresty:
#    image:  openresty/openresty:${OPENRESTY_VERSION}
#    container_name: ${DNMP_PROJECT}_openresty
#    ports:
#       - "${OPENRESTY_HTTP_HOST_PORT}:80"
#       - "${OPENRESTY_HTTPS_HOST_PORT}:443"
#    volumes:
#       - ${SOURCE_DIR}:/www/:rw
#       - ${OPENRESTY_CONFD_DIR}:/etc/nginx/conf.d/:ro
#       - ${OPENRESTY_SSL_CERTIFICATE_DIR}:/ssl:rw
#       - ${OPENRESTY_CONF_FILE}:/usr/local/openresty/nginx/conf/nginx.conf:ro
#       - ${OPENRESTY_FASTCGI_PHP_CONF}:/usr/local/openresty/nginx/conf/fastcgi-php.conf:ro
#       - ${OPENRESTY_CONF_FASTCGIPARAMS_FILE}:/usr/local/openresty/nginx/conf/fastcgi_params:ro
#       - ${OPENRESTY_LOG_DIR}:/var/log/nginx/:rw
#    environment:
#      TZ: "$TZ"
#    networks:
#      - default

  redis:
    image: redis:${REDIS_VERSION}
    container_name: ${DNMP_PROJECT}_redis
    ports:
      - "${REDIS_HOST_PORT}:6379"
    volumes:
      - ${REDIS_CONF_FILE}:/etc/redis.conf:ro
      - ${DATA_DIR}/redis:/data/:rw
    restart: always
    entrypoint: ["redis-server", "/etc/redis.conf"]
    environment:
      TZ: "$TZ"
    networks:
      - default

#  memcached:
#    image: memcached:${MEMCACHED_VERSION}
#    container_name: ${DNMP_PROJECT}_memcached
#    ports:
#      - "${MEMCACHED_HOST_PORT}:11211"
#    environment:
#       MEMCACHED_CACHE_SIZE: "${MEMCACHED_CACHE_SIZE}"
#    networks:
#      - default

#  rabbitmq:
#    image: rabbitmq:${RABBITMQ_VERSION}
#    container_name: ${DNMP_PROJECT}_rabbitmq
#    restart: always
#    ports:
#      - "${RABBITMQ_HOST_PORT_C}:5672"
#      - "${RABBITMQ_HOST_PORT_S}:15672"
#    environment:
#       TZ: "$TZ"
#       RABBITMQ_DEFAULT_USER: "${RABBITMQ_DEFAULT_USER}"
#       RABBITMQ_DEFAULT_PASS: "${RABBITMQ_DEFAULT_PASS}"
#    networks:
#          - default

#  phpmyadmin:
#    image: phpmyadmin/phpmyadmin:latest
#    container_name: ${DNMP_PROJECT}_phpmyadmin
#    ports:
#      - "${PHPMYADMIN_HOST_PORT}:80"
#    volumes:
#      - ${PHPMYADMIN_USER_CONF_FILE}:/etc/phpmyadmin/config.user.inc.php:ro
#      - ${PHPMYADMIN_PHP_CONF_FILE}:/usr/local/etc/php/conf.d/php-phpmyadmin.ini:ro
#    networks:
#      - default
#    environment:
#      - PMA_HOST=mysql
#      - PMA_PORT=3306
#      - TZ=$TZ

#  phpredisadmin:
#    image: erikdubbelboer/phpredisadmin:latest
#    container_name: ${DNMP_PROJECT}_phpredisadmin
#    ports:
#      - "${REDISMYADMIN_HOST_PORT}:80"
#    networks:
#      - default
#    environment:
#      - REDIS_1_HOST=redis
#      - REDIS_1_PORT=6379
#      - TZ=$TZ

#  mongodb:
#    image: mongo:${MONGODB_VERSION}
#    container_name: ${DNMP_PROJECT}_mongodb
#    environment:
#        MONGO_INITDB_ROOT_USERNAME: "${MONGODB_INITDB_ROOT_USERNAME}"
#        MONGO_INITDB_ROOT_PASSWORD: "${MONGODB_INITDB_ROOT_PASSWORD}"
#        TZ: "$TZ"
#    volumes:
#      - ${DATA_DIR}/mongo:/data/db:rw
#      - ${DATA_DIR}/mongo_key:/mongo:rw
#    ports:
#       - "${MONGODB_HOST_PORT}:27017"
#    networks:
#       - default
#    command:
#       --auth

#  adminmongo:
#    image: mrvautin/adminmongo
#    container_name: ${DNMP_PROJECT}_adminmongo
#    ports:
#      - "${ADMINMONGO_HOST_PORT}:1234"
#    environment:
#      - HOST=0.0.0.0
#      - DB_HOST=mongodb
#      - DB_PORT=27017
#    networks:
#      - default

  elasticsearch:
#    platform: linux/amd64 #platform: linux/x86_64
    build:
      context: ./services/elasticsearch
      args:
        ELASTICSEARCH_VERSION: ${ELASTICSEARCH_VERSION}
        ELASTICSEARCH_PLUGINS: ${ELASTICSEARCH_PLUGINS}
    container_name: ${DNMP_PROJECT}_elasticsearch
    environment:
      - TZ=${TZ}
      - discovery.type=single-node
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    volumes:
      - ${DATA_DIR}/esdata:/usr/share/elasticsearch/data
      - ${ELASTICSEARCH_CONF_FILE}:/usr/share/elasticsearch/config/elasticsearch.yml
    hostname: elasticsearch
    restart: always
    ports:
      - "${ELASTICSEARCH_HOST_PORT_C}:9200"
      - "${ELASTICSEARCH_HOST_PORT_S}:9300"

  kibana:
    platform: linux/amd64 #platform: linux/x86_64
    image: kibana:${KIBANA_VERSION}
    container_name: ${DNMP_PROJECT}_kibana
    environment:
      TZ: "${TZ}"
      elasticsearch.hosts: http://elasticsearch:9200
      I18N_LOCALE: "${KIBANA_I18N_LOCALE}"
    hostname: kibana
    depends_on:
      - elasticsearch
    restart: always
    ports:
      - "${KIBANA_HOST}:5601"

#  logstash:
#    image: logstash:${LOGSTASH_VERSION}
#    container_name: ${DNMP_PROJECT}_logstash
#    hostname: logstash
#    restart: always
#    depends_on:
#      - elasticsearch
#    environment:
#      TZ: "$TZ"
#    ports:
#      - "${LOGSTASH_HOST_PORT_C}:9600"
#      - "${LOGSTASH_HOST_PORT_S}:5044"

#  node:
#    image: node:${NODE_VERSION}
#    environment:
#      - NODE_ENV=production
#    volumes:
#      - ${SOURCE_DIR}:/www/:rw
#    expose:
#      - "8081"
#    networks:
#      - default
#    stdin_open: true
#    tty: true


#  supervisor:
#    build:
#      context: ./services/supervisor
#      args:
#        ALPINE_VERSION: alpine:${ALPINE_VERSION}
#        TZ: "$TZ"
#        CONTAINER_PACKAGE_URL: ${CONTAINER_PACKAGE_URL}
#    container_name: ${DNMP_PROJECT}_supervisor
#    ports:
#      - "${SUPERVISOR_HOST_PORT_C}:9001"
#    volumes:
#      - ${SOURCE_DIR}:/www/:rw
#      - ${SUPERVISOR_LOG}:/var/log/supervisor/:rw
#      - ${SUPERVISOR_CONFIG}:/etc/supervisor/conf.d/:rw
#      - ${SUPERVISOR_CONF_FILE}:/etc/supervisor/supervisord.conf:ro
#    command:
#      - /bin/sh
#      - -c
#      - |
#        supervisord -n -c /etc/supervisor/supervisord.conf
#    restart: always
#    cap_add:
#      - SYS_PTRACE
#    networks:
#      - default

networks:
  default:

 

 

 

 

env文件。

#
# PHP source directory
#
SOURCE_DIR=./www

#
#配置自己本机的dnmp开发环境的目录地址,主要是为了在bash脚本中使用
#

DNMP_DIR=~/Documents/my_projects/dnmps
DNMP_PROJECT=demo

#
# 本机使用此端口访问容器中对应项目,在 .services/nginx/conf.d/demo.conf 中监听的端口保持与此端口一致,方便管理
#
DEMO_PROJECT_PORT=10000
#
# 使用此单独的环境变量映射本机开发目录到docker 容器中开发目录
#
PROJECT_DIR=/Users

#
# Runtime data directory
#
DATA_DIR=./data

#
# Container Timezone
#
TZ=Asia/Shanghai

#
# Container package fetch url
#
# Can be empty, followings or others:
# mirrors.163.com
# mirrors.aliyun.com
# mirrors.ustc.edu.cn
#
CONTAINER_PACKAGE_URL=mirrors.aliyun.com

#
#ALPINE
#
ALPINE_VERSION=3.12

#
# Nginx
#
NGINX_VERSION=1.19.1-alpine
NGINX_HTTP_HOST_PORT=80
NGINX_HTTPS_HOST_PORT=443
NGINX_CONFD_DIR=./services/nginx/conf.d
NGINX_CONF_FILE=./services/nginx/nginx.conf
NGINX_FASTCGI_PHP_CONF=./services/nginx/fastcgi-php.conf
NGINX_FASTCGI_PARAMS=./services/nginx/fastcgi_params
NGINX_SSL_CERTIFICATE_DIR=./services/nginx/ssl
NGINX_LOG_DIR=./logs/nginx
# Available apps: certbot
NGINX_INSTALL_APPS=

#
# Openresty
#
OPENRESTY_VERSION=alpine
OPENRESTY_HTTP_HOST_PORT=80
OPENRESTY_HTTPS_HOST_PORT=443
OPENRESTY_CONFD_DIR=./services/openresty/conf.d
OPENRESTY_CONF_FILE=./services/openresty/openresty.conf
OPENRESTY_FASTCGI_PHP_CONF=./services/openresty/fastcgi-php.conf
OPENRESTY_CONF_FASTCGIPARAMS_FILE=./services/openresty/fastcgi_params
OPENRESTY_SSL_CERTIFICATE_DIR=./services/openresty/ssl
OPENRESTY_LOG_DIR=./logs/nginx

#
# SUPERVISOR
#
SUPERVISOR_CONFIG=./services/supervisor/conf.d/
SUPERVISOR_LOG=./logs/supervisor
SUPERVISOR_CONF_FILE=./services/supervisor/supervisord.conf
SUPERVISOR_HOST_PORT_C=9001

#
# PHP7
#
# Available PHP_EXTENSIONS:
#
# pdo_mysql,zip,pcntl,mysqli,mbstring,exif,bcmath,calendar,
# sockets,gettext,shmop,sysvmsg,sysvsem,sysvshm,pdo_rebird,
# pdo_dblib,pdo_oci,pdo_odbc,pdo_pgsql,pgsql,oci8,odbc,dba,
# gd,intl,bz2,soap,xsl,xmlrpc,wddx,curl,readline,snmp,pspell,
# recode,tidy,gmp,imap,ldap,imagick,sqlsrv,mcrypt,opcache,
# redis,memcached,xdebug,swoole,pdo_sqlsrv,sodium,yaf,mysql,
# amqp,mongodb,event,rar,ast,yac,yar,yaconf,msgpack,igbinary,
# seaslog,varnish,xhprof,xlswriter,memcache,rdkafka,zookeeper,
# psr,phalcon,sdebug,ssh2,yaml,protobuf
#
# You can let it empty to avoid installing any extensions,
# or install multi plugins as:
# PHP_EXTENSIONS=pdo_mysql,mysqli,gd,curl,opcache
#
PHP_VERSION=7.1.3
PHP_PHP_CONF_FILE=./services/php/php.ini
PHP_FPM_CONF_FILE=./services/php/php-fpm.conf
PHP_LOG_DIR=./logs/php
PHP_EXTENSIONS=soap,xsl,xmlrpc,wddx,bz2,zip,pcntl,pdo_mysql,mysqli,mbstring,exif,bcmath,calendar,sockets,gettext,shmop,sysvmsg,sysvsem,sysvshm,gd,curl,opcache,xdebug,redis


#
# PHP5.6
#
PHP56_VERSION=5.6.40
PHP56_PHP_CONF_FILE=./services/php56/php.ini
PHP56_FPM_CONF_FILE=./services/php56/php-fpm.conf
PHP56_LOG_DIR=./logs/php
PHP56_EXTENSIONS=pdo_mysql,mysqli,mbstring,gd,curl,opcache

#
# PHP5.4
#
PHP54_VERSION=5.4.45
PHP54_PHP_CONF_FILE=./services/php54/php.ini
PHP54_FPM_CONF_FILE=./services/php54/php-fpm.conf
PHP54_LOG_DIR=./logs/php
PHP54_EXTENSIONS=pdo_mysql,mysqli,mbstring,gd,curl,opcache

#
# RABBITMQ
#
RABBITMQ_VERSION=management
RABBITMQ_HOST_PORT_C=5672
RABBITMQ_HOST_PORT_S=15672
RABBITMQ_DEFAULT_USER=myuser
RABBITMQ_DEFAULT_PASS=mypass

#
# MONGODB
#
MONGODB_VERSION=4.1
MONGODB_HOST_PORT=27017
MONGODB_INITDB_ROOT_USERNAME=root
MONGODB_INITDB_ROOT_PASSWORD=123456

#
# ELASTICSEARCH
#
# Available ELASTICSEARCH_PLUGINS:
#
# amazon-ec2,analysis-icu,analysis-kuromoji,analysis-nori,
# analysis-phonetic,analysis-smartcn,analysis-stempel,
# analysis-ukrainian,discovery-azure-classic,discovery-ec2,
# discovery-file,discovery-gce,google-cloud-storage,
# ingest-attachment,ingest-geoip,ingest-user-agent,mapper-murmur3,
# mapper-size,microsoft-azure-storage,qa,repository-azure,
# repository-gcs,repository-hdfs,repository-s3,store-smb,
# analysis-ik,analysis-pinyin
#
# You can let it empty to avoid installing any plugins,
# or install plugins as:
# ELASTICSEARCH_PLUGINS=analysis-ik,analysis-pinyin
#
ELASTICSEARCH_VERSION=7.10.1
ELASTICSEARCH_CONF_FILE=./services/elasticsearch/elasticsearch.yml
ELASTICSEARCH_HOST_PORT_C=9200
ELASTICSEARCH_HOST_PORT_S=9300
ELASTICSEARCH_PLUGINS=

#
# KIBANA
#
KIBANA_VERSION=7.10.1
KIBANA_HOST=5601
KIBANA_I18N_LOCALE=zh-CN

#
# LOGSTASH
#
LOGSTASH_VERSION=7.1.1
LOGSTASH_HOST=5601
LOGSTASH_HOST_PORT_C=9600
LOGSTASH_HOST_PORT_S=5044



#
# MySQL5
#
MYSQL5_VERSION=5.7.33
MYSQL5_HOST_PORT=3306
MYSQL5_ROOT_PASSWORD=12345678
MYSQL5_CONF_FILE=./services/mysql5/mysql.cnf

#
# Redis
#
REDIS_VERSION=5.0.3-alpine
REDIS_HOST_PORT=6379
REDIS_CONF_FILE=./services/redis/redis.conf

#
# Memcached
#
MEMCACHED_VERSION=alpine
MEMCACHED_HOST_PORT=11211
MEMCACHED_CACHE_SIZE=128

#
# phpMyAdmin
#
PHPMYADMIN_HOST_PORT=8080
PHPMYADMIN_USER_CONF_FILE=./services/phpmyadmin/config.user.inc.php
PHPMYADMIN_PHP_CONF_FILE=./services/phpmyadmin/php-phpmyadmin.ini

#
# redisMyAdmin
#
REDISMYADMIN_HOST_PORT=8081

#
# AdminMongo
#
ADMINMONGO_HOST_PORT=1234

#
# Node
#
NODE_VERSION=10.16.1-alpine

 

欢迎沟通交流

https://www.cnblogs.com/cxyacai/p/14692232.html

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP程序员如何突破成长瓶颈(php开发三到四年)发布时间:2022-07-10
下一篇:
PHP开发中涉及到emoji表情的几种处理方法发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap