├── scripts ├── __init__.py ├── nginx-reload ├── swoole.sh ├── update_hosts.py ├── db-ports ├── checker ├── web-ports ├── functions └── docker.py ├── sites └── .gitignore ├── etc ├── cache │ └── .gitignore ├── dlaravel-release ├── php │ ├── .gitignore │ ├── README.txt │ └── dlaravel.ini ├── supervisor │ ├── .gitignore │ └── laravel-worker.sample ├── php-fpm.d │ ├── .gitignore │ ├── www.conf │ └── www.conf.sample ├── v3.sample ├── project.sample ├── public.sample ├── swoole.sample ├── default.sample ├── public-ssl.sample ├── project-ssl.sample └── default-ssl.sample ├── samples ├── php │ ├── ldap.ini │ ├── redis.ini │ ├── swoole.ini │ ├── mysqli.ini │ ├── imagick.ini │ ├── php-datetime.ini │ ├── bcmath.ini │ ├── php-upload-and-memory.ini │ ├── samples.ini │ ├── opcache.ini │ └── php-xdebug.ini ├── bash_aliases ├── jenkins │ └── config ├── laravel-echo-server.json ├── nginx │ └── public-default.conf ├── docker-compose-custom.yml └── docker-compose-sample.yml ├── dockerfiles ├── .gitignore └── fpm │ ├── Dockerfile_php_5.6.x │ ├── Dockerfile_php_8.0.x │ ├── Dockerfile_php_8.1.x │ ├── Dockerfile_php_8.3.x │ ├── Dockerfile_php_8.4.x │ ├── Dockerfile_php_8.2.x │ ├── Dockerfile_php_7.1.x │ ├── Dockerfile_php_7.2.x │ ├── Dockerfile_php_7.4.x │ ├── Dockerfile_php_7.0.x │ ├── Dockerfile │ └── Dockerfile_php_7.3.x ├── service ├── .gitignore ├── echoserver.yml ├── swagger-editor.yml ├── mailhog.yml ├── redis.yml ├── beanstalkd.yml ├── swagger-ui.yml ├── jenkins.yml ├── phpmyadmin.yml └── code-server.yml ├── composer.sh ├── .gitmodules ├── .env.example ├── artisan.sh ├── phpunit.sh ├── .gitignore ├── docker-compose-build.yml ├── LICENSE ├── docker-compose-normal.yml ├── docker-compose-random.yml ├── docker-compose-project.yml ├── docker-compose-httpd.yml ├── docker-compose-swoole.yml ├── docker-compose-ssh.yml ├── docker-compose-nfs.yml ├── stack.yml ├── create.py ├── console.py ├── dlaravel ├── README-zh_TW.md ├── README.md └── create /scripts/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sites/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /etc/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /samples/php/ldap.ini: -------------------------------------------------------------------------------- 1 | extension=ldap.so 2 | -------------------------------------------------------------------------------- /samples/php/redis.ini: -------------------------------------------------------------------------------- 1 | extension=redis.so 2 | -------------------------------------------------------------------------------- /samples/php/swoole.ini: -------------------------------------------------------------------------------- 1 | extension=swoole.so 2 | -------------------------------------------------------------------------------- /etc/dlaravel-release: -------------------------------------------------------------------------------- 1 | D-Laravel release v2.2.2 2 | -------------------------------------------------------------------------------- /etc/php/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !dlaravel.ini 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /samples/php/mysqli.ini: -------------------------------------------------------------------------------- 1 | [mysqli] 2 | extension=mysqli.so 3 | -------------------------------------------------------------------------------- /samples/bash_aliases: -------------------------------------------------------------------------------- 1 | export PHP_IDE_CONFIG=serverName=dlaravel 2 | -------------------------------------------------------------------------------- /samples/php/imagick.ini: -------------------------------------------------------------------------------- 1 | [ImageMagic] 2 | extension=imagick.so 3 | -------------------------------------------------------------------------------- /etc/supervisor/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !laravel-worker.sample 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /samples/php/php-datetime.ini: -------------------------------------------------------------------------------- 1 | [Date] 2 | date.timezone = "Asia/Taipei" 3 | 4 | -------------------------------------------------------------------------------- /dockerfiles/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !fpm 3 | !echoserver 4 | !osshd 5 | !.gitignore 6 | -------------------------------------------------------------------------------- /etc/php-fpm.d/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !www.conf 3 | !www.conf.sample 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /samples/php/bcmath.ini: -------------------------------------------------------------------------------- 1 | #https://github.com/laravel/telescope 2 | #required for laravel telescope 3 | [bcmath] 4 | extension=bcmath.so 5 | -------------------------------------------------------------------------------- /samples/php/php-upload-and-memory.ini: -------------------------------------------------------------------------------- 1 | upload_max_filesize = 50M 2 | post_max_size = 50M 3 | max_execution_time = 0 4 | memory_limit = -1 5 | -------------------------------------------------------------------------------- /samples/jenkins/config: -------------------------------------------------------------------------------- 1 | Host web 2 | Hostname web 3 | User dlaravel 4 | StrictHostKeyChecking no 5 | KeepAlive yes 6 | ServerAliveInterval 30 7 | IdentityFile=~/.ssh/id_rsa 8 | -------------------------------------------------------------------------------- /etc/php/README.txt: -------------------------------------------------------------------------------- 1 | 您可以把要使用的php.ini檔放這裡 2 | 例如,自訂一個內容如下的php.ini檔。 3 | 擴充上傳檔案大小到20M 4 | [Date] 5 | date.timezone = "Asia/Taipei" 6 | 7 | upload_max_filesize = 20M 8 | post_max_size = 20M 9 | -------------------------------------------------------------------------------- /service/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !echoserver.yml 3 | !phpmyadmin.yml 4 | !beanstalkd.yml 5 | !code-server.yml 6 | !redis.yml 7 | !jenkins.yml 8 | !swagger-editor.yml 9 | !swagger-ui.yml 10 | !.gitignore 11 | -------------------------------------------------------------------------------- /service/echoserver.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | echoserver: 4 | image: deviny/echoserver 5 | network_mode: "service:web" 6 | volumes: 7 | - ./samples/laravel-echo-server.json:/laravel-echo-server.json 8 | -------------------------------------------------------------------------------- /composer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #在Project的目錄下執行composer 3 | command="cd ${PWD##*/};composer" 4 | while test $# -gt 0 5 | do 6 | command="${command} ${1}" 7 | shift 8 | done 9 | docker-compose exec -u dlaravel php bash -c "${command}" 10 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dockerfiles/echoserver"] 2 | path = dockerfiles/echoserver 3 | url = git://github.com/DevinY/echoserver.git 4 | [submodule "dockerfiles/osshd"] 5 | path = dockerfiles/osshd 6 | url = https://github.com/DevinY/osshd.git 7 | -------------------------------------------------------------------------------- /service/swagger-editor.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | swagger-editor: 4 | image: swaggerapi/swagger-editor 5 | ports: 6 | - "127.0.0.1:8082:8080" 7 | networks: 8 | - dlaravel_net 9 | networks: 10 | dlaravel_net: 11 | -------------------------------------------------------------------------------- /service/mailhog.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | mailhog: 4 | image: deviny/mailhog 5 | ports: 6 | - "1025:1025" 7 | - "8025:8025" 8 | networks: 9 | - dlaravel_net 10 | 11 | networks: 12 | dlaravel_net: 13 | -------------------------------------------------------------------------------- /service/redis.yml: -------------------------------------------------------------------------------- 1 | # redis ports 2 | #- "127.0.0.1:6379:6379" 3 | 4 | #Dockerhub官方redis image 5 | version: '3.6' 6 | services: 7 | redis: 8 | image: redis 9 | networks: 10 | - dlaravel_net 11 | 12 | networks: 13 | dlaravel_net: 14 | -------------------------------------------------------------------------------- /samples/php/samples.ini: -------------------------------------------------------------------------------- 1 | extension=bz2.so 2 | extension=dom.so 3 | extension=gd.so 4 | extension=mysqli.so 5 | extension=pgsql.so 6 | extension=exif.so 7 | extension=gettext.so 8 | extension=pcntl.so 9 | extension=pdo_pgsql.so 10 | sextension=ockets.so 11 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | #===當您使用D-Laravel的.env功能時,請採用D-Laravel所提供的指令控制container!=== 2 | #MYSQL_ROOT_PASSWORD=secret 3 | LARAVEL_INSTALLER='container' 4 | #Choose service file from services folder, but without extension name. 5 | DOCKER_SERVICES='redis' 6 | #===定義./console build要使用的fpm版本=== 7 | #FPM_VERSION=7.2 8 | -------------------------------------------------------------------------------- /artisan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -d "sites/" ]; then 3 | echo "Add alias as below, than you can run php artisan in your project folder." 4 | echo 'alias a="../../artisan.sh"' 5 | exit; 6 | fi 7 | docker-compose -f "../../docker-compose.yml" exec -u dlaravel php php $(basename `pwd`)/artisan ${@} 8 | -------------------------------------------------------------------------------- /samples/php/opcache.ini: -------------------------------------------------------------------------------- 1 | [opcache] 2 | zend_extension=opcache.so 3 | opcache.memory_consumption=128 4 | opcache.interned_strings_buffer=8 5 | opcache.max_accelerated_files=4000 6 | opcache.validate_timestamps=1 7 | opcache.revalidate_freq=0 8 | opcache.fast_shutdown=1 9 | opcache.enable_cli=1 10 | opcache.enable=1 11 | -------------------------------------------------------------------------------- /samples/php/php-xdebug.ini: -------------------------------------------------------------------------------- 1 | [xdebug] 2 | extension=xdebug.so 3 | xdebug.remote_enable=1 4 | xdebug.remote_handler=dbgp 5 | xdebug.remote_port=9000 6 | xdebug.remote_autostart=1 7 | xdebug.remote_connect_back=0 8 | xdebug.idekey=docker 9 | xdebug.remote_host=172.20.10.6 10 | xdebug.remote_log=/var/www/html/xdebug.log 11 | -------------------------------------------------------------------------------- /phpunit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -d "sites/" ]; then 3 | echo "Add alias as below, than you can run phpunit in your project folder." 4 | echo 'alias phpunit="../../phpunit.sh"' 5 | exit; 6 | fi 7 | docker-compose -f "../../docker-compose.yml" exec -u dlaravel php $(basename `pwd`)/vendor/bin/phpunit -c $(basename `pwd`)/phpunit.xml 8 | -------------------------------------------------------------------------------- /service/beanstalkd.yml: -------------------------------------------------------------------------------- 1 | # Beanstalk ports 2 | #- "11300:11300" 3 | 4 | ### 非官方的版本,不過星星數最高的,我測過有作用 5 | ### beanstalk container ################################## 6 | version: '3.6' 7 | services: 8 | beanstalk: 9 | image: bevand10/alpine-beanstalk 10 | networks: 11 | - dlaravel_net 12 | 13 | networks: 14 | dlaravel_net: 15 | -------------------------------------------------------------------------------- /service/swagger-ui.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | swagger-ui: 4 | image: swaggerapi/swagger-ui 5 | ports: 6 | - "127.0.0.1:8083:8080" 7 | environment: 8 | - API_URL=https://raw.githubusercontent.com/DevinY/openapi/master/openapi-jwt.yaml 9 | networks: 10 | - dlaravel_net 11 | 12 | networks: 13 | dlaravel_net: 14 | -------------------------------------------------------------------------------- /etc/supervisor/laravel-worker.sample: -------------------------------------------------------------------------------- 1 | [program:laravel-worker] 2 | process_name=%(program_name)s_%(process_num)02d 3 | command=php /var/www/html/test1/artisan queue:work --queue=email --sleep=3 --tries=3 4 | autostart=true 5 | autorestart=true 6 | user=dlaravel 7 | numprocs=8 8 | redirect_stderr=true 9 | stdout_logfile=/var/log/supervisor/worker.log 10 | -------------------------------------------------------------------------------- /scripts/nginx-reload: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #currentPath=`pwd` 3 | base_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | source ${base_path}/checker 5 | 6 | web=`docker-compose ps|grep Up|grep ${containerName}_web_1|cut -d ' ' -f 1` 7 | echo "Reload web service: ${web}" 8 | 9 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec web nginx -s reload 10 | 11 | -------------------------------------------------------------------------------- /scripts/swoole.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | dir=/var/www/html/${1} 4 | 5 | php /var/www/html/${1}/bin/laravels -d start 6 | 7 | inotifywait -rm "$dir" --format '%w%f' -e modify | 8 | while read file; do 9 | if [[ $file == *.php ]]; then 10 | php /var/www/html/${1}/bin/laravels reload 11 | echo $file 12 | fi 13 | done 14 | 15 | /usr/local/sbin/php-fpm 16 | -------------------------------------------------------------------------------- /etc/v3.sample: -------------------------------------------------------------------------------- 1 | [req] 2 | distinguished_name = req_distinguished_name 3 | x509_extensions = v3_req 4 | prompt = no 5 | [req_distinguished_name] 6 | C = TW 7 | ST = Panchiao 8 | L = Taipei 9 | O = Dlaravel 10 | OU = It 11 | CN = dlaravel.test 12 | [v3_req] 13 | keyUsage = keyEncipherment, dataEncipherment 14 | extendedKeyUsage = serverAuth 15 | subjectAltName = @alt_names 16 | [alt_names] 17 | -------------------------------------------------------------------------------- /scripts/update_hosts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import sys 4 | arguments_list = sys.argv[1:] 5 | number_of_arguments = len(arguments_list) 6 | if(number_of_arguments > 0): 7 | parameter = arguments_list[0] 8 | try: 9 | with open("/etc/hosts","a") as f: 10 | f.write("\n127.0.0.1 {}.test".format(parameter)) 11 | except: 12 | print("sudo need") 13 | -------------------------------------------------------------------------------- /service/jenkins.yml: -------------------------------------------------------------------------------- 1 | #Dockerhub官方jenkins LTS image 2 | version: '3.6' 3 | services: 4 | ci: 5 | image: jenkins/jenkins:lts 6 | dns: 8.8.8.8 7 | ports: 8 | - "8080:8080" 9 | - "50000:50000" 10 | volumes: 11 | - ./var/jenkins_home:/var/jenkins_home 12 | - ./var/jenkins_home/workspace:/var/jenkins_home/workspace 13 | networks: 14 | - dlaravel_net 15 | 16 | networks: 17 | dlaravel_net: 18 | -------------------------------------------------------------------------------- /service/phpmyadmin.yml: -------------------------------------------------------------------------------- 1 | #phpmyadmin官方image 2 | version: '3.6' 3 | services: 4 | phpmyadmin: 5 | image: phpmyadmin/phpmyadmin 6 | #移除本機127.0.0.1,將讓外面可以直接存取哦 7 | #請勿隨意調整為8080:80 8 | #D-Laravel的root預設是不需密碼的 9 | ports: 10 | - "127.0.0.1:8080:80" 11 | #volumes: 12 | #- ./etc/phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php 13 | 14 | networks: 15 | - dlaravel_net 16 | 17 | networks: 18 | dlaravel_net: 19 | -------------------------------------------------------------------------------- /etc/php/dlaravel.ini: -------------------------------------------------------------------------------- 1 | [基本功能] 2 | extension=zip.so 3 | extension=pdo_mysql.so 4 | extension=pcntl.so 5 | extension=gd.so 6 | 7 | [opcache] 8 | zend_extension=opcache.so 9 | opcache.memory_consumption=128 10 | opcache.interned_strings_buffer=8 11 | opcache.max_accelerated_files=4000 12 | opcache.validate_timestamps=1 13 | opcache.revalidate_freq=0 14 | opcache.fast_shutdown=1 15 | opcache.enable_cli=1 16 | opcache.enable=1 17 | 18 | memory_limit=-1 19 | -------------------------------------------------------------------------------- /service/code-server.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | code-server: 4 | image: codercom/code-server 5 | user: "1000:1000" 6 | ports: 7 | - "8443:8443" 8 | volumes: 9 | #You can expose your defualt project name on your host. 10 | # export DLARAVEL_WORKSPACE=test1 11 | - "./sites/${DLARAVEL_WORKSPACE-default}:/home/coder/project" 12 | - ./etc/cache:/etc/cache 13 | command: ["--allow-http", "--password=secret","-e","/etc/cache"] 14 | networks: 15 | - dlaravel_net 16 | 17 | networks: 18 | dlaravel_net: 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | etc/* 3 | !etc/dlaravel-release 4 | !etc/php 5 | !etc/cache 6 | !etc/php-fpm.d 7 | !etc/default-ssl.sample 8 | !etc/default.sample 9 | !etc/swoole.sample 10 | !etc/networks/default.conf 11 | !etc/default-ssl.sample 12 | !etc/supervisor 13 | !etc/mysql/my.cnf 14 | !etc/mysql/my.cnf.sample 15 | !etc/public.sample 16 | !etc/public-ssl.sample 17 | etc/php/php.ini 18 | !etc/ssl/* 19 | ext/ 20 | run/ 21 | *.swp 22 | *.pyc 23 | scripts/__pycache__/ 24 | data/ 25 | docker-compose.yml 26 | docker-compose-custom.yml 27 | !.gitignore 28 | *.sql 29 | Dockerfile_db 30 | Dockerfile_php 31 | Dockerfile_web 32 | -------------------------------------------------------------------------------- /samples/laravel-echo-server.json: -------------------------------------------------------------------------------- 1 | { 2 | "authHost": "http://localhost", 3 | "authEndpoint": "/broadcasting/auth", 4 | "clients": [], 5 | "database": "redis", 6 | "databaseConfig": { 7 | "redis": { 8 | "port": "6379", 9 | "host": "redis" 10 | } 11 | }, 12 | "devMode": true, 13 | "host": "web", 14 | "port": "6001", 15 | "protocol": "http", 16 | "socketio": {}, 17 | "subscribers": { 18 | "http": true, 19 | "redis": true 20 | }, 21 | "apiOriginAllow": { 22 | "allowCors": true, 23 | "allowOrigin": "http://localhost", 24 | "allowMethods": "GET, POST", 25 | "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /docker-compose-build.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | web: 4 | image: nginx 5 | dns: 8.8.8.8 6 | ports: 7 | - "80:80" 8 | - "443:443" 9 | volumes: 10 | - ./sites:/var/www/html 11 | - ./etc:/etc/nginx/conf.d 12 | hostname: web 13 | networks: 14 | - dlaravel_net 15 | 16 | php: 17 | image: mydlaravelfpm 18 | build: 19 | context: ./dockerfiles/fpm/ 20 | dockerfile: Dockerfile_php_8.2.x 21 | network_mode: "service:web" 22 | volumes: 23 | - ./etc/php:/usr/local/etc/php/conf.d 24 | - ./sites:/var/www/html 25 | - ./etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf 26 | - ./etc/cache:/home/dlaravel/.composer/cache 27 | environment: 28 | - TZ=Asia/Taipei 29 | db: 30 | image: mariadb:10.5.5 31 | #command: --default-authentication-plugin=mysql_native_password --sql_mode="" 32 | hostname: db 33 | ports: 34 | - "3306" 35 | volumes: 36 | - ./data:/var/lib/mysql 37 | environment: 38 | - MYSQL_ALLOW_EMPTY_PASSWORD=yes 39 | - TZ=Asia/Taipei 40 | networks: 41 | - dlaravel_net 42 | 43 | networks: 44 | dlaravel_net: 45 | -------------------------------------------------------------------------------- /etc/project.sample: -------------------------------------------------------------------------------- 1 | #./console project 2 | server { 3 | 4 | server_name localhost *.test; 5 | 6 | set $basepath "/var/www/html"; 7 | index index.php index.html; 8 | 9 | error_log /var/log/nginx/error.log; 10 | access_log /var/log/nginx/access.log; 11 | 12 | #The location of our project's public directory. 13 | root $basepath/public/; 14 | 15 | client_max_body_size 50m; 16 | 17 | # Point index to the Laravel front controller. 18 | index index.php index.html; 19 | autoindex on; 20 | 21 | location / { 22 | try_files $uri $uri/ /?$query_string; 23 | } 24 | 25 | # Remove trailing slash to please routing system. 26 | if (!-d $request_filename) { 27 | rewrite ^/(.+)/$ /$1 permanent; 28 | } 29 | 30 | location ~ \.php$ { 31 | try_files $uri =404; 32 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 33 | fastcgi_pass web:9000; 34 | fastcgi_index index.php; 35 | include fastcgi_params; 36 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 37 | fastcgi_param PATH_INFO $fastcgi_path_info; 38 | fastcgi_read_timeout 500; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Devin Yang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /docker-compose-normal.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | #=== web service ====================== 4 | web: 5 | image: nginx 6 | dns: 8.8.8.8 7 | ports: 8 | - "80:80" 9 | - "443:443" 10 | volumes: 11 | - ./sites:/var/www/html 12 | - ./etc:/etc/nginx/conf.d 13 | hostname: web 14 | networks: 15 | - dlaravel_net 16 | 17 | #=== php service ========================== 18 | php: 19 | network_mode: "service:web" 20 | image: deviny/fpm:8.2.6 21 | volumes: 22 | - ./etc/php:/usr/local/etc/php/conf.d 23 | - ./sites:/var/www/html 24 | - ./etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf 25 | - ./etc/cache:/home/dlaravel/.composer/cache 26 | environment: 27 | - TZ=Asia/Taipei 28 | 29 | #=== db service =========================== 30 | db: 31 | image: mariadb:10.5.5 32 | #command: --default-authentication-plugin=mysql_native_password --sql_mode="" 33 | hostname: db 34 | ports: 35 | - "127.0.0.1:3306:3306" 36 | volumes: 37 | - ./data:/var/lib/mysql 38 | environment: 39 | - MYSQL_ALLOW_EMPTY_PASSWORD=yes 40 | - TZ=Asia/Taipei 41 | networks: 42 | - dlaravel_net 43 | 44 | #=== top-level netowks key ====================== 45 | networks: 46 | dlaravel_net: 47 | -------------------------------------------------------------------------------- /docker-compose-random.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | #=== web container ====================== 4 | web: 5 | image: nginx 6 | dns: 8.8.8.8 7 | ports: 8 | # random port 9 | - "80" 10 | - "443" 11 | volumes: 12 | - ./sites:/var/www/html 13 | - ./etc:/etc/nginx/conf.d 14 | hostname: web 15 | networks: 16 | - dlaravel_net 17 | 18 | #=== php service ========================== 19 | php: 20 | network_mode: "service:web" 21 | image: deviny/fpm:8.2.6 22 | volumes: 23 | - ./etc/php:/usr/local/etc/php/conf.d 24 | - ./sites:/var/www/html:cached 25 | - ./etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf 26 | - ./etc/cache:/home/dlaravel/.composer/cache 27 | environment: 28 | - TZ=Asia/Taipei 29 | 30 | #=== db service =========================== 31 | db: 32 | image: mariadb:10.5.5 33 | #command: --default-authentication-plugin=mysql_native_password --sql_mode="" 34 | hostname: db 35 | ports: 36 | - "3306" 37 | volumes: 38 | - ./data:/var/lib/mysql 39 | environment: 40 | - MYSQL_ALLOW_EMPTY_PASSWORD=yes 41 | - TZ=Asia/Taipei 42 | networks: 43 | - dlaravel_net 44 | 45 | #=== top-level netowks key ====================== 46 | networks: 47 | dlaravel_net: 48 | -------------------------------------------------------------------------------- /docker-compose-project.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | #=== web service ====================== 4 | web: 5 | image: nginx 6 | dns: 8.8.8.8 7 | ports: 8 | - "80" 9 | - "443" 10 | volumes: 11 | - ./..:/var/www/html 12 | - ./etc:/etc/nginx/conf.d 13 | hostname: web 14 | networks: 15 | - dlaravel_net 16 | 17 | #=== php service ========================== 18 | php: 19 | network_mode: "service:web" 20 | image: deviny/fpm:8.2.6 21 | volumes: 22 | - ./etc/php:/usr/local/etc/php/conf.d 23 | - ./..:/var/www/html:cached 24 | - ./etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf 25 | - ./etc/cache:/home/dlaravel/.composer/cache 26 | environment: 27 | - TZ=Asia/Taipei 28 | - project=${HOST-localhost} 29 | 30 | #=== db service =========================== 31 | db: 32 | image: mariadb:10.5.5 33 | #command: --default-authentication-plugin=mysql_native_password --sql_mode="" 34 | hostname: db 35 | ports: 36 | - "3306" 37 | volumes: 38 | - ./data:/var/lib/mysql 39 | environment: 40 | - MYSQL_ALLOW_EMPTY_PASSWORD=yes 41 | - TZ=Asia/Taipei 42 | networks: 43 | - dlaravel_net 44 | 45 | #=== top-level netowks key ====================== 46 | networks: 47 | dlaravel_net: 48 | -------------------------------------------------------------------------------- /scripts/db-ports: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | base_path=`echo ${scripts_path}|sed 's#/scripts##'` 4 | 5 | source ${script_path}/functions 6 | chk_project_mode 7 | source ${script_path}/checker 8 | 9 | chk_project_mode 10 | if [ ${?} -eq 0 ]; then 11 | echo "A" 12 | docker-compose -p ${project_name} -f ${scripts_path}/../docker-compose.yml ps db|tail -n1|grep -q -e Up -e running 13 | if [ ${?} -eq 1 ]; then 14 | echo "No service of db." 15 | exit; 16 | fi 17 | db=`docker-compose -p ${project_name} -f ${scripts_path}/../docker-compose.yml ps db|tail -n1|cut -d' ' -f1` 18 | else 19 | db=`docker-compose -f ${scripts_path}/../docker-compose.yml ps db|tail -n1|awk '{print $1}'` 20 | if [ ${?} -eq 1 ]; then 21 | echo "No service of db." 22 | exit; 23 | fi 24 | fi 25 | 26 | if [ $? -eq 1 ]; then 27 | echo ${db} is not running 28 | exit 29 | fi 30 | #docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' ${containerName}_web_1 31 | if [[ ${db} != "" ]]; then 32 | db_port=`docker inspect --format='{{(index (index .NetworkSettings.Ports "3306/tcp") 0).HostPort}}' ${db}` 33 | echo "host:${db_port}" 34 | fi 35 | -------------------------------------------------------------------------------- /docker-compose-httpd.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | #=== web service ====================== 4 | web: 5 | image: httpd:2.4 6 | ports: 7 | - "80:80" 8 | volumes: 9 | - ./sites:/usr/local/apache2/htdocs 10 | # test1.test & test2.test (You have to modify vhost for your own) 11 | - ./etc/httpd/httpd.conf.sample:/usr/local/apache2/conf/httpd.conf 12 | networks: 13 | - dlaravel_net 14 | 15 | #=== php service ========================== 16 | php: 17 | network_mode: "service:web" 18 | image: deviny/fpm:8.2.6 19 | volumes: 20 | - ./etc/php:/usr/local/etc/php/conf.d 21 | - ./sites:/var/www/html 22 | - ./etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf 23 | - ./etc/cache:/home/dlaravel/.composer/cache 24 | environment: 25 | - TZ=Asia/Taipei 26 | 27 | #=== db service =========================== 28 | db: 29 | image: mariadb:10.5.5 30 | #command: --default-authentication-plugin=mysql_native_password --sql_mode="" 31 | hostname: db 32 | ports: 33 | - "127.0.0.1:3306:3306" 34 | volumes: 35 | - ./data:/var/lib/mysql 36 | environment: 37 | - MYSQL_ALLOW_EMPTY_PASSWORD=yes 38 | - TZ=Asia/Taipei 39 | networks: 40 | - dlaravel_net 41 | 42 | #=== top-level netowks key ====================== 43 | networks: 44 | dlaravel_net: 45 | -------------------------------------------------------------------------------- /docker-compose-swoole.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | #=== web service ====================== 4 | web: 5 | image: nginx 6 | dns: 8.8.8.8 7 | ports: 8 | - "80:80" 9 | - "443:443" 10 | volumes: 11 | - ./sites:/var/www/html 12 | - ./etc:/etc/nginx/conf.d 13 | hostname: web 14 | networks: 15 | - dlaravel_net 16 | 17 | #=== php service ========================== 18 | php: 19 | network_mode: "service:web" 20 | image: deviny/fpm:8.2.6 21 | volumes: 22 | - ./etc/php:/usr/local/etc/php/conf.d 23 | - ./sites:/var/www/html 24 | - ./etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf 25 | - ./etc/cache:/home/dlaravel/.composer/cache 26 | - ./scripts/swoole.sh:/swoole.sh 27 | environment: 28 | - TZ=Asia/Taipei 29 | command: ["/swoole.sh","default"] 30 | 31 | #=== db service =========================== 32 | db: 33 | image: mariadb:10.5.5 34 | #command: --default-authentication-plugin=mysql_native_password --sql_mode="" 35 | hostname: db 36 | ports: 37 | - "127.0.0.1:3306:3306" 38 | volumes: 39 | - ./data:/var/lib/mysql 40 | environment: 41 | - MYSQL_ALLOW_EMPTY_PASSWORD=yes 42 | - TZ=Asia/Taipei 43 | networks: 44 | - dlaravel_net 45 | 46 | #=== top-level netowks key ====================== 47 | networks: 48 | dlaravel_net: 49 | -------------------------------------------------------------------------------- /scripts/checker: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | uid=`whoami|id -u` 3 | if [ ${uid} -eq 0 ]; then 4 | echo "Don't run D-Laravel as root!" 5 | exit; 6 | fi 7 | 8 | scripts_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 9 | dlaravel_path=${PWD##*/} 10 | 11 | if [[ ${dlaravel_path} =~ [_] ]]; then 12 | echo "D-Laravel folder can't have underscore. [${dlaravel_path}]"; 13 | exit; 14 | fi 15 | 16 | base_path=`echo ${scripts_path}|sed 's#/scripts##'` 17 | containerName=`printf '%s\n' "${base_path##*/}"|tr '[:upper:]' '[:lower:]'|sed 's/-//g'|sed 's/\.//g'` 18 | hosts_file='/etc/hosts' 19 | #檢測是否有docker-compose連結,沒有就建一個 20 | if [ ! -f "${base_path}/docker-compose.yml" ];then 21 | ln -vsf docker-compose-random.yml docker-compose.yml 22 | fi 23 | #檢測是否為widnows desktop 24 | 25 | which docker >/dev/null 2>&1 26 | if [ $? -eq 1 ]; then 27 | echo 'Please go to https://docs.docker.com/engine/installation/ to install docker' 28 | exit; 29 | fi 30 | 31 | which docker-compose >/dev/null 2>&1 32 | if [ $? -eq 1 ]; then 33 | echo 'Please go to https://docs.docker.com/compose/install/ to install docker-compose' 34 | exit 35 | fi 36 | 37 | 38 | winpty="" 39 | #is windows 40 | which winpty >/dev/null 2>&1 41 | if [ $? -eq 0 ]; then 42 | winpty=`which winpty` 43 | hosts_file='/c/Windows/system32/drivers/etc/hosts' 44 | fi 45 | -------------------------------------------------------------------------------- /docker-compose-ssh.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | #=== web service ====================== 4 | web: 5 | image: nginx 6 | dns: 8.8.8.8 7 | ports: 8 | - "80:80" 9 | - "443:443" 10 | - "127.0.0.1:2020:22" 11 | #for echo-server 12 | #- "6001:6001" 13 | volumes: 14 | - ./sites:/var/www/html 15 | - ./etc:/etc/nginx/conf.d 16 | hostname: web 17 | networks: 18 | - dlaravel_net 19 | 20 | #=== php service ========================== 21 | php: 22 | network_mode: "service:web" 23 | image: deviny/fpm:8.2.6-ssh 24 | volumes: 25 | - ./etc/php:/usr/local/etc/php/conf.d 26 | - ./sites:/var/www/html:cached 27 | - ./etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf 28 | - ~/.ssh/id_rsa.pub:/home/dlaravel/.ssh/authorized_keys 29 | - ./etc/cache:/home/dlaravel/.composer/cache 30 | environment: 31 | - TZ=Asia/Taipei 32 | 33 | #=== db service =========================== 34 | db: 35 | image: mariadb:10.5.5 36 | #command: --default-authentication-plugin=mysql_native_password --sql_mode="" 37 | hostname: db 38 | ports: 39 | - "127.0.0.1:3306:3306" 40 | volumes: 41 | - ./data:/var/lib/mysql 42 | environment: 43 | - MYSQL_ALLOW_EMPTY_PASSWORD=yes 44 | - TZ=Asia/Taipei 45 | networks: 46 | - dlaravel_net 47 | 48 | #=== top-level netowks key ====================== 49 | networks: 50 | dlaravel_net: 51 | -------------------------------------------------------------------------------- /etc/public.sample: -------------------------------------------------------------------------------- 1 | server { 2 | #######外部存取設定############ 3 | #請依這個檔按為範本拷貝出來修改。 4 | #cp public.conf my-domain.conf 5 | 6 | #調整下方的域名或IP位置 7 | #server_name www.ccc.tc; 8 | server_name localhost; 9 | 10 | #抓IP位置(開頭及結束都是數字) 11 | #server_name "~^(\d+\.).+\d$"; 12 | 13 | #sites內,要使用的專案資料夾名稱 14 | set $projectname "www"; 15 | 16 | ##########下方不需要調整################## 17 | set $basepath "/var/www/html"; 18 | index index.php index.html; 19 | 20 | error_log /var/log/nginx/error.log; 21 | access_log /var/log/nginx/access.log; 22 | 23 | #The location of our project's public directory. 24 | root $basepath/$projectname/public/; 25 | 26 | client_max_body_size 50m; 27 | 28 | # Point index to the Laravel front controller. 29 | index index.php index.html; 30 | autoindex on; 31 | 32 | location / { 33 | try_files $uri $uri/ /?$query_string; 34 | } 35 | 36 | # Remove trailing slash to please routing system. 37 | if (!-d $request_filename) { 38 | rewrite ^/(.+)/$ /$1 permanent; 39 | } 40 | 41 | location ~ \.php$ { 42 | try_files $uri =404; 43 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 44 | fastcgi_pass web:9000; 45 | fastcgi_index index.php; 46 | include fastcgi_params; 47 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 48 | fastcgi_param PATH_INFO $fastcgi_path_info; 49 | fastcgi_read_timeout 500; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /samples/nginx/public-default.conf: -------------------------------------------------------------------------------- 1 | server { 2 | #######外部存取設定############ 3 | #請依這個檔按為範本拷貝出來修改。 4 | #cp public.conf my-domain.conf 5 | 6 | #調整下方的域名或IP位置 7 | #server_name www.ccc.tc; 8 | server_name localhost "~^(\d+\.).+\d$"; 9 | 10 | #抓IP位置(開頭及結束都是數字) 11 | #server_name "~^(\d+\.).+\d$"; 12 | 13 | #sites內,要使用的專案資料夾名稱 14 | set $projectname "default"; 15 | 16 | ##########下方不需要調整################## 17 | set $basepath "/var/www/html"; 18 | index index.php index.html; 19 | 20 | error_log /var/log/nginx/error.log; 21 | access_log /var/log/nginx/access.log; 22 | 23 | #The location of our project's public directory. 24 | root $basepath/$projectname/public/; 25 | 26 | client_max_body_size 50m; 27 | 28 | # Point index to the Laravel front controller. 29 | index index.php index.html; 30 | autoindex on; 31 | 32 | location / { 33 | try_files $uri $uri/ /?$query_string; 34 | } 35 | 36 | # Remove trailing slash to please routing system. 37 | if (!-d $request_filename) { 38 | rewrite ^/(.+)/$ /$1 permanent; 39 | } 40 | 41 | location ~ \.php$ { 42 | try_files $uri =404; 43 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 44 | fastcgi_pass web:9000; 45 | fastcgi_index index.php; 46 | include fastcgi_params; 47 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 48 | fastcgi_param PATH_INFO $fastcgi_path_info; 49 | fastcgi_read_timeout 500; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /docker-compose-nfs.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | #=== web service ====================== 4 | web: 5 | image: nginx 6 | dns: 8.8.8.8 7 | ports: 8 | - "80:80" 9 | - "443:443" 10 | volumes: 11 | - sites:/var/www/html 12 | - ./etc:/etc/nginx/conf.d 13 | hostname: web 14 | networks: 15 | - dlaravel_net 16 | 17 | #=== php service ========================== 18 | php: 19 | network_mode: "service:web" 20 | image: deviny/fpm:8.2.6 21 | volumes: 22 | - ./etc/php:/usr/local/etc/php/conf.d 23 | - sites:/var/www/html 24 | - ./etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf 25 | ###create composer cache### 26 | - ./etc/cache:/home/dlaravel/.composer/cache 27 | environment: 28 | - TZ=Asia/Taipei 29 | 30 | #=== db service =========================== 31 | db: 32 | image: mariadb:10.5.5 33 | #command: --default-authentication-plugin=mysql_native_password --sql_mode="" 34 | hostname: db 35 | ports: 36 | - "127.0.0.1:3306:3306" 37 | volumes: 38 | - ./data:/var/lib/mysql 39 | environment: 40 | - MYSQL_ALLOW_EMPTY_PASSWORD=yes 41 | - TZ=Asia/Taipei 42 | networks: 43 | - dlaravel_net 44 | 45 | volumes: 46 | sites: 47 | driver: local 48 | driver_opts: 49 | type: nfs 50 | o: addr=host.docker.internal,rw,nolock,hard,nointr,nfsvers=3 51 | device: ":${PWD}/sites" 52 | 53 | #=== top-level netowks key ====================== 54 | networks: 55 | dlaravel_net: 56 | -------------------------------------------------------------------------------- /samples/docker-compose-custom.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | #=== web service ====================== 4 | web: 5 | image: nginx 6 | dns: 8.8.8.8 7 | ports: 8 | - "80:80" 9 | - "443:443" 10 | - "127.0.0.1:2020:22" 11 | volumes: 12 | - sites:/var/www/html 13 | - ./etc:/etc/nginx/conf.d 14 | hostname: web 15 | networks: 16 | - dlaravel_net 17 | 18 | #=== php service ========================== 19 | php: 20 | network_mode: "service:web" 21 | image: deviny/fpm:7.4.4ssh 22 | volumes: 23 | - ./etc/php:/usr/local/etc/php/conf.d 24 | - sites:/var/www/html 25 | - ./etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf 26 | - ~/.ssh/dlaravel_rsa.pub:/home/dlaravel/.ssh/authorized_keys 27 | - ~/.dlaravel/cache:/home/dlaravel/.composer/cache 28 | environment: 29 | - TZ=Asia/Taipei 30 | 31 | #=== db service =========================== 32 | db: 33 | image: mysql:8.0.18 34 | command: --default-authentication-plugin=mysql_native_password --lower-case-table-names=0 --sql_mode="" 35 | hostname: db 36 | ports: 37 | - "127.0.0.1:3306:3306" 38 | volumes: 39 | - ./data:/var/lib/mysql 40 | environment: 41 | - MYSQL_ALLOW_EMPTY_PASSWORD= "yes" 42 | - TZ=Asia/Taipei 43 | networks: 44 | - dlaravel_net 45 | 46 | volumes: 47 | sites: 48 | driver: local 49 | driver_opts: 50 | type: nfs 51 | o: addr=host.docker.internal,rw,nolock,hard,nointr,nfsvers=3 52 | device: ":${PWD}/sites" 53 | 54 | #=== top-level netowks key ====================== 55 | networks: 56 | dlaravel_net: 57 | -------------------------------------------------------------------------------- /stack.yml: -------------------------------------------------------------------------------- 1 | #docker stack deploy -c stack.yaml dlaravel 2 | version: '3.6' 3 | services: 4 | #=== web service ====================== 5 | web: 6 | image: dlaravel_web 7 | dns: 8.8.8.8 8 | ports: 9 | - "80:80" 10 | - "443:443" 11 | volumes: 12 | - sites:/var/www/html 13 | hostname: web 14 | networks: 15 | - dlaravel_net 16 | 17 | #=== php service ========================== 18 | php: 19 | network_mode: "service:web" 20 | image: dlaravel_php 21 | volumes: 22 | - sites:/var/www/html 23 | - php_session:/var/lib/php/session 24 | environment: 25 | - TZ=Asia/Taipei 26 | 27 | #=== db service =========================== 28 | db: 29 | image: db 30 | hostname: dlaravel_db 31 | ports: 32 | - "3306" 33 | volumes: 34 | - data:/var/lib/mysql 35 | environment: 36 | - MYSQL_ALLOW_EMPTY_PASSWORD= "yes" 37 | - TZ=Asia/Taipei 38 | networks: 39 | - dlaravel_net 40 | 41 | #=============================================== 42 | volumes: 43 | cache: 44 | driver: local 45 | driver_opts: 46 | type: none 47 | o: bind 48 | device: ${PWD}/etc/cache/cache 49 | data: 50 | driver: local 51 | driver_opts: 52 | type: none 53 | o: bind 54 | device: ${PWD}/data 55 | sites: 56 | driver: local 57 | driver_opts: 58 | type: none 59 | o: bind 60 | device: ${PWD}/sites 61 | php_session: 62 | driver: local 63 | driver_opts: 64 | type: none 65 | o: bind 66 | device: ${PWD}/php_session 67 | 68 | #=== top-level netowks key ====================== 69 | networks: 70 | dlaravel_net: 71 | -------------------------------------------------------------------------------- /etc/swoole.sample: -------------------------------------------------------------------------------- 1 | upstream laravels { 2 | # Connect IP:Port 3 | server 127.0.0.1:5200 weight=5 max_fails=3 fail_timeout=30s; 4 | keepalive 16; 5 | } 6 | server { 7 | listen 80; 8 | 9 | set $basepath "/var/www/html"; 10 | set $domain $host; 11 | 12 | # check one name domain for simple application 13 | if ($domain ~ "^(.[^.]*)\.\w+$") { 14 | set $domain $1; 15 | set $rootpath "${domain}"; 16 | set $servername "${domain}.\w+"; 17 | } 18 | # check multi name domain to multi application 19 | if ($domain ~ "^(.*)\.(.[^.]*)\.\w+$") { 20 | set $subdomain $1; 21 | set $domain $2; 22 | set $rootpath "${domain}"; 23 | set $servername "${subdomain}.${domain}.\w+"; 24 | } 25 | 26 | 27 | #The location of our project's public directory. 28 | root $basepath/$rootpath/public/; 29 | 30 | index index.php index.html index.htm; 31 | 32 | # Nginx 处理静态资源,LaravelS 处理动态资源 33 | location / { 34 | try_files $uri @laravels; 35 | } 36 | 37 | location @laravels { 38 | proxy_http_version 1.1; 39 | proxy_set_header Connection ""; 40 | proxy_set_header X-Real-IP $remote_addr; 41 | proxy_set_header X-Real-PORT $remote_port; 42 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 43 | proxy_set_header Host $http_host; 44 | proxy_set_header Scheme $scheme; 45 | proxy_set_header Server-Protocol $server_protocol; 46 | proxy_set_header Server-Name $server_name; 47 | proxy_set_header Server-Addr $server_addr; 48 | proxy_set_header Server-Port $server_port; 49 | proxy_pass http://laravels; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /etc/default.sample: -------------------------------------------------------------------------------- 1 | server { 2 | index index.php index.html; 3 | 4 | set $basepath "/var/www/html"; 5 | set $domain $host; 6 | 7 | # using subdomain as project name 8 | if ($domain ~ "^([^.]+)\.(.+)") { 9 | set $subdomain $1; 10 | set $domain $2; 11 | set $rootpath "${subdomain}"; 12 | set $servername "${subdomain}.${domain}"; 13 | } 14 | 15 | server_name $servername; 16 | 17 | error_log /var/log/nginx/error.log; 18 | access_log /var/log/nginx/access.log; 19 | 20 | #The location of our project's public directory. 21 | root $basepath/$rootpath/public/; 22 | 23 | client_max_body_size 50m; 24 | 25 | # Point index to the Laravel front controller. 26 | index index.php index.html; 27 | autoindex off; 28 | 29 | location / { 30 | try_files $uri $uri/ /index.php?$query_string; 31 | # return 301 https://$host$request_uri; 32 | } 33 | 34 | #所有不存在的檔案都要導向index.php 35 | if (!-e $request_filename) 36 | { 37 | rewrite ^/(.*)$ /index.php?$query_string; 38 | break; 39 | } 40 | 41 | # Remove trailing slash to please routing system. 42 | if (!-d $request_filename) { 43 | rewrite ^/(.+)/$ /$1 permanent; 44 | } 45 | 46 | location ~ \.php$ { 47 | try_files $uri =404; 48 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 49 | fastcgi_pass web:9000; 50 | fastcgi_index index.php; 51 | include fastcgi_params; 52 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 53 | fastcgi_param PATH_INFO $fastcgi_path_info; 54 | fastcgi_read_timeout 500; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /create.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import sys 4 | import re 5 | from scripts import docker 6 | arguments_list = sys.argv[1:] 7 | number_of_arguments = len(arguments_list) 8 | 9 | #參數 10 | if(number_of_arguments > 0): 11 | parameter = arguments_list[0] 12 | 13 | if(number_of_arguments == 1): 14 | 15 | if(parameter=="--help" or parameter=="help"): 16 | print("usage: {} [] [Project name]".format(sys.argv[0])) 17 | print("Example") 18 | print("{} [project name]: Create a new laravel proejct into sites folder.".format(sys.argv[0])) 19 | print("{} [project name] \"5.4.*\": You can specify the version you want to install.".format(sys.argv[0])) 20 | print("options:") 21 | help=""" --help : help 22 | --host [project name]: Adding [project name].test to /etc/hosts, But don't want to install laravel framework. 23 | --db [project name]: Create a database name and user name that is the same as project name.""" 24 | print(help) 25 | else: 26 | project=parameter 27 | try: 28 | docker.dlaravel_new(project) 29 | docker.dlaravel_config(project) 30 | docker.create_db(project) 31 | print("http://{}.test".format(project)) 32 | docker.create_host(project) 33 | except: 34 | pass 35 | 36 | 37 | if(number_of_arguments == 2): 38 | 39 | if(re.search("^--\\w+", arguments_list[0], re.I | re.M)): 40 | option=arguments_list[0] 41 | project=arguments_list[1] 42 | else: 43 | option=arguments_list[1] 44 | project=arguments_list[0] 45 | 46 | if(option=="--db"): 47 | docker.create_db(project) 48 | 49 | if(option=="--host"): 50 | docker.create_host(project) 51 | -------------------------------------------------------------------------------- /samples/docker-compose-sample.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | #=== web service ====================== 4 | web: 5 | image: nginx 6 | dns: 8.8.8.8 7 | ports: 8 | # normal 9 | - "80:80" 10 | - "443:443" 11 | #for echo-server 12 | #- "6001:6001" 13 | volumes: 14 | - ./sites:/var/www/html:cached 15 | - ./etc:/etc/nginx/conf.d 16 | - ./var/log/web:/var/log/nginx 17 | hostname: web 18 | networks: 19 | - dlaravel_net 20 | 21 | #=== php service ========================== 22 | php: 23 | network_mode: "service:web" 24 | image: deviny/fpm:7.4.3 25 | #image: deviny/fpm:7.3.15 26 | #image: deviny/fpm:7.2.28 27 | volumes: 28 | - ./etc/php:/usr/local/etc/php/conf.d 29 | - ./sites:/var/www/html:cached 30 | - ./etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf 31 | ###create composer cache### 32 | - ~/.dlaravel/cache:/home/dlaravel/.composer/cache 33 | #- ./var/log/php:/var/log 34 | #- ./etc/supervisor:/etc/supervisor/conf.d 35 | #- ./var/log/supervisor:/var/log/supervisor 36 | environment: 37 | - TZ=Asia/Taipei 38 | #- PHP_IDE_CONFIG=serverName=dlaravel 39 | #- XDEBUG_CONFIG="remote_host=???? profiler_enable=1" 40 | #- ./etc/bash_aliases:/home/dlaravel/.bash_aliases 41 | #command: bash -c "php-fpm -D&&php /var/www/html/default/bin/laravels start" 42 | 43 | #=== db service =========================== 44 | db: 45 | image: mysql:8.0.18 46 | command: --default-authentication-plugin=mysql_native_password 47 | hostname: db 48 | ports: 49 | - "127.0.0.1:3306:3306" 50 | volumes: 51 | - ./data:/var/lib/mysql 52 | environment: 53 | #- MYSQL_DATABASE=homestead 54 | #- MYSQL_USER=homestead 55 | #- MYSQL_PASSWORD=secret 56 | #- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD-secret} 57 | - MYSQL_ALLOW_EMPTY_PASSWORD= "yes" 58 | - TZ=Asia/Taipei 59 | networks: 60 | - dlaravel_net 61 | 62 | #=== top-level netowks key ====================== 63 | networks: 64 | dlaravel_net: 65 | -------------------------------------------------------------------------------- /console.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import sys 4 | from scripts import docker 5 | arguments_list = sys.argv[1:] 6 | number_of_arguments = len(arguments_list) 7 | 8 | #參數 9 | if(number_of_arguments > 0): 10 | parameter = arguments_list[0] 11 | else: 12 | docker.execute(["exec","-u","dlaravel","php","bash"]) 13 | 14 | if(number_of_arguments == 1): 15 | if(parameter=="help"): 16 | docker.help() 17 | 18 | if(parameter=="node"): 19 | docker.node() 20 | 21 | if(parameter=="ps"): 22 | docker.ps() 23 | 24 | if(parameter=="up"): 25 | docker.up() 26 | 27 | if(parameter=="down"): 28 | docker.down() 29 | 30 | if(parameter=="pull"): 31 | docker.pull() 32 | 33 | if(parameter=="restart"): 34 | docker.restart() 35 | 36 | if(parameter=="info"): 37 | docker.info() 38 | 39 | if(parameter=="random"): 40 | docker.random() 41 | 42 | if(parameter=="normal"): 43 | docker.normal() 44 | 45 | if(parameter=="swoole"): 46 | docker.swoole() 47 | 48 | if(parameter=="custom"): 49 | docker.custom() 50 | 51 | if(parameter=="mysql"): 52 | docker.mysql() 53 | 54 | if(parameter=="version"): 55 | docker.version() 56 | 57 | if(parameter=="alias"): 58 | docker.alias() 59 | 60 | if(parameter=="ext"): 61 | docker.ext() 62 | 63 | if(parameter=="reload"): 64 | docker.reload() 65 | 66 | if(parameter=="public"): 67 | docker.public() 68 | 69 | if(parameter=="secure"): 70 | docker.secure() 71 | 72 | if(parameter=="clear"): 73 | docker.clear() 74 | 75 | if(parameter=="logs"): 76 | docker.logs() 77 | 78 | if(parameter=="link"): 79 | docker.link() 80 | 81 | if(parameter=="chowner"): 82 | docker.chowner() 83 | 84 | if(parameter=="test"): 85 | docker.check_link() 86 | 87 | if(number_of_arguments > 1): 88 | if(parameter=="exec"): 89 | docker.execute(arguments_list) 90 | 91 | if(parameter=="logs"): 92 | docker.logs(arguments_list[1:]) 93 | -------------------------------------------------------------------------------- /etc/public-ssl.sample: -------------------------------------------------------------------------------- 1 | server { 2 | listen *:443 ssl http2; 3 | #######外部存取設定############ 4 | #請依這個檔按為範本拷貝出來修改。 5 | #cp public.conf my-domain.conf 6 | 7 | #調整下方的域名或IP位置 8 | #server_name www.ccc.tc; 9 | server_name 36-229-1-29.dynamic-ip.hinet.net; 10 | 11 | #抓IP位置(開頭及結束都是數字) 12 | #server_name "~^(\d+\.).+\d$"; 13 | 14 | #sites內,要使用的專案資料夾名稱 15 | set $projectname "www"; 16 | 17 | ##########下方不需要調整################## 18 | # 19 | location ^~ /.well-known/acme-challenge { 20 | root /etc/nginx/conf.d/ssl; 21 | default_type text/plain; 22 | } 23 | ########SSL設定######### 24 | # 25 | ssl_certificate /etc/nginx/conf.d/ssl/fullchain.pem; 26 | ssl_certificate_key /etc/nginx/conf.d/ssl/privkey.pem; 27 | ssl_client_certificate /etc/nginx/conf.d/ssl/cert.pem; 28 | ssl_session_cache shared:SSL:10m; 29 | ssl_session_timeout 10m; 30 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 31 | ssl_ciphers "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS:!AES256"; 32 | ssl_prefer_server_ciphers on; 33 | 34 | ######################## 35 | 36 | set $basepath "/var/www/html"; 37 | index index.php index.html; 38 | 39 | error_log /var/log/nginx/ssl_error.log; 40 | access_log /var/log/nginx/ssl_access.log; 41 | 42 | #The location of our project's public directory. 43 | root $basepath/$projectname/public/; 44 | 45 | client_max_body_size 50m; 46 | 47 | # Point index to the Laravel front controller. 48 | index index.php index.html; 49 | autoindex on; 50 | 51 | location / { 52 | try_files $uri $uri/ /?$query_string; 53 | } 54 | 55 | # Remove trailing slash to please routing system. 56 | if (!-d $request_filename) { 57 | rewrite ^/(.+)/$ /$1 permanent; 58 | } 59 | 60 | location ~ \.php$ { 61 | try_files $uri =404; 62 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 63 | fastcgi_pass web:9000; 64 | fastcgi_index index.php; 65 | include fastcgi_params; 66 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 67 | fastcgi_param PATH_INFO $fastcgi_path_info; 68 | fastcgi_read_timeout 500; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /etc/project-ssl.sample: -------------------------------------------------------------------------------- 1 | server { 2 | listen *:443 ssl http2; 3 | 4 | server_name localhost *.test; 5 | 6 | set $basepath "/var/www/html"; 7 | 8 | error_log /var/log/nginx/error.log; 9 | access_log /var/log/nginx/access.log; 10 | 11 | 12 | client_max_body_size 50m; 13 | ssl_certificate /etc/nginx/conf.d/ssl/cert.crt; 14 | ssl_certificate_key /etc/nginx/conf.d/ssl/cert.key; 15 | ssl_client_certificate /etc/nginx/conf.d/ssl/cert.crt; 16 | ssl_session_cache shared:SSL:10m; 17 | ssl_session_timeout 10m; 18 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 19 | ssl_ciphers "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS:!AES256"; 20 | ssl_prefer_server_ciphers on; 21 | 22 | gzip on; 23 | gzip_disable "msie6"; 24 | gzip_comp_level 6; 25 | gzip_buffers 16 8k; 26 | gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/xml+rss; 27 | gzip_vary on; 28 | gzip_proxied any; 29 | 30 | location ~* \.(?:ico|css|js|gif|jpe?g|png|woff)$ { 31 | expires 30d; 32 | add_header Pragma public; 33 | add_header Cache-Control "public"; 34 | } 35 | 36 | root $basepath/public/; 37 | index index.php index.html; 38 | autoindex off; 39 | 40 | #所有不存在的檔案都要導向index.php 41 | if (!-e $request_filename) 42 | { 43 | rewrite ^/(.*)$ /index.php?/$1 last; 44 | break; 45 | } 46 | 47 | location / { 48 | try_files $uri $uri/ /index.php?$query_string; 49 | } 50 | 51 | if (!-d $request_filename) { 52 | rewrite ^/(.+)/$ /$1 permanent; 53 | } 54 | 55 | #ssl on; 56 | location ~ \.php$ { 57 | try_files $uri =404; 58 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 59 | fastcgi_pass web:9000; 60 | fastcgi_index index.php; 61 | include fastcgi_params; 62 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 63 | fastcgi_param PATH_INFO $fastcgi_path_info; 64 | fastcgi_read_timeout 500; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /etc/default-ssl.sample: -------------------------------------------------------------------------------- 1 | server { 2 | listen *:443 ssl http2; 3 | 4 | set $basepath "/var/www/html"; 5 | set $domain $host; 6 | 7 | # using subdomain as project name 8 | if ($domain ~ "^([^.]+)\.(.+)") { 9 | set $subdomain $1; 10 | set $domain $2; 11 | set $rootpath "${subdomain}"; 12 | set $servername "${subdomain}.${domain}"; 13 | } 14 | 15 | server_name $servername; 16 | 17 | client_max_body_size 50m; 18 | ssl_certificate /etc/nginx/conf.d/ssl/cert.crt; 19 | ssl_certificate_key /etc/nginx/conf.d/ssl/cert.key; 20 | ssl_client_certificate /etc/nginx/conf.d/ssl/cert.crt; 21 | ssl_session_cache shared:SSL:10m; 22 | ssl_session_timeout 10m; 23 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 24 | ssl_ciphers "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS:!AES256"; 25 | ssl_prefer_server_ciphers on; 26 | 27 | gzip on; 28 | gzip_disable "msie6"; 29 | gzip_comp_level 6; 30 | gzip_buffers 16 8k; 31 | gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/xml+rss; 32 | gzip_vary on; 33 | gzip_proxied any; 34 | 35 | location ~* \.(?:ico|css|js|gif|jpe?g|png|woff)$ { 36 | expires 30d; 37 | add_header Pragma public; 38 | add_header Cache-Control "public"; 39 | } 40 | 41 | root $basepath/$rootpath/public/; 42 | index index.php index.html; 43 | autoindex off; 44 | 45 | location / { 46 | try_files $uri $uri/ /index.php?$query_string; 47 | } 48 | 49 | #所有不存在的檔案都要導向index.php 50 | if (!-e $request_filename) 51 | { 52 | rewrite ^/(.*)$ /index.php?$query_string; 53 | break; 54 | } 55 | 56 | if (!-d $request_filename) { 57 | rewrite ^/(.+)/$ /$1 permanent; 58 | } 59 | 60 | #ssl on; 61 | location ~ \.php$ { 62 | try_files $uri =404; 63 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 64 | fastcgi_pass web:9000; 65 | fastcgi_index index.php; 66 | include fastcgi_params; 67 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 68 | fastcgi_param PATH_INFO $fastcgi_path_info; 69 | fastcgi_read_timeout 500; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /dlaravel: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ "${1}" == "clear" ]; then 3 | echo "移除hosts內所有的*.test域名嗎?(y/n)" 4 | read ans 5 | if [ ${ans} = 'y' ]; then 6 | #移除hosts下,所有的.test名稱 7 | sudo sed -i.bak '/\.test$/d' /etc/hosts 8 | fi 9 | exit; 10 | fi 11 | 12 | #移除系統上所有的containers及images及hosts 13 | if [ "${1}" == "uninstall" ]; then 14 | echo "Warning!!All your docker images and containers will be removed!!" 15 | echo "Please make sure you know what you are doing." 16 | echo "警告!!將清空所有的docker images及containers及在hosts內的所有*.test設定(y/n)" 17 | read ans 18 | if [ ${ans} = 'y' ]; then 19 | docker-compose -f docker-compose.yml down --remove-orphans > /dev/null 2>&1 20 | sudo sed -i.bak '/\.test$/d' /etc/hosts 21 | docker rm $(docker ps -a -q) > /dev/null 2>&1 22 | docker rmi $(docker images -q) > /dev/null 2>&1 23 | fi 24 | exit; 25 | fi 26 | 27 | echo "重整hosts檔,將移除/etc/hosts內所有的*.test域名及dlaravel的etc/*.conf所有nginx設定檔,使用sites資料夾重建設定嗎?(y/n)" 28 | read ans 29 | if [ ${ans} = 'n' ]; then 30 | exit 31 | else 32 | #建立sites資料夾,如果不存在 33 | if [ ! -d "sites/" ]; then 34 | echo "sites資料夾未建立" 35 | exit; 36 | fi 37 | #移除hosts下,所有的.test名稱 38 | sudo sed -i.bak '/\.test$/d' /etc/hosts 39 | #抓出sites資料夾下所有的目錄 40 | ls -ld sites/*|grep ^d|cut -d '/' -f2| awk '{ printf "127.0.0.1 %s.test\n", $0}' > ./etc/dlaravel_sites 41 | #暫存目前的hosts檔 42 | sudo cat /etc/hosts > ./etc/hosts_temp 43 | #組合產生出來的127.0.0.1 *.test清單,到暫存的hosts內 44 | sudo cat ./etc/dlaravel_sites >> ./etc/hosts_temp 45 | #確認hosts_temp是存在的,才調整/etc/hosts檔 46 | if [ $? -eq 0 ]; then 47 | #移動並更新 48 | sudo mv ./etc/hosts_temp /etc/hosts 49 | #調整權限 50 | sudo chown root /etc/hosts 51 | sudo chgrp wheel /etc/hosts 52 | #重建 *.conf 53 | #移除nginx下的所有*.conf的設定檔 54 | mv ./etc/default.conf ./etc/default.temp 55 | 56 | if [ -f "./etc/public.conf" ]; then 57 | mv ./etc/public.conf ./etc/public.temp 58 | fi 59 | 60 | if [ -f "./etc/php-fpm.d/www.conf" ]; then 61 | mv ./etc/php-fpm.d/www.conf ./etc/php-fpm.d/www.temp 62 | fi 63 | 64 | #檢測是否有ssl.conf 65 | if [ -f "./etc/default-ssl.conf" ]; then 66 | mv ./etc/default-ssl.conf ./etc/default-ssl.temp 67 | fi 68 | find ./etc -name "*.conf" -exec rm {} \; 69 | 70 | #還原 71 | if [ -f "./etc/default.temp" ]; then 72 | mv ./etc/default.temp ./etc/default.conf 73 | fi 74 | 75 | if [ -f "./etc/public.temp" ]; then 76 | mv ./etc/public.temp ./etc/public.conf 77 | fi 78 | 79 | if [ -f "./etc/php-fpm.d/www.temp" ]; then 80 | mv ./etc/php-fpm.d/www.temp ./etc/php-fpm.d/www.conf 81 | fi 82 | 83 | if [ -f "./etc/default-ssl.temp" ]; then 84 | mv ./etc/default-ssl.temp ./etc/default-ssl.conf 85 | fi 86 | 87 | fi 88 | #移除暫存的檔案 89 | rm ./etc/dlaravel_sites 90 | fi 91 | dscacheutil -flushcache 92 | -------------------------------------------------------------------------------- /dockerfiles/fpm/Dockerfile_php_5.6.x: -------------------------------------------------------------------------------- 1 | FROM php:5.6.39-fpm 2 | #Docker官方說明文件 3 | #https://hub.docker.com/_/php/ 4 | RUN apt-get update && apt-get install -y \ 5 | libfreetype6-dev \ 6 | libjpeg62-turbo-dev \ 7 | #====安裝mcrypt==== 8 | autoconf \ 9 | libc-dev \ 10 | pkg-config \ 11 | libmcrypt-dev \ 12 | #================== 13 | libpng-dev \ 14 | ca-certificates \ 15 | curl \ 16 | xz-utils \ 17 | sudo \ 18 | cron \ 19 | inotify-tools \ 20 | git \ 21 | wget \ 22 | libldb-dev \ 23 | libldap2-dev \ 24 | libsasl2-dev \ 25 | python \ 26 | vim \ 27 | unzip \ 28 | mysql-client \ 29 | zip \ 30 | libgeoip-dev \ 31 | libpq-dev \ 32 | libzip-dev \ 33 | libbz2-dev \ 34 | libgd2-dev \ 35 | libjpeg-dev \ 36 | libgif-dev \ 37 | libxml2-dev \ 38 | apt-utils \ 39 | supervisor \ 40 | wget \ 41 | && docker-php-ext-install -j$(nproc) pdo_mysql mysqli pgsql pdo_pgsql bcmath \ 42 | && docker-php-ext-install -j$(nproc) exif hash gettext sockets ctype xml zip pcntl intl\ 43 | && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ 44 | && docker-php-ext-install -j$(nproc) gd 45 | 46 | #docker-php-ext-install 可安裝外掛大概如下: 47 | #bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip 48 | 49 | RUN pecl install xdebug-2.5.5 \ 50 | pecl install swoole \ 51 | install redis \ 52 | && docker-php-ext-enable xdebug 53 | 54 | #建立Dlaravel的使用者 55 | RUN adduser --disabled-password --gecos "" dlaravel &&\ 56 | echo "dlaravel ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/dlaravel && \ 57 | chmod 0440 /etc/sudoers.d/dlaravel 58 | 59 | #安裝composer 60 | RUN EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig); \ 61 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \ 62 | ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');"); \ 63 | php composer-setup.php; \ 64 | php -r "unlink('composer-setup.php');"; \ 65 | mv composer.phar /usr/local/bin/composer; \ 66 | #加入dlaravel使用者 67 | sudo -u dlaravel /usr/local/bin/composer global require "laravel/installer"; \ 68 | sudo -u dlaravel /usr/local/bin/composer global require "phpunit/phpunit=5.5.*"; \ 69 | sudo -u dlaravel echo 'export TERM=xterm-256color' >> /home/dlaravel/.bashrc; \ 70 | sudo -u dlaravel echo 'export PATH=vendor/bin:/home/dlaravel/.composer/vendor/bin:$PATH' >> /home/dlaravel/.bashrc; \ 71 | #加入composer環境變數 72 | echo 'export TERM=xterm-256color' >> /root/.bashrc; \ 73 | echo 'export PATH=/root/.composer/vendor/bin:$PATH' >> /root/.bashrc; 74 | 75 | EXPOSE 9000 76 | USER dlaravel 77 | CMD ["php-fpm"] 78 | -------------------------------------------------------------------------------- /dockerfiles/fpm/Dockerfile_php_8.0.x: -------------------------------------------------------------------------------- 1 | FROM php:8.0.30-fpm 2 | #Docker官方說明文件 3 | RUN apt-get update && apt-get install -y \ 4 | autoconf \ 5 | libc-dev \ 6 | pkg-config \ 7 | libmcrypt-dev \ 8 | libsnmp-dev \ 9 | libsmi2-common \ 10 | libsmi2-dev \ 11 | libperl-dev \ 12 | snmp \ 13 | ca-certificates \ 14 | curl \ 15 | xz-utils \ 16 | sudo \ 17 | cron \ 18 | inotify-tools \ 19 | git \ 20 | wget \ 21 | libmagickwand-dev \ 22 | libldap2-dev \ 23 | libsasl2-dev \ 24 | python \ 25 | vim \ 26 | unzip \ 27 | mariadb-client \ 28 | zip \ 29 | libgeoip-dev \ 30 | libpq-dev \ 31 | libzip-dev \ 32 | libbz2-dev \ 33 | libxml2-dev \ 34 | apt-utils \ 35 | supervisor \ 36 | libfreetype6-dev \ 37 | libjpeg62-turbo-dev \ 38 | libldb-dev \ 39 | libpng-dev 40 | RUN docker-php-ext-configure gd --with-freetype --with-jpeg 41 | RUN docker-php-ext-install -j$(nproc) gd \ 42 | && docker-php-ext-install -j$(nproc) pdo_mysql mysqli pgsql pdo_pgsql gettext sockets ctype xml zip pcntl bcmath bz2 43 | RUN docker-php-ext-install -j$(nproc) exif zip gettext sockets ctype pcntl intl 44 | 45 | #docker-php-ext-install 可安裝外掛大概如下: 46 | #bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip 47 | 48 | #RUN pecl install redis \ 49 | # pecl install imagick \ 50 | # pecl install swoole 51 | 52 | RUN pecl install redis 53 | 54 | #建立Dlaravel的使用者 55 | RUN adduser --disabled-password --gecos "" dlaravel &&\ 56 | echo "dlaravel ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/dlaravel && \ 57 | chmod 0440 /etc/sudoers.d/dlaravel 58 | 59 | #安裝composer 60 | RUN EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig); \ 61 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \ 62 | ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');"); \ 63 | php composer-setup.php; \ 64 | php -r "unlink('composer-setup.php');"; \ 65 | mv composer.phar /usr/local/bin/composer; \ 66 | #加入dlaravel使用者 67 | sudo -u dlaravel /usr/local/bin/composer global require "laravel/installer"; \ 68 | sudo -u dlaravel /usr/local/bin/composer global require "phpunit/phpunit"; \ 69 | sudo -u dlaravel echo 'export TERM=xterm-256color' >> /home/dlaravel/.bashrc; \ 70 | sudo -u dlaravel echo 'export PATH=vendor/bin:/home/dlaravel/.composer/vendor/bin:$PATH' >> /home/dlaravel/.bashrc; \ 71 | #加入composer環境變數 72 | echo 'export TERM=xterm-256color' >> /root/.bashrc; \ 73 | echo 'export PATH=/root/.composer/vendor/bin:$PATH' >> /root/.bashrc; 74 | 75 | EXPOSE 9000 76 | USER dlaravel 77 | 78 | WORKDIR /var/www/html 79 | CMD ["php-fpm"] 80 | -------------------------------------------------------------------------------- /dockerfiles/fpm/Dockerfile_php_8.1.x: -------------------------------------------------------------------------------- 1 | FROM php:8.1.31-fpm 2 | #Docker官方說明文件 3 | RUN apt-get update && apt-get install -y \ 4 | autoconf \ 5 | libc-dev \ 6 | pkg-config \ 7 | libmcrypt-dev \ 8 | libsnmp-dev \ 9 | libsmi2-common \ 10 | libsmi2-dev \ 11 | libperl-dev \ 12 | snmp \ 13 | ca-certificates \ 14 | curl \ 15 | xz-utils \ 16 | sudo \ 17 | cron \ 18 | inotify-tools \ 19 | git \ 20 | wget \ 21 | libmagickwand-dev \ 22 | libldap2-dev \ 23 | libsasl2-dev \ 24 | python3 \ 25 | vim \ 26 | unzip \ 27 | mariadb-client \ 28 | zip \ 29 | libgeoip-dev \ 30 | libpq-dev \ 31 | libzip-dev \ 32 | libbz2-dev \ 33 | libxml2-dev \ 34 | libsodium-dev \ 35 | apt-utils \ 36 | supervisor \ 37 | libfreetype6-dev \ 38 | libjpeg62-turbo-dev \ 39 | libpng-dev \ 40 | && docker-php-ext-configure gd --with-freetype --with-jpeg \ 41 | && docker-php-ext-install -j$(nproc) ftp gd sodium\ 42 | && docker-php-ext-install -j$(nproc) pdo_mysql mysqli pgsql pdo_pgsql gettext sockets ctype xml zip pcntl bcmath bz2 \ 43 | && docker-php-ext-install -j$(nproc) exif zip gettext sockets ctype pcntl intl 44 | 45 | #docker-php-ext-install 可安裝外掛大概如下: 46 | #bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip 47 | 48 | #RUN pecl install redis \ 49 | # pecl install imagick \ 50 | # pecl install swoole 51 | 52 | RUN pecl install redis 53 | 54 | #建立Dlaravel的使用者 55 | RUN adduser --disabled-password --gecos "" dlaravel &&\ 56 | echo "dlaravel ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/dlaravel && \ 57 | chmod 0440 /etc/sudoers.d/dlaravel 58 | 59 | #安裝composer 60 | RUN EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig); \ 61 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \ 62 | ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');"); \ 63 | php composer-setup.php; \ 64 | php -r "unlink('composer-setup.php');"; \ 65 | mv composer.phar /usr/local/bin/composer; \ 66 | sudo -u dlaravel /usr/local/bin/composer global require "laravel/installer"; \ 67 | sudo -u dlaravel /usr/local/bin/composer global require "phpunit/phpunit"; \ 68 | sudo -u dlaravel echo 'export TERM=xterm-256color' >> /home/dlaravel/.bashrc; \ 69 | sudo -u dlaravel echo 'export PATH=vendor/bin:/home/dlaravel/.composer/vendor/bin:$PATH' >> /home/dlaravel/.bashrc; \ 70 | echo 'export TERM=xterm-256color' >> /root/.bashrc; \ 71 | echo 'export PATH=/root/.composer/vendor/bin:$PATH' >> /root/.bashrc; 72 | 73 | EXPOSE 9000 74 | USER dlaravel 75 | 76 | WORKDIR /var/www/html 77 | CMD ["php-fpm"] 78 | -------------------------------------------------------------------------------- /dockerfiles/fpm/Dockerfile_php_8.3.x: -------------------------------------------------------------------------------- 1 | FROM php:8.3.22-fpm 2 | #Docker官方說明文件 3 | RUN apt-get update && apt-get install -y \ 4 | autoconf \ 5 | libc-dev \ 6 | pkg-config \ 7 | libmcrypt-dev \ 8 | libsnmp-dev \ 9 | libsmi2-common \ 10 | libsmi2-dev \ 11 | libperl-dev \ 12 | snmp \ 13 | ca-certificates \ 14 | curl \ 15 | xz-utils \ 16 | sudo \ 17 | cron \ 18 | inotify-tools \ 19 | git \ 20 | wget \ 21 | libmagickwand-dev \ 22 | libldap2-dev \ 23 | libsasl2-dev \ 24 | python3 \ 25 | vim \ 26 | unzip \ 27 | mariadb-client \ 28 | zip \ 29 | libgeoip-dev \ 30 | libpq-dev \ 31 | libzip-dev \ 32 | libbz2-dev \ 33 | libxml2-dev \ 34 | libsodium-dev \ 35 | apt-utils \ 36 | supervisor \ 37 | libfreetype6-dev \ 38 | libjpeg62-turbo-dev \ 39 | libpng-dev \ 40 | && docker-php-ext-configure gd --with-freetype --with-jpeg \ 41 | && docker-php-ext-install -j$(nproc) ftp gd sodium\ 42 | && docker-php-ext-install -j$(nproc) pdo_mysql mysqli pgsql pdo_pgsql gettext sockets ctype xml zip pcntl bcmath bz2 \ 43 | && docker-php-ext-install -j$(nproc) exif zip gettext sockets ctype pcntl intl 44 | 45 | #docker-php-ext-install 可安裝外掛大概如下: 46 | #bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip 47 | 48 | #RUN pecl install redis \ 49 | # pecl install imagick \ 50 | # pecl install swoole 51 | 52 | RUN pecl install redis 53 | 54 | #建立Dlaravel的使用者 55 | RUN adduser --disabled-password --gecos "" dlaravel &&\ 56 | echo "dlaravel ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/dlaravel && \ 57 | chmod 0440 /etc/sudoers.d/dlaravel 58 | 59 | #安裝composer 60 | RUN EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig); \ 61 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \ 62 | ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');"); \ 63 | php composer-setup.php; \ 64 | php -r "unlink('composer-setup.php');"; \ 65 | mv composer.phar /usr/local/bin/composer; \ 66 | sudo -u dlaravel /usr/local/bin/composer global require "laravel/installer"; \ 67 | sudo -u dlaravel /usr/local/bin/composer global require "phpunit/phpunit"; \ 68 | sudo -u dlaravel echo 'export TERM=xterm-256color' >> /home/dlaravel/.bashrc; \ 69 | sudo -u dlaravel echo 'export PATH=vendor/bin:/home/dlaravel/.config/composer/vendor/bin:$PATH' >> /home/dlaravel/.bashrc; \ 70 | echo 'export TERM=xterm-256color' >> /root/.bashrc; \ 71 | echo 'export PATH=/root/.composer/vendor/bin:$PATH' >> /root/.bashrc; 72 | 73 | EXPOSE 9000 74 | USER dlaravel 75 | 76 | WORKDIR /var/www/html 77 | CMD ["php-fpm"] 78 | -------------------------------------------------------------------------------- /dockerfiles/fpm/Dockerfile_php_8.4.x: -------------------------------------------------------------------------------- 1 | FROM php:8.4.10-fpm 2 | #Docker官方說明文件 3 | RUN apt-get update && apt-get install -y \ 4 | autoconf \ 5 | libc-dev \ 6 | pkg-config \ 7 | libmcrypt-dev \ 8 | libsnmp-dev \ 9 | libsmi2-common \ 10 | libsmi2-dev \ 11 | libperl-dev \ 12 | snmp \ 13 | ca-certificates \ 14 | curl \ 15 | xz-utils \ 16 | sudo \ 17 | cron \ 18 | inotify-tools \ 19 | git \ 20 | wget \ 21 | libmagickwand-dev \ 22 | libldap2-dev \ 23 | libsasl2-dev \ 24 | python3 \ 25 | vim \ 26 | unzip \ 27 | mariadb-client \ 28 | zip \ 29 | libgeoip-dev \ 30 | libpq-dev \ 31 | libzip-dev \ 32 | libbz2-dev \ 33 | libxml2-dev \ 34 | libsodium-dev \ 35 | apt-utils \ 36 | supervisor \ 37 | libfreetype6-dev \ 38 | libjpeg62-turbo-dev \ 39 | libpng-dev \ 40 | && docker-php-ext-configure gd --with-freetype --with-jpeg \ 41 | && docker-php-ext-install -j$(nproc) ftp gd sodium\ 42 | && docker-php-ext-install -j$(nproc) pdo_mysql mysqli pgsql pdo_pgsql gettext sockets ctype xml zip pcntl bcmath bz2 \ 43 | && docker-php-ext-install -j$(nproc) exif zip gettext sockets ctype pcntl intl 44 | 45 | #docker-php-ext-install 可安裝外掛大概如下: 46 | #bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip 47 | 48 | #RUN pecl install redis \ 49 | # pecl install imagick \ 50 | # pecl install swoole 51 | 52 | RUN pecl install redis 53 | 54 | #建立Dlaravel的使用者 55 | RUN adduser --disabled-password --gecos "" dlaravel &&\ 56 | echo "dlaravel ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/dlaravel && \ 57 | chmod 0440 /etc/sudoers.d/dlaravel 58 | 59 | #安裝composer 60 | RUN EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig); \ 61 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \ 62 | ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');"); \ 63 | php composer-setup.php; \ 64 | php -r "unlink('composer-setup.php');"; \ 65 | mv composer.phar /usr/local/bin/composer; \ 66 | sudo -u dlaravel /usr/local/bin/composer global require "laravel/installer"; \ 67 | sudo -u dlaravel /usr/local/bin/composer global require "phpunit/phpunit"; \ 68 | sudo -u dlaravel echo 'export TERM=xterm-256color' >> /home/dlaravel/.bashrc; \ 69 | sudo -u dlaravel echo 'export PATH=vendor/bin:/home/dlaravel/.config/composer/vendor/bin:$PATH' >> /home/dlaravel/.bashrc; \ 70 | echo 'export TERM=xterm-256color' >> /root/.bashrc; \ 71 | echo 'export PATH=/root/.composer/vendor/bin:$PATH' >> /root/.bashrc; 72 | 73 | EXPOSE 9000 74 | USER dlaravel 75 | 76 | WORKDIR /var/www/html 77 | CMD ["php-fpm"] 78 | -------------------------------------------------------------------------------- /dockerfiles/fpm/Dockerfile_php_8.2.x: -------------------------------------------------------------------------------- 1 | FROM php:8.2.28-fpm 2 | #Docker官方說明文件 3 | RUN apt-get update && apt-get install -y \ 4 | autoconf \ 5 | libc-dev \ 6 | pkg-config \ 7 | libmcrypt-dev \ 8 | libsnmp-dev \ 9 | libsmi2-common \ 10 | libsmi2-dev \ 11 | libperl-dev \ 12 | snmp \ 13 | ca-certificates \ 14 | curl \ 15 | xz-utils \ 16 | sudo \ 17 | cron \ 18 | inotify-tools \ 19 | git \ 20 | wget \ 21 | libmagickwand-dev \ 22 | libldap2-dev \ 23 | libsasl2-dev \ 24 | python3 \ 25 | vim \ 26 | unzip \ 27 | mariadb-client \ 28 | zip \ 29 | libgeoip-dev \ 30 | libpq-dev \ 31 | libzip-dev \ 32 | libbz2-dev \ 33 | libxml2-dev \ 34 | libsodium-dev \ 35 | apt-utils \ 36 | supervisor \ 37 | libfreetype6-dev \ 38 | libjpeg62-turbo-dev \ 39 | libpng-dev \ 40 | && docker-php-ext-configure gd --with-freetype --with-jpeg \ 41 | && docker-php-ext-install -j$(nproc) ftp gd sodium \ 42 | && docker-php-ext-install -j$(nproc) pdo_mysql mysqli pgsql pdo_pgsql gettext sockets ctype xml zip pcntl bcmath bz2 \ 43 | && docker-php-ext-install -j$(nproc) exif zip gettext sockets ctype pcntl intl 44 | 45 | #docker-php-ext-install 可安裝外掛大概如下: 46 | #bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip 47 | 48 | #RUN pecl install redis \ 49 | # pecl install imagick \ 50 | # pecl install swoole 51 | 52 | RUN pecl install redis 53 | 54 | #建立Dlaravel的使用者 55 | RUN adduser --disabled-password --gecos "" dlaravel &&\ 56 | echo "dlaravel ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/dlaravel && \ 57 | chmod 0440 /etc/sudoers.d/dlaravel 58 | 59 | #安裝composer 60 | RUN EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig); \ 61 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \ 62 | ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');"); \ 63 | php composer-setup.php; \ 64 | php -r "unlink('composer-setup.php');"; \ 65 | mv composer.phar /usr/local/bin/composer; \ 66 | sudo -u dlaravel /usr/local/bin/composer global require "laravel/installer"; \ 67 | sudo -u dlaravel /usr/local/bin/composer global require "phpunit/phpunit"; \ 68 | sudo -u dlaravel echo 'export TERM=xterm-256color' >> /home/dlaravel/.bashrc; \ 69 | sudo -u dlaravel echo 'export PATH=vendor/bin:/home/dlaravel/.config/composer/vendor/bin:$PATH' >> /home/dlaravel/.bashrc; \ 70 | echo 'export TERM=xterm-256color' >> /root/.bashrc; \ 71 | echo 'export PATH=/root/.composer/vendor/bin:$PATH' >> /root/.bashrc; 72 | 73 | EXPOSE 9000 74 | USER dlaravel 75 | 76 | WORKDIR /var/www/html 77 | CMD ["php-fpm"] 78 | -------------------------------------------------------------------------------- /dockerfiles/fpm/Dockerfile_php_7.1.x: -------------------------------------------------------------------------------- 1 | FROM php:7.1.33-fpm-buster 2 | RUN apt-get update && apt-get install -y \ 3 | autoconf \ 4 | libc-dev \ 5 | pkg-config \ 6 | libmcrypt-dev \ 7 | libsnmp-dev \ 8 | libsmi2-common \ 9 | libsmi2-dev \ 10 | libperl-dev \ 11 | snmp \ 12 | ca-certificates \ 13 | curl \ 14 | xz-utils \ 15 | sudo \ 16 | cron \ 17 | inotify-tools \ 18 | git \ 19 | wget \ 20 | libmagickwand-dev \ 21 | libldap2-dev \ 22 | libsasl2-dev \ 23 | python \ 24 | vim \ 25 | unzip \ 26 | mariadb-client \ 27 | zip \ 28 | libgeoip-dev \ 29 | libpq-dev \ 30 | libzip-dev \ 31 | libbz2-dev \ 32 | libxml2-dev \ 33 | apt-utils \ 34 | supervisor \ 35 | libfreetype6-dev \ 36 | libjpeg62-turbo-dev \ 37 | libpng-dev \ 38 | && docker-php-ext-configure gd --with-freetype --with-jpeg \ 39 | && docker-php-ext-install -j$(nproc) gd \ 40 | && docker-php-ext-install -j$(nproc) pdo_mysql mysqli pgsql pdo_pgsql gettext sockets ctype xml zip pcntl bcmath bz2 \ 41 | && docker-php-ext-install -j$(nproc) exif zip gettext sockets ctype pcntl intl 42 | 43 | #docker-php-ext-install 可安裝外掛大概如下: 44 | #bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip 45 | 46 | 47 | #RUN pecl install redis \ 48 | # pecl install xdebug \ 49 | # pecl install swoole \ 50 | # pecl install imagick \ 51 | 52 | #RUN pecl install redis 53 | 54 | #建立Dlaravel的使用者 55 | RUN adduser --disabled-password --gecos "" dlaravel &&\ 56 | echo "dlaravel ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/dlaravel && \ 57 | chmod 0440 /etc/sudoers.d/dlaravel 58 | 59 | #安裝composer 60 | RUN EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig); \ 61 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \ 62 | ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');"); \ 63 | php composer-setup.php; \ 64 | php -r "unlink('composer-setup.php');"; \ 65 | mv composer.phar /usr/local/bin/composer; \ 66 | sudo -u dlaravel /usr/local/bin/composer global require "laravel/installer"; \ 67 | sudo -u dlaravel /usr/local/bin/composer global require "phpunit/phpunit=5.5.*"; \ 68 | sudo -u dlaravel echo 'export TERM=xterm-256color' >> /home/dlaravel/.bashrc; \ 69 | sudo -u dlaravel echo 'export PATH=vendor/bin:/home/dlaravel/.composer/vendor/bin:$PATH' >> /home/dlaravel/.bashrc; \ 70 | echo 'export TERM=xterm-256color' >> /root/.bashrc; \ 71 | echo 'export PATH=/root/.composer/vendor/bin:$PATH' >> /root/.bashrc; 72 | 73 | #修正權限 74 | RUN mkdir -p /home/dlaravel/.composer/.cache&&chown dlaravel -R /home/dlaravel 75 | 76 | EXPOSE 9000 77 | USER dlaravel 78 | 79 | WORKDIR /var/www/html 80 | CMD ["php-fpm"] 81 | -------------------------------------------------------------------------------- /dockerfiles/fpm/Dockerfile_php_7.2.x: -------------------------------------------------------------------------------- 1 | FROM php:7.2.34-fpm-buster 2 | RUN apt-get update && apt-get install -y \ 3 | autoconf \ 4 | libc-dev \ 5 | pkg-config \ 6 | libmcrypt-dev \ 7 | libsnmp-dev \ 8 | libsmi2-common \ 9 | libsmi2-dev \ 10 | libperl-dev \ 11 | snmp \ 12 | ca-certificates \ 13 | curl \ 14 | xz-utils \ 15 | sudo \ 16 | cron \ 17 | inotify-tools \ 18 | git \ 19 | wget \ 20 | libmagickwand-dev \ 21 | libldap2-dev \ 22 | libsasl2-dev \ 23 | python \ 24 | vim \ 25 | unzip \ 26 | mariadb-client \ 27 | zip \ 28 | libgeoip-dev \ 29 | libpq-dev \ 30 | libzip-dev \ 31 | libbz2-dev \ 32 | libxml2-dev \ 33 | apt-utils \ 34 | supervisor \ 35 | libfreetype6-dev \ 36 | libjpeg62-turbo-dev \ 37 | libpng-dev \ 38 | && docker-php-ext-configure gd --with-freetype --with-jpeg \ 39 | && docker-php-ext-install -j$(nproc) gd \ 40 | && docker-php-ext-install -j$(nproc) pdo_mysql mysqli pgsql pdo_pgsql gettext sockets ctype xml zip pcntl bcmath bz2 \ 41 | && docker-php-ext-install -j$(nproc) exif zip gettext sockets ctype pcntl intl 42 | 43 | #docker-php-ext-install 可安裝外掛大概如下: 44 | #bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip 45 | 46 | 47 | #RUN pecl install redis \ 48 | # pecl install xdebug \ 49 | # pecl install swoole \ 50 | # pecl install imagick \ 51 | 52 | RUN pecl install redis 53 | 54 | #建立Dlaravel的使用者 55 | RUN adduser --disabled-password --gecos "" dlaravel &&\ 56 | echo "dlaravel ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/dlaravel && \ 57 | chmod 0440 /etc/sudoers.d/dlaravel 58 | 59 | #安裝composer 60 | RUN EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig); \ 61 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \ 62 | ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');"); \ 63 | php composer-setup.php; \ 64 | php -r "unlink('composer-setup.php');"; \ 65 | mv composer.phar /usr/local/bin/composer; \ 66 | sudo -u dlaravel /usr/local/bin/composer global require "laravel/installer"; \ 67 | sudo -u dlaravel /usr/local/bin/composer global require "phpunit/phpunit=5.5.*"; \ 68 | sudo -u dlaravel echo 'export TERM=xterm-256color' >> /home/dlaravel/.bashrc; \ 69 | sudo -u dlaravel echo 'export PATH=vendor/bin:/home/dlaravel/.composer/vendor/bin:$PATH' >> /home/dlaravel/.bashrc; \ 70 | echo 'export TERM=xterm-256color' >> /root/.bashrc; \ 71 | echo 'export PATH=/root/.composer/vendor/bin:$PATH' >> /root/.bashrc; 72 | 73 | #修正權限 74 | RUN mkdir -p /home/dlaravel/.composer/.cache&&chown dlaravel -R /home/dlaravel 75 | 76 | EXPOSE 9000 77 | USER dlaravel 78 | 79 | WORKDIR /var/www/html 80 | CMD ["php-fpm"] 81 | -------------------------------------------------------------------------------- /dockerfiles/fpm/Dockerfile_php_7.4.x: -------------------------------------------------------------------------------- 1 | FROM php:7.4.30-fpm-buster 2 | RUN apt-get update && apt-get install -y \ 3 | autoconf \ 4 | libc-dev \ 5 | pkg-config \ 6 | libmcrypt-dev \ 7 | libsnmp-dev \ 8 | libsmi2-common \ 9 | libsmi2-dev \ 10 | libperl-dev \ 11 | snmp \ 12 | ca-certificates \ 13 | curl \ 14 | xz-utils \ 15 | sudo \ 16 | cron \ 17 | inotify-tools \ 18 | git \ 19 | wget \ 20 | libmagickwand-dev \ 21 | libldap2-dev \ 22 | libsasl2-dev \ 23 | python \ 24 | vim \ 25 | unzip \ 26 | mariadb-client \ 27 | zip \ 28 | libgeoip-dev \ 29 | libpq-dev \ 30 | libzip-dev \ 31 | libbz2-dev \ 32 | libxml2-dev \ 33 | apt-utils \ 34 | supervisor \ 35 | libfreetype6-dev \ 36 | libjpeg62-turbo-dev \ 37 | libpng-dev \ 38 | && docker-php-ext-configure gd --with-freetype --with-jpeg \ 39 | && docker-php-ext-install -j$(nproc) gd \ 40 | && docker-php-ext-install -j$(nproc) pdo_mysql mysqli pgsql pdo_pgsql gettext sockets ctype xml zip pcntl bcmath bz2 \ 41 | && docker-php-ext-install -j$(nproc) exif zip gettext sockets ctype pcntl intl 42 | 43 | #docker-php-ext-install 可安裝外掛大概如下: 44 | #bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip 45 | 46 | 47 | #RUN pecl install redis \ 48 | # pecl install xdebug \ 49 | # pecl install swoole \ 50 | # pecl install imagick \ 51 | 52 | RUN pecl install redis 53 | 54 | #建立Dlaravel的使用者 55 | RUN adduser --disabled-password --gecos "" dlaravel &&\ 56 | echo "dlaravel ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/dlaravel && \ 57 | chmod 0440 /etc/sudoers.d/dlaravel 58 | 59 | #安裝composer 60 | RUN EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig); \ 61 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \ 62 | ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');"); \ 63 | php composer-setup.php; \ 64 | php -r "unlink('composer-setup.php');"; \ 65 | mv composer.phar /usr/local/bin/composer; \ 66 | sudo -u dlaravel /usr/local/bin/composer global require "laravel/installer"; \ 67 | sudo -u dlaravel /usr/local/bin/composer global require "phpunit/phpunit=5.5.*"; \ 68 | sudo -u dlaravel echo 'export TERM=xterm-256color' >> /home/dlaravel/.bashrc; \ 69 | sudo -u dlaravel echo 'export PATH=vendor/bin:/home/dlaravel/.composer/vendor/bin:$PATH' >> /home/dlaravel/.bashrc; \ 70 | echo 'export TERM=xterm-256color' >> /root/.bashrc; \ 71 | echo 'export PATH=/root/.composer/vendor/bin:$PATH' >> /root/.bashrc; 72 | 73 | #修正權限 74 | RUN mkdir -p /home/dlaravel/.composer/.cache&&chown dlaravel -R /home/dlaravel 75 | 76 | EXPOSE 9000 77 | USER dlaravel 78 | 79 | WORKDIR /var/www/html 80 | CMD ["php-fpm"] 81 | -------------------------------------------------------------------------------- /dockerfiles/fpm/Dockerfile_php_7.0.x: -------------------------------------------------------------------------------- 1 | FROM php:7.0.33-fpm 2 | #Docker官方說明文件 3 | #https://hub.docker.com/_/php/ 4 | RUN apt-get update && apt-get install -y \ 5 | libfreetype6-dev \ 6 | libjpeg62-turbo-dev \ 7 | #====安裝mcrypt==== 8 | autoconf \ 9 | libc-dev \ 10 | pkg-config \ 11 | libmcrypt-dev \ 12 | #================== 13 | libsnmp-dev \ 14 | libsmi2-common \ 15 | libsmi2-dev \ 16 | libperl-dev \ 17 | snmp \ 18 | libpng-dev \ 19 | ca-certificates \ 20 | curl \ 21 | xz-utils \ 22 | sudo \ 23 | cron \ 24 | inotify-tools \ 25 | git \ 26 | wget \ 27 | libmagickwand-dev \ 28 | libldb-dev \ 29 | libldap2-dev \ 30 | libsasl2-dev \ 31 | python \ 32 | vim \ 33 | unzip \ 34 | mysql-client \ 35 | zip \ 36 | libgeoip-dev \ 37 | libpq-dev \ 38 | libzip-dev \ 39 | libbz2-dev \ 40 | libgd2-dev \ 41 | libjpeg-dev \ 42 | libgif-dev \ 43 | libxml2-dev \ 44 | apt-utils \ 45 | supervisor \ 46 | wget \ 47 | && docker-php-ext-install -j$(nproc) pdo_mysql mysqli pgsql pdo_pgsql bcmath\ 48 | && docker-php-ext-install -j$(nproc) exif hash gettext sockets ctype xml zip pcntl intl\ 49 | && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ 50 | && docker-php-ext-install -j$(nproc) gd 51 | 52 | #docker-php-ext-install 可安裝外掛大概如下: 53 | #bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip 54 | 55 | RUN pecl install redis \ 56 | pecl install imagick \ 57 | pecl install swoole 58 | 59 | #建立Dlaravel的使用者 60 | RUN adduser --disabled-password --gecos "" dlaravel &&\ 61 | echo "dlaravel ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/dlaravel && \ 62 | chmod 0440 /etc/sudoers.d/dlaravel 63 | 64 | #安裝composer 65 | RUN EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig); \ 66 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \ 67 | ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');"); \ 68 | php composer-setup.php; \ 69 | php -r "unlink('composer-setup.php');"; \ 70 | mv composer.phar /usr/local/bin/composer; \ 71 | #加入dlaravel使用者 72 | sudo -u dlaravel /usr/local/bin/composer global require "laravel/installer"; \ 73 | sudo -u dlaravel /usr/local/bin/composer global require "phpunit/phpunit=5.5.*"; \ 74 | sudo -u dlaravel echo 'export TERM=xterm-256color' >> /home/dlaravel/.bashrc; \ 75 | sudo -u dlaravel echo 'export PATH=vendor/bin:/home/dlaravel/.composer/vendor/bin:$PATH' >> /home/dlaravel/.bashrc; \ 76 | #加入composer環境變數 77 | echo 'export TERM=xterm-256color' >> /root/.bashrc; \ 78 | echo 'export PATH=/root/.composer/vendor/bin:$PATH' >> /root/.bashrc; 79 | 80 | EXPOSE 9000 81 | USER dlaravel 82 | CMD ["php-fpm"] 83 | -------------------------------------------------------------------------------- /dockerfiles/fpm/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM --platform=$BUILDPLATFORM php:8.1.11-fpm-buster AS build 2 | ARG TARGETPLATFORM 3 | ARG BUILDPLATFORM 4 | RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" > /log 5 | 6 | FROM php:8.1.11-fpm-buster 7 | #Docker官方說明文件 8 | RUN apt-get update && apt-get install -y \ 9 | autoconf \ 10 | libc-dev \ 11 | pkg-config \ 12 | libmcrypt-dev \ 13 | libsnmp-dev \ 14 | libsmi2-common \ 15 | libsmi2-dev \ 16 | libperl-dev \ 17 | snmp \ 18 | ca-certificates \ 19 | curl \ 20 | xz-utils \ 21 | sudo \ 22 | cron \ 23 | inotify-tools \ 24 | git \ 25 | wget \ 26 | libmagickwand-dev \ 27 | libldap2-dev \ 28 | libsasl2-dev \ 29 | python \ 30 | vim \ 31 | unzip \ 32 | mariadb-client \ 33 | zip \ 34 | libgeoip-dev \ 35 | libpq-dev \ 36 | libzip-dev \ 37 | libbz2-dev \ 38 | libxml2-dev \ 39 | apt-utils \ 40 | supervisor \ 41 | libfreetype6-dev \ 42 | libjpeg62-turbo-dev \ 43 | libpng-dev \ 44 | && docker-php-ext-configure gd --with-freetype --with-jpeg \ 45 | && docker-php-ext-install -j$(nproc) gd \ 46 | && docker-php-ext-install -j$(nproc) pdo_mysql mysqli pgsql pdo_pgsql gettext sockets ctype xml zip pcntl bcmath bz2 \ 47 | && docker-php-ext-install -j$(nproc) exif zip gettext sockets ctype pcntl intl 48 | 49 | #docker-php-ext-install 可安裝外掛大概如下: 50 | #bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip 51 | 52 | #RUN pecl install redis \ 53 | # pecl install imagick \ 54 | # pecl install swoole 55 | 56 | RUN pecl install redis 57 | 58 | #建立Dlaravel的使用者 59 | RUN adduser --disabled-password --gecos "" dlaravel &&\ 60 | echo "dlaravel ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/dlaravel && \ 61 | chmod 0440 /etc/sudoers.d/dlaravel 62 | 63 | #安裝composer 64 | RUN EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig); \ 65 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \ 66 | ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');"); \ 67 | php composer-setup.php; \ 68 | php -r "unlink('composer-setup.php');"; \ 69 | mv composer.phar /usr/local/bin/composer; \ 70 | sudo -u dlaravel /usr/local/bin/composer global require "laravel/installer"; \ 71 | sudo -u dlaravel /usr/local/bin/composer global require "phpunit/phpunit"; \ 72 | sudo -u dlaravel echo 'export TERM=xterm-256color' >> /home/dlaravel/.bashrc; \ 73 | sudo -u dlaravel echo 'export PATH=vendor/bin:/home/dlaravel/.composer/vendor/bin:$PATH' >> /home/dlaravel/.bashrc; \ 74 | echo 'export TERM=xterm-256color' >> /root/.bashrc; \ 75 | echo 'export PATH=/root/.composer/vendor/bin:$PATH' >> /root/.bashrc; 76 | 77 | EXPOSE 9000 78 | USER dlaravel 79 | 80 | WORKDIR /var/www/html 81 | CMD ["php-fpm"] 82 | -------------------------------------------------------------------------------- /dockerfiles/fpm/Dockerfile_php_7.3.x: -------------------------------------------------------------------------------- 1 | FROM php:7.3.33-fpm 2 | #Docker官方說明文件 3 | #https://hub.docker.com/_/php/ 4 | RUN apt-get update && apt-get install -y \ 5 | libfreetype6-dev \ 6 | libjpeg62-turbo-dev \ 7 | #====安裝mcrypt==== 8 | autoconf \ 9 | libc-dev \ 10 | pkg-config \ 11 | libmcrypt-dev \ 12 | #================== 13 | libsnmp-dev \ 14 | libsmi2-common \ 15 | libsmi2-dev \ 16 | libperl-dev \ 17 | snmp \ 18 | libpng-dev \ 19 | ca-certificates \ 20 | curl \ 21 | xz-utils \ 22 | sudo \ 23 | cron \ 24 | inotify-tools \ 25 | git \ 26 | wget \ 27 | libmagickwand-dev \ 28 | libldb-dev \ 29 | libldap2-dev \ 30 | libsasl2-dev \ 31 | python \ 32 | vim \ 33 | unzip \ 34 | mariadb-client \ 35 | zip \ 36 | libgeoip-dev \ 37 | libpq-dev \ 38 | libzip-dev \ 39 | libbz2-dev \ 40 | libgd-dev \ 41 | libjpeg-dev \ 42 | libgif-dev \ 43 | libxml2-dev \ 44 | apt-utils \ 45 | supervisor \ 46 | wget \ 47 | && docker-php-ext-install -j$(nproc) pdo_mysql mysqli ldap pgsql pdo_pgsql snmp\ 48 | && docker-php-ext-install -j$(nproc) exif hash gettext sockets ctype xml zip pcntl bcmath intl\ 49 | && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ 50 | && docker-php-ext-install -j$(nproc) gd 51 | 52 | #docker-php-ext-install 可安裝外掛大概如下: 53 | #bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip 54 | 55 | #RUN pecl install xdebug \ 56 | # pecl install redis \ 57 | # pecl install imagick \ 58 | # && docker-php-ext-enable xdebug 59 | 60 | RUN pecl install redis 61 | 62 | #建立Dlaravel的使用者 63 | RUN adduser --disabled-password --gecos "" dlaravel &&\ 64 | echo "dlaravel ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/dlaravel && \ 65 | chmod 0440 /etc/sudoers.d/dlaravel 66 | 67 | #安裝composer 68 | RUN EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig); \ 69 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \ 70 | ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');"); \ 71 | php composer-setup.php; \ 72 | php -r "unlink('composer-setup.php');"; \ 73 | mv composer.phar /usr/local/bin/composer; \ 74 | #加入dlaravel使用者 75 | sudo -u dlaravel /usr/local/bin/composer global require "laravel/installer"; \ 76 | sudo -u dlaravel /usr/local/bin/composer global require "phpunit/phpunit=5.5.*"; \ 77 | sudo -u dlaravel echo 'export TERM=xterm-256color' >> /home/dlaravel/.bashrc; \ 78 | sudo -u dlaravel echo 'export PATH=vendor/bin:/home/dlaravel/.composer/vendor/bin:$PATH' >> /home/dlaravel/.bashrc; \ 79 | #加入composer環境變數 80 | echo 'export TERM=xterm-256color' >> /root/.bashrc; \ 81 | echo 'export PATH=/root/.composer/vendor/bin:$PATH' >> /root/.bashrc; 82 | 83 | EXPOSE 9000 84 | USER dlaravel 85 | CMD ["php-fpm"] 86 | -------------------------------------------------------------------------------- /scripts/web-ports: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | scripts_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | base_path=`echo ${scripts_path}|sed 's#/scripts##'` 4 | source ${base_path}/scripts/functions 5 | chk_project_mode 6 | source ${base_path}/scripts/checker 7 | 8 | chk_project_mode 9 | if [ ${?} -eq 0 ]; then 10 | docker-compose -p ${project_name} -f ${scripts_path}/../docker-compose.yml ps web|tail -n1|grep -q -e Up -e running 11 | if [ ${?} -eq 1 ]; then 12 | echo "No service of web." 13 | exit; 14 | fi 15 | web=`docker-compose -p ${project_name} -f ${scripts_path}/../docker-compose.yml ps web|tail -n1|cut -d' ' -f1` 16 | 17 | else 18 | docker-compose -f ${scripts_path}/../docker-compose.yml ps web|tail -n1|grep -q -e Up -e running 19 | if [ ${?} -eq 1 ]; then 20 | exit; 21 | else 22 | web=`docker-compose -f ${scripts_path}/../docker-compose.yml ps web|tail -n1|awk '{print $1}'` 23 | fi 24 | fi 25 | 26 | if [ $? -eq 1 ]; then 27 | echo ${web} is not running 28 | exit $? 29 | fi 30 | 31 | 32 | if [[ ${web} != "" ]]; then 33 | web_port=`${win_pty} docker inspect --format='{{(index (index .NetworkSettings.Ports "80/tcp") 0).HostPort}}' ${web}` 34 | fi 35 | 36 | if [ $? -eq 1 ]; then 37 | echo ${web} is not running 38 | exit $? 39 | fi 40 | 41 | chk_project_mode 42 | if [ $? -eq 0 ]; then 43 | if [[ ${web_port} == 80 ]]; then 44 | echo "http://localhost" 45 | else 46 | echo "http://localhost:${web_port}" 47 | fi 48 | exit 0 49 | fi 50 | 51 | #查看sites內的資料夾數量 52 | projectNum=`ls ${base_path}/sites/|wc -l` 53 | #印出sites資料夾目錄,轉換為Web 54 | if [ ${projectNum} -gt 0 ]; then 55 | #for Mac 56 | is_enable_default=0 57 | if [[ ${hosts_file} == '/etc/hosts' ]]; then 58 | for i in $(ls -d ${base_path}/sites/*|rev|cut -d/ -f1|rev); do 59 | if [[ ${i} == 'xdebug.log' ]]; then 60 | continue 61 | fi 62 | if [[ ${web_port} == 80 ]]; then 63 | if [ ${i} != "default" ]; then 64 | if [ -f ${base_path}/etc/default-ssl.conf ]; then 65 | echo -n https://;echo ${i}.test|cut -d/ -f 2; 66 | else 67 | echo -n http://;echo ${i}.test|cut -d/ -f 2; 68 | fi 69 | else 70 | is_enable_default=1 71 | fi 72 | else 73 | if [[ ${i} != "default" ]]; then 74 | if [ -f ${base_path}/etc/default-ssl.conf ]; then 75 | webs_port=`${win_pty} docker inspect --format='{{(index (index .NetworkSettings.Ports "443/tcp") 0).HostPort}}' ${web}` 76 | echo -n https://;echo ${i}.test:${webs_port}|cut -d/ -f 2; 77 | else 78 | echo -n http://;echo ${i}.test:${web_port}|cut -d/ -f 2; 79 | fi 80 | else 81 | is_enable_default=1 82 | fi 83 | fi 84 | done 85 | if [ ${is_enable_default} -eq 1 ]; then 86 | if [ ${web_port} -eq "80" ]; then 87 | echo -e "\nDefault folder exist.\nhttp://localhost or http://your_ip_address" 88 | else 89 | echo -e "\nDefault folder exist.\nhttp://localhost:${web_port} or http://your_ip_address:${web_port}" 90 | fi 91 | fi 92 | else 93 | echo "*.test, port:" ${web_port} 94 | ls -l sites/|cut -d ' ' -f 9 95 | fi 96 | fi 97 | 98 | if [ ${projectNum} -eq 0 ]; then 99 | echo "No Projects are found, you can create one by following command." 100 | echo "For example as below:" 101 | echo "./create [project name]" 102 | fi 103 | #echo " http://0.0.0.0:${web_port}" 104 | 105 | -------------------------------------------------------------------------------- /README-zh_TW.md: -------------------------------------------------------------------------------- 1 | 2 | **[English Documentation](https://github.com/DevinY/dlaravel/blob/master/README.md)** 3 | 4 | ## 此倉庫目前主要僅維護Dockerfile的更新,建議使用我最新的php環境bash。 5 | 6 | 採連接埠基礎的環境,更容易與proxy整合及運用,更多功能。 7 | 8 | https://github.com/DevinY/phpenv 9 | 10 | # D-Laravel (開發&學習) 11 | 12 | 想要有 Docker + Laravel 建立PHP開發環境嗎,D-Laravel使用了docker-compose, 13 | 14 | 他讓我們可透過自訂docker-compose-custom.yml輕易的擴充更多的服務,打造自己的微服務架構。 15 | 16 | 經由超簡易的console及create指令,讓您更簡單的建立出Laravel或PHP開發或學習環境。 17 | 18 | D-Laravel,代表了,我們的Mac系統,不再需要安裝mysql、nginx、php-fpm或者NodeJs。 19 | 20 | 21 | ### 為什麼用D-Laravel 22 | 23 | 提供簡易方式執行docker-compose指令,快速生成laravel專案環境,而且還自動替您建立資料庫及調整Laravel的.env資料庫設定。 24 | 25 | 可安裝sublime3外掛D-Laravel alias,經由sublime執行容器內的artisan及composer命令(MacOS及Linux環境)。 26 | 27 | 可用最新的PHP在Mac OS、Linux、Widnows 10的gitbash環境執行。 28 | 29 | 快速產生self-signed自我簽署的憑證,並完成HTTPS設定。 30 | 31 | 不需要安裝DnsMasq軟體。 32 | 33 | D-laravel停止時,不會佔用80埠,拜docker-compose之賜,極易調整Listen的連接埠。 34 | 35 | 秒級的啟動速度。 36 | 37 | 可模擬不同的資料庫環境。 38 | 39 | 可同時開啟多個不同的測試站台。 40 | 41 | 使用Dockerhub標註offical的image,建立Laravel基本執行環境。 42 | 43 | 用docker聽起來,好像比較潮。:p 44 | 45 | ./console help (幫助,console參數用法。) 46 | ./create test1 (建立test1.test) 47 | ./console down或./console up (啟用及停用container) 48 | ./console restart (./console down再./console up) 49 | `./console alias` 50 | (打./console指令太長了嗎,上方指令可暫時用c代表./console,所以執行後,輸入:c info、c up或c down..即可執行。) 51 | ./console alias (印出console的別名範本,自行加到.bashrc或.zshrc永久生效) 52 | ./console version (顯示D-Laravel的版本) 53 | 54 | 產生自我簽署憑證給目前所有的Project. (MacOS or Linux)。 55 | ./console secure 56 | 57 | 58 | #### D-Laravel易懂目錄結構 59 | 60 | etc/ (nginx、php.ini及mysql的相關設定檔) 61 | data/ (mysql的資料檔案,./console up 自動生成) 62 | dockerfiles/ (放置一些dockerfile,需要時重build自已的image使用) 63 | logs/ (用來掛載及放置服務的紀錄) 64 | service/ (放置擴充用的yml檔) 65 | sites/ (專案的資夾,例如./create blog時,會建立在這個此目錄下) 66 | samples/ (一些設定範本,例如: php.ini及一些額外的docker-compose yaml檔設定) 67 | create (簡化的bash,用來快速的建立laravel的專案) 68 | console(簡化的bash,用來快速使用各種docker-compose的命令。例如:./console mysql即可進入mysql) 69 | docker-compose.yml (一個softlink,連結到不同的設定檔,例如:./console custom,即何將連結連到docker-compose-custom.yml) 70 | 71 | #### docker及docker-compose 版本要求 72 | 73 | docker >= 18.02.0 74 | 75 | docker-compose >= 1.19.0 76 | 77 | #### 一、請先安裝docker 78 | ## 請使用最新版本的docker,至少應為18.02.0以上。 79 | 80 | 執行docker version確認docker的版本。 81 | 82 | $docker version 83 | Client: 84 | Version: 18.06.0-ce 85 | API version: 1.38 86 | Go version: go1.10.3 87 | Git commit: 0ffa825 88 | Built: Wed Jul 18 19:05:26 2018 89 | OS/Arch: darwin/amd64 90 | Experimental: false 91 | 92 | Server: 93 | Engine: 94 | Version: 18.06.0-ce 95 | API version: 1.38 (minimum version 1.12) 96 | Go version: go1.10.3 97 | Git commit: 0ffa825 98 | Built: Wed Jul 18 19:13:46 2018 99 | OS/Arch: linux/amd64 100 | Experimental: true 101 | 102 | ## 安裝docker的網址: 103 | 104 | Mac OS系統: 105 | https://docs.docker.com/docker-for-mac/ 106 | 107 | Ubuntu: 108 | https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#install-docker-ce 109 | 110 | Windows 10: 111 | https://docs.docker.com/docker-for-windows/install/ 112 | gitbash環境 (console及create需在gitbash環境執行,並且gitbash需可正確執行laravel installer!!) 113 | 114 | 115 | 116 | ## 請確認您使用新版的docker-compose。 117 | 118 | 執行docker-compose version 119 | 120 | 大於等於 121 | 122 | docker-compose version 1.19.0 123 | 124 | ## 安裝docker-compose網址 125 | 126 | https://docs.docker.com/compose/install/ 127 | 128 | 129 | #### 二、例如:可用git clone下載這個repo,並進入dlaravel工作目錄。 130 | 131 | git clone https://github.com/DevinY/dlaravel.git 132 | cd dlaravel 133 | 134 | 135 | #### 三、執行./create ['project name'] 建立開發專案 136 | 137 | 例如: (第一次執行會自動下載所需的Image,需較長的時間) 138 | ./create test1 139 | 140 | 那麼就會建立出 http://test1.test 網站(本機測試用的外部無法存取)。 141 | 可以建立多個project站台 142 | 143 | 由於create的bash需有系統權修改/etc/hosts檔,./create的過程中會需要詢問您的系統密碼: 144 | create指令、可在Mac OS、Linux及Windows 10的gitbash(Laravel installer)環境使用。 145 | 146 | 147 | 148 | #### 四、停止請在目錄下執行./console down 149 | 150 | 注意事項: 這個只是拿來開發測試用的,Mysql的root是沒有密碼的。 151 | 你可能需要修改docker-compose.yml啟動時的TZ,目前設為Asia/Taipei 152 | 153 | 154 | #### 五、更新d-laravel bash程式及一些基本設定檔。 155 | 156 | git pull 157 | 158 | 在d-laravel的.gitignore已排除了會變動的區域了,例如: docker-compose.yml、docker-compse-custom.yml, sites專案資料夾等。 159 | 所以在dlaravel的目錄下,您可以透過git pull取得最新的版本及設定。 160 | 161 | 162 | #### 六、別名及功能(不需進入container即可執行container內的composer或artisan指令) 163 | 164 | 取得console別名 165 | 166 | ./console alias 167 | 168 | 把輸出結果,新增到~/.bash_profile,或是如果您用Z shell,新增到~/.zshrc檔案內。 169 | 在MacOs的系統預設不會有.bash_profile在家目錄中,你可以在終端機自己touch一個。 170 | 輸入: touch ~/.bash_profile 171 | 172 | 非必要項,自己有需要可新增或調整名稱。 173 | 174 | alias laravel='docker-compose exec -u dlaravel php /home/dlaravel/.composer/vendor/bin/laravel' 175 | 176 | 使用dlaravel的身份執行container內的laravel installer 177 | 178 | 在Project內執行composer,例如ce dump 179 | 180 | alias ce="../../composer.sh" 181 | 182 | 183 | 我們可以在自己的電腦加入別名,這樣就可不需進入container內執行php artisan指令了. 184 | 讓artisan的指令更簡潔,這理我直接將別名命名為a。 185 | 例如: a --version 186 | 187 | alias a="../../artisan.sh" 188 | 189 | 190 | 191 | 192 | alias phpunit='docker-compose -f ../../docker-compose.yml exec -u dlaravel php $(basename ${PWD})/vendor/bin/phpunit -c $(basename ${PWD})/phpunit.xml' 193 | 194 | 加入這個alias可以執行簡phpunit。 195 | #### 其他 196 | 197 | ./create [project名稱] 會建立及下載laravel,搞定一切設定,包含資料庫, 198 | 但如果是一個已存在的Project,只需有nginx的設定,應該怎麼做呢? 199 | 200 | 使用--host 即可修改系統的/etc/hosts檔,加入project的域名,如: project1.test。 201 | ./create --host [project名稱] 例如:./create --host project1 202 | 203 | 可以將已存在的Laravel專案移到sites資料夾內。 204 | 205 | 或是使用composer create-project指令建立Project. 206 | 例如使用手動指令手動建立Project,這裡用lumen示範。 207 | ./console exec,可用於執行php contaiener內的命令 208 | 209 | ./console exec php composer create-project --prefer-dist laravel/lumen project1 210 | 211 | #### 調整設定檔的image切換 212 | PHP: (OFFICIAL REPOSITORY重build符合Laravel環境) 213 | https://hub.docker.com/r/deviny/fpm/tags/ 214 | 215 | mage: deviny/fpm:7.3.5 216 | image: deviny/fpm:7.2.18 217 | image: deviny/fpm:7.1.29 218 | image: deviny/fpm:5.6.39 219 | 220 | 221 | Nginx: (OFFICIAL REPOSITORY) 222 | https://hub.docker.com/r/library/nginx/ 223 | 224 | Mysql: (OFFICIAL REPOSITORY) 225 | https://hub.docker.com/_/mysql/ 226 | 227 | 註: 原data資料夾已產生時,變更不同的mysql版本,在docker-compose.yml的設定檔內, 228 | 你需可能需調整資料庫夾data的名稱,確保新版的mysql image能正常運作。 229 | 例如:我將data設更為data_mysql8 230 | 231 | 232 | db: 233 | image: mysql:8 234 | 略.. 235 | volumes: 236 | - ./etc/mysql/my.cnf:/etc/mysql/my.cnf 237 | - ./data_mysql8:/var/lib/mysql 238 | 239 | 240 | #### 進階 241 | 如果您想重build自己php的fpm image版本。 242 | 例如下方建立了一個名為myfpm的image。 243 | 244 | cd dockerfiles/fpm/7.2 245 | docker build -t myfpm . 246 | 247 | 248 | And then edit Your docker-compose.yml file. 249 | 然後,編輯docker-compose.yml檔,如下: 250 | 251 | php: 252 | network_mode: "service:web" 253 | image: myfpm 254 | 255 | 256 | Docker指令及DevinY/dlaravel提供的./console的bash指令 257 | 258 | |Docker官方指令 |簡易./console Bash指令| 說明| 259 | |---|---|---| 260 | | docker-compose pull |./console pull |抓最新的images | 261 | | docker-compose up -d |./console up |啟動container | 262 | | docker-compose down |./console down |停止container | 263 | | docker-compose ps或docker ps|./console ps |查看docker-compose的process | 264 | | docker-compose exec -u dlaravel php bash |./console |進入php的container | 265 | | docker-compose exec php 指令 |./console exec 指令 |執行php container 指令,例如: ./console exec php -v| 266 | | docker-compose exec db mysql |./console mysql |執行mysql | 267 | | docker-compose exec web nginx -s reload |./console reload |重載nginx設定 | 268 | | docker-compose logs -f [SERVICE] |./console logs |看nginx的log,Ctrl+C停止 | 269 | | |./create [ProjectName]|建立一個project,並完成所有基本的環境設定 | 270 | | |例如: ./create test1 |例如: 這樣會建立一個http://test1.test的網站 | 271 | | |./console restart |重啟container | 272 | | |./console info |查看目前可用的sites資料(這裡是查單的查詢sites資料夾) | 273 | |模式切換:| 274 | | |./console random |container啟動時,使用隨機埠| 275 | | |./console normal |使用本機port 80及127.0.0.1:3306| 276 | | |./console custom |使用自己的docker-compose-custom.yml| 277 | |下方: -f: 指定docker-compose設定檔。 up -d:啟動在背景執行。| 278 | |docker-compose -f docker-compose-normal.yml up -d| |使用port 80及port 3306| 279 | |docker-compose -f docker-compose-random.yml up -d| |指定隨機埠的啟動檔| 280 | 281 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | **[中文說明](https://github.com/DevinY/dlaravel/blob/master/README-zh_TW.md)** 3 | 4 | ## This repostory currently only maintains the update of Dockerfile. It is recommended to use my latest php environment bash. 5 | 6 | Adopting a port-based environment, it is easier to integrate and use the proxy, and it has more functions. 7 | 8 | https://github.com/DevinY/phpenv 9 | 10 | # D-Laravel (English manual) 11 | 12 | D-Laravel uses docker-composer micro service framework, 13 | 14 | it helps you quickly to build basic Laravel development environment by using simple commands: console and create. 15 | 16 | Using D-Laravel also means no longer to install mysql, nginx and php-fpm in Mac. 17 | 18 | You can deploy the environment by self-defined docker-compose-custom.yml file. 19 | 20 | 21 | ### Why use D-Laravel 22 | 23 | It Provides easy way to execute the docker-compose command, quickly generate a laravel project environment, and automatically build a database and adjust Laravel's .env database settings for you. 24 | 25 | The sublime3 package of D-Laravel alias can be installed, and the artisan and composer commands in the container (MacOS and Linux environment) are executed via sublime. 26 | 27 | You can execute the latest PHP version in Mac OS. 28 | 29 | It helps you to generate self-signed certification and completes HTTPS setting. 30 | 31 | No need to install DnsMasq. 32 | 33 | Port 80 won't be used when not start dlaravel. 34 | 35 | Initial speed in seconds!!! 36 | 37 | It can simulate different DB environment. 38 | 39 | It also could open kinds of testing hosts. 40 | 41 | 42 | Easy docker-compose v3.6 setting. 43 | 44 | Using Dockerhub to remark official image to build basic Laravel environment. 45 | 46 | 47 | It seems fashion if use docker. :P 48 | 49 | ./console help (help, console parameter) 50 | ./create test1 (build test1.test) 51 | ./console down or ./console up (stop or start container) 52 | ./console restart (first ./console down and then ./console up) 53 | `./console alias` 54 | (If you think ./console command is too log, you could create c alias in terminal which simplifies command to "c info", "c up", or "c down") 55 | ./console alias (print console alias samples, it can be added to .bashrc or .zshrc) 56 | ./console version 57 | 58 | Generate self-signed certificate for all current projects. (MacOS and Linux) 59 | ./console secure 60 | 61 | 62 | 63 | ### Main Directory structure 64 | 65 | etc/ (nginx、php.ini and mysql settings) 66 | data/ (mysql data files, auto-generated by ./console up) 67 | dockerfiles/ (some dockerfiles) 68 | sites/ (project files, the project will be set in this folder when executes ./create test1) 69 | create (Simplified bash, to fast build laravel project) 70 | console (Simplified bash file, to use kinds of docker-compose commands. ex. login mysql by "./console mysql") 71 | docker-compose.yml (A soft link to connect different settings. ex. linking to docker-compose-custom.yml by "./console custom") 72 | 73 | 74 | 75 | #### 1. Please install docker. 76 | 77 | Mac OS: 78 | https://docs.docker.com/docker-for-mac/ 79 | 80 | Ubuntu: 81 | https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#install-docker-ce 82 | 83 | Windows 10: (required for laravel install in gitbash!!) 84 | https://docs.docker.com/docker-for-windows/install/ 85 | 86 | To run console and create bash on Windows 10: 87 | Gitbash is required. 88 | Laravel installer have to run correctly in gitbash also. 89 | 90 | 91 | 92 | #### 2. git clone D-Laravel repo and execute "./console pull" in the folder 93 | 94 | git clone https://github.com/DevinY/dlaravel.git 95 | cd dlaravel 96 | 97 | 98 | You can ignore below's pull command. It will auto download the images according to docker-compose.yml when initials. 99 | ./console pull 100 | The first time to download needed images from dockhub will take longer time. Be patient. :P 101 | 102 | 103 | 104 | #### 3. execute "./create ['project name']" to biuild new project 105 | 106 | ex. 107 | ./create test1 108 | It will build http://test1.test website (can't be accessed from outside) 109 | So you can use this command to build many different projects. 110 | 111 | You need to provide privilege to modify /etc/hosts file, so D-Laravel will ask for your systme password during executing "./create project". (Mac OS using only) 112 | 113 | 114 | 115 | #### 4. executing "./console down" in D-Laravel foldee 116 | 117 | Attention: 118 | D-Laravel is only used for development, Mysql root password is empty. 119 | You may need to revise TZ in docker-compose.yml, default is Asia/Taipei. 120 | 121 | 122 | 123 | #### 5. Updating D-Laravel bash program and some settings 124 | 125 | git pull 126 | 127 | .gitignore in D-Laravel already excludes dynamic files, ex. docker-comnpose.yml, docker-compose-custom.yml, sites folder etc. 128 | You can git pull latest version and setting in D-Laravel folder. 129 | 130 | 131 | #### 6. alias and function (without entering the container can be implemented within the container composer or artisan instructions) 132 | 133 | Get the console alias in your system. 134 | 135 | ./console alias 136 | 137 | And then add the output to your ~/.bash_profile, or ~/.zshrc if you are using Z shell. 138 | The OS X won't create .bash_profile for you. 139 | Type 'touch ~/.bash_profile' to create your new one. 140 | 141 | Execute the laravel installer in the container using the identity of dlaravel 142 | 143 | alias laravel='docker-compose exec -u dlaravel php /home/dlaravel/.composer/vendor/bin/laravel' 144 | 145 | 146 | run composer.sh in project folder, for example: ce dump 147 | 148 | alias ce="../../composer.sh" 149 | 150 | 151 | We can add aliases to our computer so that you do not have to go into the container to execute the php artisan directive. Let artisan's instructions be more concise, which I call the alias directly as a. For example: a --version 152 | 153 | alias a="../../artisan.sh" 154 | 155 | 156 | 157 | alias phpunit = 'docker-compose -f ../../docker-compose.yml exec -u dlaravel php $ (basename $ {PWD}) / vendor / bin / phpunit -c $ (basename $ {PWD}) / phpunit.xml ' 158 | 159 | Join this alias can do simple phpunit. 160 | 161 | #### Others 162 | 163 | ./create [project name] will create and build laravel, it would set all configures automatically including DB. 164 | But how do we do if project already exists and only needs nginx setting? 165 | 166 | Using "--host" to update /etc/hosts file, for example: "127.0.0.1 project1.test". 167 | ./create --host [project name] (./create --host project1) 168 | 169 | 170 | You can move exist Laravel project to D-Laravel site folder. 171 | 172 | Or manually executes "composer create-project" (not default version etc.) 173 | 174 | Ex. Create project manually by using lumen 175 | ./console exec //It can execute php command in container. 176 | 177 | ./console exec php composer create-project --prefer-dist laravel/lumen project1 178 | 179 | 180 | 181 | 182 | #### Adjust images in setting 183 | PHP: [Official repository rebuilds php to fit Laravel environment](https://hub.docker.com/r/deviny/fpm/tags/) 184 | 185 | image: deviny/fpm:7.3.5 186 | image: deviny/fpm:7.2.18 187 | image: deviny/fpm:7.1.29 188 | image: deviny/fpm:5.6.39 189 | 190 | 191 | Nginx: [OFFICIAL REPOSITORY](https://hub.docker.com/r/library/nginx/) 192 | 193 | Mysql: [OFFICIAL REPOSITORY](https://hub.docker.com/_/mysql/) 194 | 195 | Remark: 196 | When you need to revise different mysql version and that D-Laravel/data already exist, you may need to reset DB name in D-Laravel.data to ensure mysql image works normally. 197 | 198 | Ex. Rename data to data_mysql8 199 | 200 | 201 | db: 202 | image: mysql:8 203 | ... 204 | volumes: 205 | - ./etc/mysql/my.cnf:/etc/mysql/my.cnf 206 | - ./data_mysql8:/var/lib/mysql 207 | 208 | 209 | 210 | #### Advandace 211 | 212 | If you would like to rebuild your own php-fpm image. 213 | You can do as below: 214 | 215 | cd dockerfiles/fpm/7.3 216 | docker build -t myfpm . 217 | 218 | 219 | And then edit Your docker-compose.yml file. 220 | 221 | php: 222 | network_mode: "service:web" 223 | image: myfpm 224 | 225 | 226 | 227 | ### Docker commands and Devin/dlaravel "./console" bash command comparison table 228 | 229 | |Docker official commands|simplified ./console Bash commands| Describtion| 230 | |---|---|---| 231 | | docker-compose pull |./console pull |pull latest images | 232 | | docker-compose up -d |./console up |start container | 233 | | docker-compose down |./console down |stop container | 234 | | docker-compose ps or docker ps|./console ps |show docker-compose process | 235 | | docker-compose exec -u dlaravel php bash |./console |access php container | 236 | | docker-compose exec php command |./console exec command |execute php container command,ex. ./console exec php -v| 237 | | docker-compose exec db mysql |./console mysql |exectue mysql | 238 | | docker-compose exec web nginx -s reload |./console reload |reload nginx setting | 239 | | docker-compose logs -f [SERVICE] |./console logs |show nginx log,stop it with Ctrl+C | 240 | | |./create [ProjectName]|create a project with default settings | 241 | | |Ex. ./create test1 |Ex. create a http://test1.test website | 242 | | |./console restart |restart container | 243 | | |./console info |show url info | 244 | |Switch model:| 245 | | |./console random |using random port when initiate container| 246 | | |./console normal |using local port 80 and 127.0.0.1:3306| 247 | | |./console custom |using self-defined docker-compose-custom.yml| 248 | |command below: -f: specific docker-compose.yml path。 up -d:start container in background| 249 | |docker-compose -f docker-compose-normal.yml up -d| |using port 80 and port 3306| 250 | |docker-compose -f docker-compose-random.yml up -d| |specific yml file with random port| 251 | 252 | -------------------------------------------------------------------------------- /scripts/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #set -e 3 | #get the scripts path 4 | scripts_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | base_path=`echo ${scripts_path}|sed 's#/scripts##'` 6 | 7 | #check docker-compose file is readable 8 | function chk_docker_compose_file_is_readable { 9 | if [ ! -r "${base_path}/docker-compose.yml" ]; then 10 | echo "Soft link Error" 11 | echo "File ${base_path}/docker-compose.yml is not readdable!" 12 | echo "force link to ${base_path}/docker-compose-normal.yml" 13 | ln -vsf ${base_path}/docker-compose-normal.yml ${base_path}/docker-compose.yml 14 | fi 15 | } 16 | 17 | #check_which_one_to_use_when_ssl_is_enabled 18 | function replace_ssl_conf { 19 | 20 | #檢查是否啟動ssl 21 | if [ -f ${base_path}/etc/default-ssl.conf ]; then 22 | echo "Found etc/default-ssl.conf using https" 23 | chk_project_mode 24 | if [ ${?} -eq 0 ]; then 25 | cp ${base_path}/etc/project-ssl.sample ${base_path}/etc/default-ssl.conf 26 | ${winpty} docker-compose -p ${project_name} -f ${base_path}/docker-compose.yml exec web nginx -s reload 27 | else 28 | cp ${base_path}/etc/default-ssl.sample ${base_path}/etc/default-ssl.conf 29 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec web nginx -s reload 30 | fi 31 | else 32 | echo "Do no thing" 33 | 34 | fi 35 | 36 | } 37 | #array_service 38 | function array_service { 39 | array_service=(${DOCKER_SERVICES}) 40 | CONSOLE_CMD="-f ${base_path}/docker-compose.yml " 41 | for i in "${array_service[@]}" 42 | do 43 | : 44 | CONSOLE_CMD+="-f ${base_path}/service/${i}.yml " 45 | done 46 | } 47 | #dlaravel console log 48 | function console_logs { 49 | chk_docker_compose_file_is_readable 50 | if [ -z "${DOCKER_SERVICES}" ]; then 51 | echo "${winpty} docker-compose -f ${base_path}/docker-compose.yml ${@}" 52 | 53 | chk_project_mode 54 | 55 | if [ ${?} -eq 0 ]; then 56 | ${winpty} docker-compose -p ${project_name} -f ${base_path}/docker-compose.yml ${@} 57 | else 58 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml ${@} 59 | fi 60 | 61 | else 62 | array_service 63 | echo "${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} ${@}" 64 | ${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} ${@} 65 | fi 66 | } 67 | #display logs when error 68 | function fail_exit { 69 | if [ $? -eq 1 ]; then 70 | console_logs logs ${@} 71 | exit; 72 | fi 73 | } 74 | 75 | #spcify service restart 76 | function console_restart { 77 | chk_docker_compose_file_is_readable 78 | if [ -z "${DOCKER_SERVICES}" ]; then 79 | chk_project_mode 80 | if [ $? -eq 0 ]; then 81 | ${winpty} docker-compose -p ${project_name} -f ${base_path}/docker-compose.yml ${@} 82 | else 83 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml ${@} 84 | fi 85 | else 86 | chk_project_mode 87 | if [ $? -eq 0 ]; then 88 | array_service 89 | ${winpty} docker-compose -p ${project_name} -p $(basename ${base_path}) ${CONSOLE_CMD} ${@} 90 | else 91 | array_service 92 | ${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} ${@} 93 | fi 94 | 95 | fi 96 | } 97 | 98 | #specify service up 99 | function console_up_service { 100 | chk_docker_compose_file_is_readable 101 | if [ -z "${DOCKER_SERVICES}" ]; then 102 | echo "${winpty} docker-compose -f ${base_path}/docker-compose.yml up -d ${@}" 103 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml up -d ${@} 104 | else 105 | array_service 106 | echo "${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} up -d ${@}" 107 | ${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} up -d ${@} 108 | fi 109 | 110 | } 111 | 112 | #display soft link 113 | function console_link { 114 | link=$(ls -l ${base_path}/docker-compose.yml) 115 | target_link=$(echo ${link}|cut -d" " -f 11) 116 | if [ ! -z ${target_link} ]; then 117 | echo "Currently docker-compose.yml is soft link to ${target_link}" 118 | fi 119 | } 120 | 121 | #dlaravel console exec 122 | function console_exec { 123 | chk_docker_compose_file_is_readable 124 | if [ -z "${DOCKER_SERVICES}" ]; then 125 | echo "${winpty} docker-compose -f ${base_path}/docker-compose.yml ${@}" 126 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml ${@} 127 | else 128 | array_service 129 | echo "${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} ${@}" 130 | ${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} ${@} 131 | fi 132 | } 133 | function check_swoole { 134 | cat ${base_path}/etc/default.conf|grep -q laravels 135 | #發現laravels 136 | if [ ${?} -eq 0 ]; then 137 | echo -e "\nSwoole is enabled." 138 | echo "Default folder exist. (sites/default)" 139 | echo "http://localhost or http://your_ip_address" 140 | exit; 141 | fi 142 | } 143 | function chk_default_conf_exist { 144 | #檢測預設的設定檔是否存在 145 | if [ ! -f "${base_path}/etc/default.conf" ]; then 146 | cp ${base_path}/etc/default.sample ${base_path}/etc/default.conf 147 | fi 148 | } 149 | 150 | #is_project_mode 151 | function chk_project_mode { 152 | project_name=$(dirname ${base_path}|/usr/bin/awk -F/ '{print $NF}') 153 | project_name=`echo ${project_name}|awk '{print tolower($0)}'` 154 | grep -q dlaravel_project_mode ${base_path}/sites/${project_name} >/dev/null 2>&1 155 | #ls -R ${base_path}/sites/${project_name} 1> /dev/null 2>/dev/null 156 | } 157 | 158 | #dlarave console up 159 | function console_up { 160 | chk_default_conf_exist 161 | if [ ! -f "${base_path}/docker-compose.yml" ]; then 162 | echo ${base_path} 163 | #create soft link if no exists. 164 | ln -s ${base_path}/docker-compose-random.yml ${base_path}/docker-compose.yml 165 | fi 166 | console_link 167 | if [ -z "${DOCKER_SERVICES}" ]; then 168 | echo "${winpty} docker-compose -f ${base_path}/docker-compose.yml up -d --remove-orphans" 169 | 170 | chk_project_mode 171 | if [ ${?} -eq 0 ]; then 172 | ${winpty} docker-compose -p ${project_name} -f ${base_path}/docker-compose.yml up -d --remove-orphans 173 | else 174 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml up -d --remove-orphans 175 | fi 176 | else 177 | array_service 178 | echo "${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} up -d --remove-orphans" 179 | ${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} up -d --remove-orphans 180 | fi 181 | replace_ssl_conf 182 | 183 | #暫時保留 184 | #${winpty} docker-compose exec web /bin/bash -c 'cd /etc/;ln -sf /usr/share/zoneinfo/Asia/Taipei localtime;dpkg-reconfigure -f noninteractive tzdata' 185 | check_swoole 186 | fail_exit ${base_path} 187 | echo "DB:" 188 | #設定DB的時區到Asia/Taipei 189 | ${base_path}/scripts/db-ports 190 | echo "Web:" 191 | ${base_path}/scripts/web-ports 192 | } 193 | #dlarave console pull 194 | function console_pull { 195 | if [ ! -f "${base_path}/docker-compose.yml" ]; then 196 | echo ${base_path} 197 | #檔案不存在,進行預設的soft link 198 | ln -s ${base_path}/docker-compose-random.yml ${base_path}/docker-compose.yml 199 | fi 200 | console_link 201 | if [ -z "${DOCKER_SERVICES}" ]; then 202 | echo "${winpty} docker-compose -f ${base_path}/docker-compose.yml pull" 203 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml pull 204 | else 205 | array_service 206 | echo "${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} pull" 207 | ${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} pull 208 | fi 209 | } 210 | 211 | #dlaravel console down 212 | function console_down { 213 | chk_docker_compose_file_is_readable 214 | if [ -z "${DOCKER_SERVICES}" ]; then 215 | if [ -e ${base_path}/docker-compose.yml ]; then 216 | echo "${winpty} docker-compose -f ${base_path}/docker-compose.yml down --remove-orphans" 217 | 218 | chk_project_mode 219 | 220 | if [ ${?} -eq 0 ]; then 221 | ${winpty} docker-compose -p ${project_name} -f ${base_path}/docker-compose.yml down --remove-orphans 222 | else 223 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml down --remove-orphans 224 | fi 225 | 226 | else 227 | echo "${winpty} docker-compose -f ${base_path}/docker-compose-random.yml down --remove-orphans" 228 | ${winpty} docker-compose -f ${base_path}/docker-compose-random.yml down --remove-orphans 229 | fi 230 | else 231 | array_service 232 | echo "docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} down --remove-orphans" 233 | docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} down --remove-orphans 234 | fi 235 | } 236 | #dlaravel console down 237 | function console_down_silent { 238 | chk_docker_compose_file_is_readable 239 | if [ -z "${DOCKER_SERVICES}" ]; then 240 | if [ -e ${base_path}/docker-compose.yml ]; then 241 | 242 | echo "docker-compose -f ${base_path}/docker-compose.yml down --remove-orphans" 243 | chk_project_mode 244 | if [ ${?} -eq 0 ]; then 245 | docker-compose -p ${project_name} -f ${base_path}/docker-compose.yml down --remove-orphans > /dev/null 2>&1 246 | rm ${base_path}/sites/${project_name} 247 | else 248 | docker-compose -f ${base_path}/docker-compose.yml down --remove-orphans > /dev/null 2>&1 249 | fi 250 | 251 | else 252 | echo "docker-compose -f ${base_path}/docker-compose-random.yml down --remove-orphans" 253 | docker-compose -f ${base_path}/docker-compose-random.yml down --remove-orphans > /dev/null 2>&1 254 | fi 255 | else 256 | array_service 257 | echo "docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} down --remove-orphans" 258 | docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} down --remove-orphans > /dev/null 2>&1 259 | fi 260 | } 261 | #dlaravel console ps 262 | function console_ps { 263 | chk_project_mode 264 | if [ ${?} -eq 0 ]; then 265 | echo "Dlaravel is running in per project mode." 266 | fi 267 | chk_docker_compose_file_is_readable 268 | if [ -f "${base_path}/.docker-compose.yml" ]; then 269 | echo "Can't find ${base_path}/docker-compose.yml" 270 | fi 271 | 272 | if [ -z "${DOCKER_SERVICES}" ]; then 273 | echo "${winpty} docker-compose -f ${base_path}/docker-compose.yml ps" 274 | 275 | chk_project_mode 276 | 277 | if [ ${?} -eq 0 ]; then 278 | ${winpty} docker-compose -p ${project_name} -f ${base_path}/docker-compose.yml ps 279 | else 280 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml ps 281 | fi 282 | else 283 | array_service 284 | echo "${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} ps" 285 | ${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} ps 286 | fi 287 | 288 | } 289 | #dlaravel console_top 290 | function console_top { 291 | chk_docker_compose_file_is_readable 292 | if [ -f "${base_path}/.docker-compose.yml" ]; then 293 | echo "Can't find ${base_path}/docker-compose.yml" 294 | fi 295 | 296 | if [ -z "${DOCKER_SERVICES}" ]; then 297 | echo "${winpty} docker-compose -f ${base_path}/docker-compose.yml top" 298 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml top 299 | else 300 | array_service 301 | echo "${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} top" 302 | ${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} top 303 | fi 304 | 305 | } 306 | 307 | #specify service top 308 | function console_top_service { 309 | chk_docker_compose_file_is_readable 310 | if [ -z "${DOCKER_SERVICES}" ]; then 311 | echo "${winpty} docker-compose -f ${base_path}/docker-compose.yml top ${@}" 312 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml top ${@} 313 | else 314 | array_service 315 | echo "${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} top ${@}" 316 | ${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} top ${@} 317 | fi 318 | } 319 | 320 | #dlaravel console kill 321 | function console_kill { 322 | if [ -z "${DOCKER_SERVICES}" ]; then 323 | echo "${winpty} docker-compose -f ${base_path}/docker-compose.yml down" 324 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml down > /dev/null 2>&1 325 | else 326 | array_service 327 | echo "${winpty} docker-compose kill $(${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} ps -q)" 328 | ${winpty} docker-compose kill $(${winpty} docker-compose -p $(basename ${base_path}) ${CONSOLE_CMD} ps -q) > /dev/null 2>&1 329 | fi 330 | 331 | } 332 | -------------------------------------------------------------------------------- /create: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source ./scripts/checker 3 | source ${base_path}/scripts/functions 4 | chk_project_mode 5 | if [ ${?} -eq 0 ]; then 6 | web=`docker-compose -p ${project_name} -f ${base_path}/docker-compose.yml ps web|awk '{print $1}'|tail -n1` 7 | php=`docker-compose -p ${project_name} -f ${base_path}/docker-compose.yml ps php|awk '{print $1}'|tail -n1` 8 | db=`docker-compose -p ${project_name} -f ${base_path}/docker-compose.yml ps db|awk '{print $1}'|tail -n1` 9 | else 10 | web=`docker-compose -f ${base_path}/docker-compose.yml ps web|tail -n1|awk '{print $1}'` 11 | php=`docker-compose -f ${base_path}/docker-compose.yml ps php|tail -n1|awk '{print $1}'` 12 | db=`docker-compose -f ${base_path}/docker-compose.yml ps db|tail -n1|awk '{print $1}'` 13 | fi 14 | 15 | echo ${web}|grep -q '\-\-\-\-' 16 | if [ $? -eq 0 ]; then 17 | web="" 18 | fi 19 | 20 | #檢測是否有環境設定檔 21 | #default由container內的laravel install安裝Laravel 22 | export LARAVEL_INSTALLER='container' 23 | if [ -f "${base_path}/.env" ]; then 24 | source ${base_path}/.env 25 | else 26 | base_path="$( cd "$(dirname "$0")" ; pwd -P )" 27 | fi 28 | 29 | #is windows 30 | which winpty >/dev/null 2>&1 31 | if [ $? -eq 0 ]; then 32 | winpty=`which winpty` 33 | hosts_file='/c/Windows/system32/drivers/etc/hosts' 34 | fi 35 | 36 | #array_service 37 | function array_service { 38 | array_service=(${DOCKER_SERVICES}) 39 | CONSOLE_CMD="" 40 | for i in "${array_service[@]}" 41 | do 42 | : 43 | CONSOLE_CMD+="-f ${base_path}/${i} " 44 | done 45 | } 46 | 47 | #common functions 48 | source ./scripts/functions 49 | 50 | function is_running { 51 | if [ "${web}" == "" ]; then 52 | web=${containerName}_web_1 53 | fi 54 | docker-compose -f ${base_path}/docker-compose.yml ps |grep ${web}|grep -q -e 'Up' -e 'running' 55 | 56 | if [ $? -eq 1 ]; then 57 | echo "Would you like to create the project and run docker-compose up (y/n):" 58 | read ans 59 | if [ ${ans} = 'n' ]; then 60 | exit 61 | else 62 | console_up 63 | if [ ${?} -ne 0 ]; then 64 | #failed to start up 65 | exit; 66 | fi 67 | fi 68 | fi 69 | } 70 | 71 | function help { 72 | echo "usage: ${0} [] [Project name]" 73 | echo "" 74 | echo "Example" 75 | echo "./create [project name]: Create a new laravel proejct into sites folder." 76 | echo "./create [project name] \"5.4.*\": You can specify the version you want to install." 77 | echo "" 78 | echo "options:" 79 | echo " --help : help" 80 | echo " --host [project name]: Adding [project name].test to /etc/hosts, But don't want to install laravel framework." 81 | echo " --db [project name]: Create a database name and user name that is the same as project name." 82 | } 83 | #說明 84 | if [ "${1}" == "--help" ]; then 85 | help 86 | exit; 87 | fi 88 | 89 | if [ "${1}" == "help" ]; then 90 | help 91 | exit; 92 | fi 93 | 94 | #未指定專案名稱 95 | if [ $# -lt 1 ]; then 96 | help 97 | exit; 98 | fi 99 | 100 | #check winpty 101 | function dlaravelconfig { 102 | if [ ${hosts_file} == '/etc/hosts' ]; then 103 | #檢測hosts檔是否已新增 104 | sudo cat ${hosts_file}|tr -s " "|grep "127.0.0.1 ${@}.test" 105 | #找不到時,就新增至Hosts 106 | if [ $? -eq 1 ]; then 107 | echo "127.0.0.1 ${@}.test" |sudo tee -a ${hosts_file} 108 | fi 109 | 110 | sudo cat ${hosts_file}|tr -s " "|grep "127.0.0.1 www.${@}.test" 111 | if [ $? -eq 1 ]; then 112 | echo "127.0.0.1 www.${@}.test" |sudo tee -a ${hosts_file} 113 | fi 114 | ${winpty} docker-compose exec -u dlaravel php sed -i "s/DB_HOST=127.0.0.1/DB_HOST=db/" /var/www/html/${@}/.env >/dev/null 2>&1 115 | if [ $? -eq 2 ]; then 116 | echo "Unable to update sites/${@}/.env file." 117 | exit; 118 | fi 119 | #new 120 | ${winpty} docker-compose exec -u dlaravel php sed -i "s/DB_DATABASE=laravel/DB_DATABASE=${@}/" /var/www/html/${@}/.env 121 | ${winpty} docker-compose exec -u dlaravel php sed -i "s/DB_USERNAME=root/DB_USERNAME=${@}/" /var/www/html/${@}/.env 122 | ${winpty} docker-compose exec -u dlaravel php sed -i "s/DB_PASSWORD=$/DB_PASSWORD=${@}/" /var/www/html/${@}/.env 123 | #old 124 | ${winpty} docker-compose exec -u dlaravel php sed -i "s/DB_DATABASE=homestead/DB_DATABASE=${@}/" /var/www/html/${@}/.env 125 | ${winpty} docker-compose exec -u dlaravel php sed -i "s/DB_USERNAME=homestead/DB_USERNAME=${@}/" /var/www/html/${@}/.env 126 | ${winpty} docker-compose exec -u dlaravel php sed -i "s/DB_PASSWORD=secret/DB_PASSWORD=${@}/" /var/www/html/${@}/.env 127 | 128 | #docker-compose exec php /root/.composer/vendor/bin/laravel new ${1} 129 | #調整資料庫連線到db的container 130 | 131 | else 132 | echo "Win" 133 | #for windows 10 134 | cat /c/Windows/System32/drivers/etc/hosts|grep "127.0.0.1 ${@}.test" 135 | if [ $? -eq 1 ]; then 136 | echo 127.0.0.1 ${@}.test >> /c/Windows/System32/drivers/etc/hosts 137 | fi 138 | 139 | sed -i "s/DB_HOST=127.0.0.1/DB_HOST=db/" sites/${@}/.env 140 | sed -i "s/DB_DATABASE=homestead/DB_DATABASE=${@}/" sites/${@}/.env 141 | sed -i "s/DB_USERNAME=homestead/DB_USERNAME=${@}/" sites/${@}/.env 142 | sed -i "s/DB_PASSWORD=homestead/DB_PASSWORD=${@}/" sites/${@}/.env 143 | 144 | fi 145 | 146 | #檢測container內是否有給MYSQL_ROOT_PASSWORD 147 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db env|grep MYSQL_ROOT_PASSWORD >/dev/null 2>&1 148 | 149 | #RTOO沒設定密碼 150 | if [ $? -gt 0 ]; then 151 | 152 | #建資料庫 153 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db mysql -e "CREATE DATABASE IF NOT EXISTS \`${1}\`" -h db 154 | #建立使用者 155 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db mysql -e "CREATE USER IF NOT EXISTS \"${1}\"" -h db 156 | #設定使用者帳密同Project名稱 157 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db mysql -e "SET PASSWORD FOR \`${1}\`=PASSWORD(\"${1}\")" -h db 158 | #mysql 5.7.x 159 | #${winpty} docker-compose exec db mysql -e "SET PASSWORD FOR \`${1}\`=\"${1}\"" 160 | #mysql 8.x 161 | #${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db mysql -e "ALTER USER \"${1}\" IDENTIFIED WITH mysql_native_password BY \"${1}\"" 162 | #授權使用者 163 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db mysql -e "GRANT ALL ON \`${1}\`.* TO \"${1}\"" -h db 164 | #更新container權限 165 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db mysql -e "FLUSH PRIVILEGES" -h db 166 | else 167 | #建資料庫 168 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db sh -c 'mysql -e "CREATE DATABASE IF NOT EXISTS \`'${1}'\`" -uroot -p"$MYSQL_ROOT_PASSWORD"' -h db >/dev/null 2>&1 169 | #建立使用者 170 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db sh -c 'mysql -e "CREATE USER IF NOT EXISTS \"'${1}'\"" -uroot -p"$MYSQL_ROOT_PASSWORD"' -h db >/dev/null 2>&1 171 | #設定使用者帳密同Project名稱 172 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db sh -c 'mysql -e "SET PASSWORD FOR \`'${1}'\`=\"'${1}'\"" -uroot -p"$MYSQL_ROOT_PASSWORD"' >/dev/null 2>&1 173 | 174 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "SET PASSWORD FOR \`${1}\`=PASSWORD(\"${1}\")" -h db 175 | #${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db sh -c 'mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "ALTER USER \"'${1}'\" IDENTIFIED WITH mysql_native_password BY \"'${1}'\""' -h db 176 | #授權使用者 177 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db sh -c 'mysql -e "GRANT ALL ON \`'${1}'\`.* TO \"'${1}'\"" -uroot -p"$MYSQL_ROOT_PASSWORD"' -h db >/dev/null 2>&1 178 | #更新container權限 179 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db sh -c 'mysql -e "FLUSH PRIVILEGES" -uroot -p"$MYSQL_ROOT_PASSWORD"' -h db >/dev/null 2>&1 180 | 181 | fi 182 | 183 | 184 | 185 | 186 | #拷貝default.sample修改 187 | #docker-compose exec web cp /etc/nginx/conf.d/default.sample /etc/nginx/conf.d/${1}.conf 188 | 189 | #變更內容 190 | #docker-compose exec web sed -i "s/laravel/${1}/g" /etc/nginx/conf.d/${1}.conf 191 | #docker-compose exec web sed -i "s/localhost/${1}.test/" /etc/nginx/conf.d/${1}.conf 192 | 193 | source ./scripts/nginx-reload 194 | 195 | #web=`docker-compose ps|grep -e 'Up' -e 'running' |grep ${containerName}_web_1|cut -d ' ' -f 1` 196 | web=`docker-compose -f ${base_path}/docker-compose.yml ps web|awk '{print $1}'|tail -n1` 197 | web_port=`${win_pty} docker inspect --format='{{(index (index .NetworkSettings.Ports "80/tcp") 0).HostPort}}' ${web}` 198 | 199 | #echo " http://${1}.test:${web_port}" 200 | 201 | if [[ ${web_port} == "80" ]]; then 202 | echo -n http://;echo ${1}.test|cut -d/ -f 2; 203 | else 204 | echo -n http://;echo ${1}.test:${web_port}|cut -d/ -f 2; 205 | fi 206 | 207 | } 208 | 209 | #由container建立Laravel 210 | function dlaravel_new { 211 | if [ ${hosts_file} == '/etc/hosts' ]; then 212 | 213 | #確保ubuntu環境能順利寫入資料 214 | #${winpty} docker-compose exec php chown dlaravel /var/www/html 215 | #確保dlaravel有權限寫入/var/log,例如xdebug.log 216 | #${winpty} docker-compose exec php chown dlaravel /var/log 217 | #由container進行Laravel安裝 218 | if [ ${LARAVEL_INSTALLER} == 'container' ]; then 219 | echo "Run laravel installer in container: laravel new ${1}" 220 | ${winpty} docker-compose -f docker-compose.yml exec -u dlaravel php /home/dlaravel/.composer/vendor/bin/laravel new ${1} 221 | if [ $? -eq 1 ]; then 222 | ${winpty} docker-compose -f docker-compose.yml ps 223 | exit 224 | fi 225 | fi 226 | #由主機端的Laravel Installer安裝 227 | if [ ${LARAVEL_INSTALLER} == 'host' ]; then 228 | echo "Run laravel installer on host: laravel new ${1}" 229 | laravel new sites/${1} 230 | fi 231 | else 232 | 233 | which laravel >/dev/null 2>&1 234 | 235 | if [ $? -eq 0 ]; then 236 | laravel new sites/${1} 237 | 238 | #for windows 10 239 | cat /c/Windows/System32/drivers/etc/hosts|grep "127.0.0.1 ${2}.test" 240 | if [ $? -eq 1 ]; then 241 | echo "127.0.0.1 ${2}.test" >> /c/Windows/System32/drivers/etc/hosts 242 | fi 243 | 244 | else 245 | echo "Please install laravel installer from gitbash on Windows 10" 246 | echo "or you can manually run laravel installer in the php container and create database by yourself." 247 | exit 248 | fi 249 | fi 250 | } 251 | 252 | 253 | #create --host 254 | if [ "$#" -eq 2 ]; then 255 | 256 | if [ "${1}" = "--db" ]; then 257 | is_running 258 | MYSQL_ROOT_PASSWORD=`${winpty} docker-compose -f docker-compose.yml exec db env|grep MYSQL_ROOT_PASSWORD|cut -d= -f2` 259 | 260 | if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then 261 | #建立資料庫,如果不存在 262 | ${winpty} docker-compose -f docker-compose.yml exec db mysql -e "CREATE DATABASE IF NOT EXISTS \`${2}\`" -h db 263 | #建立使用者 264 | ${winpty} docker-compose -f docker-compose.yml exec db mysql -e "CREATE USER IF NOT EXISTS \"${2}\"" -h db 265 | #建立密碼,同使用者名稱 266 | ${winpty} docker-compose -f docker-compose.yml exec db mysql -e "SET PASSWORD FOR \`${2}\`=PASSWORD(\"${2}\")" -h db 267 | #mysql 5.7.x 268 | #${winpty} docker-compose -f docker-compose.yml exec db mysql -e "SET PASSWORD FOR \`${2}\`=\"${2}\"" 269 | #mysql 8.x 270 | #${winpty} docker-compose -f docker-compose.yml exec db mysql -e "ALTER USER \"${2}\" IDENTIFIED WITH mysql_native_password BY \"${2}\"" 271 | #授權 272 | ${winpty} docker-compose -f docker-compose.yml exec db mysql -e "GRANT ALL ON \`${2}\`.* TO \"${2}\"" -h db 273 | #更新container權限 274 | ${winpty} docker-compose -f docker-compose.yml exec db mysql -e "FLUSH PRIVILEGES" -h db 275 | else 276 | #建資料庫 277 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db sh -c 'mysql -e "CREATE DATABASE IF NOT EXISTS \`'${2}'\`" -uroot -p"$MYSQL_ROOT_PASSWORD"' -h db > /dev/null 2>&1 278 | #建立使用者 279 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db sh -c 'mysql -e "CREATE USER IF NOT EXISTS \"'${2}'\"" -uroot -p"$MYSQL_ROOT_PASSWORD"' -h db > /dev/null 2>&1 280 | #設定使用者帳密同Project名稱 281 | #mariadb 282 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db sh -c 'mysql -e "SET PASSWORD FOR \`'${2}'\`=PASSWORD(\"'${2}'\")" -uroot -p"$MYSQL_ROOT_PASSWORD"' -h db > /dev/null 2>&1 283 | #mysql 5.7 284 | #${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db sh -c 'mysql -e "SET PASSWORD FOR \`'${2}'\`=\"'${2}'\"" -uroot -p"$MYSQL_ROOT_PASSWORD"' > /dev/null 2>&1 285 | #mysql 8 286 | #${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db sh -c 'mysql -e "ALTER USER \"'${2}'\" IDENTIFIED WITH mysql_native_password BY \"'${2}'\"" -uroot -p"$MYSQL_ROOT_PASSWORD"' > /dev/null 2>&1 287 | #授權使用者 288 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db sh -c 'mysql -e "GRANT ALL ON \`'${2}'\`.* TO \"'${2}'\"" -uroot -p"$MYSQL_ROOT_PASSWORD"' -h db > /dev/null 2>&1 289 | #更新container權限 290 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml exec db sh -c 'mysql -e "FLUSH PRIVILEGES" -uroot -p"$MYSQL_ROOT_PASSWORD"' -h db > /dev/null 2>&1 291 | 292 | if [ $? -eq 1 ]; then 293 | echo "CREATE DATABASE failed. Please try restart your container." 294 | exit; 295 | fi 296 | fi 297 | 298 | echo "Done." 299 | exit; 300 | fi 301 | if [ "${1}" = "--host" ]; then 302 | 303 | if [ ${hosts_file} == '/etc/hosts' ]; then 304 | sudo cat /etc/hosts|tr -s " "|grep "127.0.0.1 ${2}.test" 305 | #找不到時,就新增至Hosts 306 | if [ $? -eq 1 ]; then 307 | echo "127.0.0.1 ${2}.test" |sudo tee -a /etc/hosts 308 | fi 309 | else 310 | 311 | #for windows 10 312 | cat /c/Windows/System32/drivers/etc/hosts|grep "127.0.0.1 ${2}.test" 313 | if [ $? -eq 1 ]; then 314 | echo "127.0.0.1 ${2}.test" >> /c/Windows/System32/drivers/etc/hosts 315 | fi 316 | fi 317 | 318 | ${winpty} docker-compose -f ${base_path}/docker-compose.yml ps web 319 | if [ $? -eq 0 ]; then 320 | source ./scripts/nginx-reload 321 | fi 322 | echo "To manually create new empty project:" 323 | echo "mkdir -p sites/${2}/public;touch sites/${2}/public/index.php" 324 | exit 325 | fi 326 | fi 327 | 328 | #資料夾不能有 . 329 | if [[ "${1}" =~ [\.] ]]; then 330 | echo "Can't have dot in Project name." 331 | exit; 332 | fi 333 | 334 | #檢測目錄是否已存在 335 | if [ -e "sites/${1}" ]; then 336 | echo "The sites/${1} folder exists" 337 | exit 338 | fi 339 | 340 | #check dlaravel is running 341 | is_running 342 | 343 | #install laravel by version 344 | if [ "$#" -eq 2 ]; then 345 | ${winpty} docker-compose -f ${base_path} exec -u dlaravel php /usr/local/bin/composer create-project laravel/laravel=${2} ${1} --prefer-dist 346 | dlaravelconfig ${1} 347 | exit; 348 | fi 349 | 350 | chk_default_conf_exist 351 | 352 | #install new laravel project 353 | dlaravel_new ${1} 354 | 355 | dlaravelconfig ${1} 356 | -------------------------------------------------------------------------------- /etc/php-fpm.d/www.conf: -------------------------------------------------------------------------------- 1 | ; Start a new pool named 'www'. 2 | ; the variable $pool can be used in any directive and will be replaced by the 3 | ; pool name ('www' here) 4 | [www] 5 | 6 | ; Per pool prefix 7 | ; It only applies on the following directives: 8 | ; - 'access.log' 9 | ; - 'slowlog' 10 | ; - 'listen' (unixsocket) 11 | ; - 'chroot' 12 | ; - 'chdir' 13 | ; - 'php_values' 14 | ; - 'php_admin_values' 15 | ; When not set, the global prefix (or NONE) applies instead. 16 | ; Note: This directive can also be relative to the global prefix. 17 | ; Default Value: none 18 | ;prefix = /path/to/pools/$pool 19 | 20 | ; Unix user/group of processes 21 | ; Note: The user is mandatory. If the group is not set, the default user's group 22 | ; will be used. 23 | user = dlaravel 24 | group = dlaravel 25 | 26 | ; The address on which to accept FastCGI requests. 27 | ; Valid syntaxes are: 28 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on 29 | ; a specific port; 30 | ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on 31 | ; a specific port; 32 | ; 'port' - to listen on a TCP socket to all addresses 33 | ; (IPv6 and IPv4-mapped) on a specific port; 34 | ; '/path/to/unix/socket' - to listen on a unix socket. 35 | ; Note: This value is mandatory. 36 | listen = 127.0.0.1:9000 37 | 38 | ; Set listen(2) backlog. 39 | ; Default Value: 511 (-1 on FreeBSD and OpenBSD) 40 | ;listen.backlog = 511 41 | 42 | ; Set permissions for unix socket, if one is used. In Linux, read/write 43 | ; permissions must be set in order to allow connections from a web server. Many 44 | ; BSD-derived systems allow connections regardless of permissions. 45 | ; Default Values: user and group are set as the running user 46 | ; mode is set to 0660 47 | ;listen.owner = dlaravel 48 | ;listen.group = dlaravel 49 | ;listen.mode = 0660 50 | ; When POSIX Access Control Lists are supported you can set them using 51 | ; these options, value is a comma separated list of user/group names. 52 | ; When set, listen.owner and listen.group are ignored 53 | ;listen.acl_users = 54 | ;listen.acl_groups = 55 | 56 | ; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. 57 | ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original 58 | ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address 59 | ; must be separated by a comma. If this value is left blank, connections will be 60 | ; accepted from any ip address. 61 | ; Default Value: any 62 | ;listen.allowed_clients = 127.0.0.1 63 | 64 | ; Specify the nice(2) priority to apply to the pool processes (only if set) 65 | ; The value can vary from -19 (highest priority) to 20 (lower priority) 66 | ; Note: - It will only work if the FPM master process is launched as root 67 | ; - The pool processes will inherit the master process priority 68 | ; unless it specified otherwise 69 | ; Default Value: no set 70 | ; process.priority = -19 71 | 72 | ; Choose how the process manager will control the number of child processes. 73 | ; Possible Values: 74 | ; static - a fixed number (pm.max_children) of child processes; 75 | ; dynamic - the number of child processes are set dynamically based on the 76 | ; following directives. With this process management, there will be 77 | ; always at least 1 children. 78 | ; pm.max_children - the maximum number of children that can 79 | ; be alive at the same time. 80 | ; pm.start_servers - the number of children created on startup. 81 | ; pm.min_spare_servers - the minimum number of children in 'idle' 82 | ; state (waiting to process). If the number 83 | ; of 'idle' processes is less than this 84 | ; number then some children will be created. 85 | ; pm.max_spare_servers - the maximum number of children in 'idle' 86 | ; state (waiting to process). If the number 87 | ; of 'idle' processes is greater than this 88 | ; number then some children will be killed. 89 | ; ondemand - no children are created at startup. Children will be forked when 90 | ; new requests will connect. The following parameter are used: 91 | ; pm.max_children - the maximum number of children that 92 | ; can be alive at the same time. 93 | ; pm.process_idle_timeout - The number of seconds after which 94 | ; an idle process will be killed. 95 | ; Note: This value is mandatory. 96 | pm = dynamic 97 | 98 | ; The number of child processes to be created when pm is set to 'static' and the 99 | ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. 100 | ; This value sets the limit on the number of simultaneous requests that will be 101 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. 102 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP 103 | ; CGI. The below defaults are based on a server without much resources. Don't 104 | ; forget to tweak pm.* to fit your needs. 105 | ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' 106 | ; Note: This value is mandatory. 107 | pm.max_children = 5 108 | 109 | ; The number of child processes created on startup. 110 | ; Note: Used only when pm is set to 'dynamic' 111 | ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 112 | pm.start_servers = 2 113 | 114 | ; The desired minimum number of idle server processes. 115 | ; Note: Used only when pm is set to 'dynamic' 116 | ; Note: Mandatory when pm is set to 'dynamic' 117 | pm.min_spare_servers = 1 118 | 119 | ; The desired maximum number of idle server processes. 120 | ; Note: Used only when pm is set to 'dynamic' 121 | ; Note: Mandatory when pm is set to 'dynamic' 122 | pm.max_spare_servers = 3 123 | 124 | ; The number of seconds after which an idle process will be killed. 125 | ; Note: Used only when pm is set to 'ondemand' 126 | ; Default Value: 10s 127 | ;pm.process_idle_timeout = 10s; 128 | 129 | ; The number of requests each child process should execute before respawning. 130 | ; This can be useful to work around memory leaks in 3rd party libraries. For 131 | ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. 132 | ; Default Value: 0 133 | ;pm.max_requests = 500 134 | 135 | ; The URI to view the FPM status page. If this value is not set, no URI will be 136 | ; recognized as a status page. It shows the following informations: 137 | ; pool - the name of the pool; 138 | ; process manager - static, dynamic or ondemand; 139 | ; start time - the date and time FPM has started; 140 | ; start since - number of seconds since FPM has started; 141 | ; accepted conn - the number of request accepted by the pool; 142 | ; listen queue - the number of request in the queue of pending 143 | ; connections (see backlog in listen(2)); 144 | ; max listen queue - the maximum number of requests in the queue 145 | ; of pending connections since FPM has started; 146 | ; listen queue len - the size of the socket queue of pending connections; 147 | ; idle processes - the number of idle processes; 148 | ; active processes - the number of active processes; 149 | ; total processes - the number of idle + active processes; 150 | ; max active processes - the maximum number of active processes since FPM 151 | ; has started; 152 | ; max children reached - number of times, the process limit has been reached, 153 | ; when pm tries to start more children (works only for 154 | ; pm 'dynamic' and 'ondemand'); 155 | ; Value are updated in real time. 156 | ; Example output: 157 | ; pool: www 158 | ; process manager: static 159 | ; start time: 01/Jul/2011:17:53:49 +0200 160 | ; start since: 62636 161 | ; accepted conn: 190460 162 | ; listen queue: 0 163 | ; max listen queue: 1 164 | ; listen queue len: 42 165 | ; idle processes: 4 166 | ; active processes: 11 167 | ; total processes: 15 168 | ; max active processes: 12 169 | ; max children reached: 0 170 | ; 171 | ; By default the status page output is formatted as text/plain. Passing either 172 | ; 'html', 'xml' or 'json' in the query string will return the corresponding 173 | ; output syntax. Example: 174 | ; http://www.foo.bar/status 175 | ; http://www.foo.bar/status?json 176 | ; http://www.foo.bar/status?html 177 | ; http://www.foo.bar/status?xml 178 | ; 179 | ; By default the status page only outputs short status. Passing 'full' in the 180 | ; query string will also return status for each pool process. 181 | ; Example: 182 | ; http://www.foo.bar/status?full 183 | ; http://www.foo.bar/status?json&full 184 | ; http://www.foo.bar/status?html&full 185 | ; http://www.foo.bar/status?xml&full 186 | ; The Full status returns for each process: 187 | ; pid - the PID of the process; 188 | ; state - the state of the process (Idle, Running, ...); 189 | ; start time - the date and time the process has started; 190 | ; start since - the number of seconds since the process has started; 191 | ; requests - the number of requests the process has served; 192 | ; request duration - the duration in µs of the requests; 193 | ; request method - the request method (GET, POST, ...); 194 | ; request URI - the request URI with the query string; 195 | ; content length - the content length of the request (only with POST); 196 | ; user - the user (PHP_AUTH_USER) (or '-' if not set); 197 | ; script - the main script called (or '-' if not set); 198 | ; last request cpu - the %cpu the last request consumed 199 | ; it's always 0 if the process is not in Idle state 200 | ; because CPU calculation is done when the request 201 | ; processing has terminated; 202 | ; last request memory - the max amount of memory the last request consumed 203 | ; it's always 0 if the process is not in Idle state 204 | ; because memory calculation is done when the request 205 | ; processing has terminated; 206 | ; If the process is in Idle state, then informations are related to the 207 | ; last request the process has served. Otherwise informations are related to 208 | ; the current request being served. 209 | ; Example output: 210 | ; ************************ 211 | ; pid: 31330 212 | ; state: Running 213 | ; start time: 01/Jul/2011:17:53:49 +0200 214 | ; start since: 63087 215 | ; requests: 12808 216 | ; request duration: 1250261 217 | ; request method: GET 218 | ; request URI: /test_mem.php?N=10000 219 | ; content length: 0 220 | ; user: - 221 | ; script: /home/fat/web/docs/php/test_mem.php 222 | ; last request cpu: 0.00 223 | ; last request memory: 0 224 | ; 225 | ; Note: There is a real-time FPM status monitoring sample web page available 226 | ; It's available in: /usr/local/share/php/fpm/status.html 227 | ; 228 | ; Note: The value must start with a leading slash (/). The value can be 229 | ; anything, but it may not be a good idea to use the .php extension or it 230 | ; may conflict with a real PHP file. 231 | ; Default Value: not set 232 | ;pm.status_path = /status 233 | 234 | ; The ping URI to call the monitoring page of FPM. If this value is not set, no 235 | ; URI will be recognized as a ping page. This could be used to test from outside 236 | ; that FPM is alive and responding, or to 237 | ; - create a graph of FPM availability (rrd or such); 238 | ; - remove a server from a group if it is not responding (load balancing); 239 | ; - trigger alerts for the operating team (24/7). 240 | ; Note: The value must start with a leading slash (/). The value can be 241 | ; anything, but it may not be a good idea to use the .php extension or it 242 | ; may conflict with a real PHP file. 243 | ; Default Value: not set 244 | ;ping.path = /ping 245 | 246 | ; This directive may be used to customize the response of a ping request. The 247 | ; response is formatted as text/plain with a 200 response code. 248 | ; Default Value: pong 249 | ;ping.response = pong 250 | 251 | ; The access log file 252 | ; Default: not set 253 | ;access.log = log/$pool.access.log 254 | 255 | ; The access log format. 256 | ; The following syntax is allowed 257 | ; %%: the '%' character 258 | ; %C: %CPU used by the request 259 | ; it can accept the following format: 260 | ; - %{user}C for user CPU only 261 | ; - %{system}C for system CPU only 262 | ; - %{total}C for user + system CPU (default) 263 | ; %d: time taken to serve the request 264 | ; it can accept the following format: 265 | ; - %{seconds}d (default) 266 | ; - %{miliseconds}d 267 | ; - %{mili}d 268 | ; - %{microseconds}d 269 | ; - %{micro}d 270 | ; %e: an environment variable (same as $_ENV or $_SERVER) 271 | ; it must be associated with embraces to specify the name of the env 272 | ; variable. Some exemples: 273 | ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e 274 | ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e 275 | ; %f: script filename 276 | ; %l: content-length of the request (for POST request only) 277 | ; %m: request method 278 | ; %M: peak of memory allocated by PHP 279 | ; it can accept the following format: 280 | ; - %{bytes}M (default) 281 | ; - %{kilobytes}M 282 | ; - %{kilo}M 283 | ; - %{megabytes}M 284 | ; - %{mega}M 285 | ; %n: pool name 286 | ; %o: output header 287 | ; it must be associated with embraces to specify the name of the header: 288 | ; - %{Content-Type}o 289 | ; - %{X-Powered-By}o 290 | ; - %{Transfert-Encoding}o 291 | ; - .... 292 | ; %p: PID of the child that serviced the request 293 | ; %P: PID of the parent of the child that serviced the request 294 | ; %q: the query string 295 | ; %Q: the '?' character if query string exists 296 | ; %r: the request URI (without the query string, see %q and %Q) 297 | ; %R: remote IP address 298 | ; %s: status (response code) 299 | ; %t: server time the request was received 300 | ; it can accept a strftime(3) format: 301 | ; %d/%b/%Y:%H:%M:%S %z (default) 302 | ; The strftime(3) format must be encapsuled in a %{}t tag 303 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t 304 | ; %T: time the log has been written (the request has finished) 305 | ; it can accept a strftime(3) format: 306 | ; %d/%b/%Y:%H:%M:%S %z (default) 307 | ; The strftime(3) format must be encapsuled in a %{}t tag 308 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t 309 | ; %u: remote user 310 | ; 311 | ; Default: "%R - %u %t \"%m %r\" %s" 312 | ;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" 313 | 314 | ; The log file for slow requests 315 | ; Default Value: not set 316 | ; Note: slowlog is mandatory if request_slowlog_timeout is set 317 | ;slowlog = log/$pool.log.slow 318 | 319 | ; The timeout for serving a single request after which a PHP backtrace will be 320 | ; dumped to the 'slowlog' file. A value of '0s' means 'off'. 321 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 322 | ; Default Value: 0 323 | ;request_slowlog_timeout = 0 324 | 325 | ; The timeout for serving a single request after which the worker process will 326 | ; be killed. This option should be used when the 'max_execution_time' ini option 327 | ; does not stop script execution for some reason. A value of '0' means 'off'. 328 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 329 | ; Default Value: 0 330 | ;request_terminate_timeout = 0 331 | 332 | ; Set open file descriptor rlimit. 333 | ; Default Value: system defined value 334 | ;rlimit_files = 1024 335 | 336 | ; Set max core size rlimit. 337 | ; Possible Values: 'unlimited' or an integer greater or equal to 0 338 | ; Default Value: system defined value 339 | ;rlimit_core = 0 340 | 341 | ; Chroot to this directory at the start. This value must be defined as an 342 | ; absolute path. When this value is not set, chroot is not used. 343 | ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one 344 | ; of its subdirectories. If the pool prefix is not set, the global prefix 345 | ; will be used instead. 346 | ; Note: chrooting is a great security feature and should be used whenever 347 | ; possible. However, all PHP paths will be relative to the chroot 348 | ; (error_log, sessions.save_path, ...). 349 | ; Default Value: not set 350 | ;chroot = 351 | 352 | ; Chdir to this directory at the start. 353 | ; Note: relative path can be used. 354 | ; Default Value: current directory or / when chroot 355 | ;chdir = /var/www 356 | 357 | ; Redirect worker stdout and stderr into main error log. If not set, stdout and 358 | ; stderr will be redirected to /dev/null according to FastCGI specs. 359 | ; Note: on highloaded environement, this can cause some delay in the page 360 | ; process time (several ms). 361 | ; Default Value: no 362 | ;catch_workers_output = yes 363 | 364 | ; Clear environment in FPM workers 365 | ; Prevents arbitrary environment variables from reaching FPM worker processes 366 | ; by clearing the environment in workers before env vars specified in this 367 | ; pool configuration are added. 368 | ; Setting to "no" will make all environment variables available to PHP code 369 | ; via getenv(), $_ENV and $_SERVER. 370 | ; Default Value: yes 371 | ;clear_env = no 372 | 373 | ; Limits the extensions of the main script FPM will allow to parse. This can 374 | ; prevent configuration mistakes on the web server side. You should only limit 375 | ; FPM to .php extensions to prevent malicious users to use other extensions to 376 | ; execute php code. 377 | ; Note: set an empty value to allow all extensions. 378 | ; Default Value: .php 379 | ;security.limit_extensions = .php .php3 .php4 .php5 .php7 380 | 381 | ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from 382 | ; the current environment. 383 | ; Default Value: clean env 384 | ;env[HOSTNAME] = $HOSTNAME 385 | ;env[PATH] = /usr/local/bin:/usr/bin:/bin 386 | ;env[TMP] = /tmp 387 | ;env[TMPDIR] = /tmp 388 | ;env[TEMP] = /tmp 389 | 390 | ; Additional php.ini defines, specific to this pool of workers. These settings 391 | ; overwrite the values previously defined in the php.ini. The directives are the 392 | ; same as the PHP SAPI: 393 | ; php_value/php_flag - you can set classic ini defines which can 394 | ; be overwritten from PHP call 'ini_set'. 395 | ; php_admin_value/php_admin_flag - these directives won't be overwritten by 396 | ; PHP call 'ini_set' 397 | ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. 398 | 399 | ; Defining 'extension' will load the corresponding shared extension from 400 | ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not 401 | ; overwrite previously defined php.ini values, but will append the new value 402 | ; instead. 403 | 404 | ; Note: path INI options can be relative and will be expanded with the prefix 405 | ; (pool, global or /usr/local) 406 | 407 | ; Default Value: nothing is defined by default except the values in php.ini and 408 | ; specified at startup with the -d argument 409 | ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com 410 | php_flag[display_errors] = off 411 | php_admin_value[error_log] = /var/log/fpm-php.www.log 412 | php_admin_flag[log_errors] = on 413 | php_admin_value[memory_limit] = 2048M 414 | -------------------------------------------------------------------------------- /etc/php-fpm.d/www.conf.sample: -------------------------------------------------------------------------------- 1 | ; Start a new pool named 'www'. 2 | ; the variable $pool can be used in any directive and will be replaced by the 3 | ; pool name ('www' here) 4 | [www] 5 | 6 | ; Per pool prefix 7 | ; It only applies on the following directives: 8 | ; - 'access.log' 9 | ; - 'slowlog' 10 | ; - 'listen' (unixsocket) 11 | ; - 'chroot' 12 | ; - 'chdir' 13 | ; - 'php_values' 14 | ; - 'php_admin_values' 15 | ; When not set, the global prefix (or NONE) applies instead. 16 | ; Note: This directive can also be relative to the global prefix. 17 | ; Default Value: none 18 | ;prefix = /path/to/pools/$pool 19 | 20 | ; Unix user/group of processes 21 | ; Note: The user is mandatory. If the group is not set, the default user's group 22 | ; will be used. 23 | user = dlaravel 24 | group = dlaravel 25 | 26 | ; The address on which to accept FastCGI requests. 27 | ; Valid syntaxes are: 28 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on 29 | ; a specific port; 30 | ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on 31 | ; a specific port; 32 | ; 'port' - to listen on a TCP socket to all addresses 33 | ; (IPv6 and IPv4-mapped) on a specific port; 34 | ; '/path/to/unix/socket' - to listen on a unix socket. 35 | ; Note: This value is mandatory. 36 | listen = 127.0.0.1:9000 37 | 38 | ; Set listen(2) backlog. 39 | ; Default Value: 511 (-1 on FreeBSD and OpenBSD) 40 | ;listen.backlog = 511 41 | 42 | ; Set permissions for unix socket, if one is used. In Linux, read/write 43 | ; permissions must be set in order to allow connections from a web server. Many 44 | ; BSD-derived systems allow connections regardless of permissions. 45 | ; Default Values: user and group are set as the running user 46 | ; mode is set to 0660 47 | ;listen.owner = dlaravel 48 | ;listen.group = dlaravel 49 | ;listen.mode = 0660 50 | ; When POSIX Access Control Lists are supported you can set them using 51 | ; these options, value is a comma separated list of user/group names. 52 | ; When set, listen.owner and listen.group are ignored 53 | ;listen.acl_users = 54 | ;listen.acl_groups = 55 | 56 | ; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. 57 | ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original 58 | ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address 59 | ; must be separated by a comma. If this value is left blank, connections will be 60 | ; accepted from any ip address. 61 | ; Default Value: any 62 | ;listen.allowed_clients = 127.0.0.1 63 | 64 | ; Specify the nice(2) priority to apply to the pool processes (only if set) 65 | ; The value can vary from -19 (highest priority) to 20 (lower priority) 66 | ; Note: - It will only work if the FPM master process is launched as root 67 | ; - The pool processes will inherit the master process priority 68 | ; unless it specified otherwise 69 | ; Default Value: no set 70 | ; process.priority = -19 71 | 72 | ; Choose how the process manager will control the number of child processes. 73 | ; Possible Values: 74 | ; static - a fixed number (pm.max_children) of child processes; 75 | ; dynamic - the number of child processes are set dynamically based on the 76 | ; following directives. With this process management, there will be 77 | ; always at least 1 children. 78 | ; pm.max_children - the maximum number of children that can 79 | ; be alive at the same time. 80 | ; pm.start_servers - the number of children created on startup. 81 | ; pm.min_spare_servers - the minimum number of children in 'idle' 82 | ; state (waiting to process). If the number 83 | ; of 'idle' processes is less than this 84 | ; number then some children will be created. 85 | ; pm.max_spare_servers - the maximum number of children in 'idle' 86 | ; state (waiting to process). If the number 87 | ; of 'idle' processes is greater than this 88 | ; number then some children will be killed. 89 | ; ondemand - no children are created at startup. Children will be forked when 90 | ; new requests will connect. The following parameter are used: 91 | ; pm.max_children - the maximum number of children that 92 | ; can be alive at the same time. 93 | ; pm.process_idle_timeout - The number of seconds after which 94 | ; an idle process will be killed. 95 | ; Note: This value is mandatory. 96 | pm = dynamic 97 | 98 | ; The number of child processes to be created when pm is set to 'static' and the 99 | ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. 100 | ; This value sets the limit on the number of simultaneous requests that will be 101 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. 102 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP 103 | ; CGI. The below defaults are based on a server without much resources. Don't 104 | ; forget to tweak pm.* to fit your needs. 105 | ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' 106 | ; Note: This value is mandatory. 107 | pm.max_children = 5 108 | 109 | ; The number of child processes created on startup. 110 | ; Note: Used only when pm is set to 'dynamic' 111 | ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 112 | pm.start_servers = 2 113 | 114 | ; The desired minimum number of idle server processes. 115 | ; Note: Used only when pm is set to 'dynamic' 116 | ; Note: Mandatory when pm is set to 'dynamic' 117 | pm.min_spare_servers = 1 118 | 119 | ; The desired maximum number of idle server processes. 120 | ; Note: Used only when pm is set to 'dynamic' 121 | ; Note: Mandatory when pm is set to 'dynamic' 122 | pm.max_spare_servers = 3 123 | 124 | ; The number of seconds after which an idle process will be killed. 125 | ; Note: Used only when pm is set to 'ondemand' 126 | ; Default Value: 10s 127 | ;pm.process_idle_timeout = 10s; 128 | 129 | ; The number of requests each child process should execute before respawning. 130 | ; This can be useful to work around memory leaks in 3rd party libraries. For 131 | ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. 132 | ; Default Value: 0 133 | ;pm.max_requests = 500 134 | 135 | ; The URI to view the FPM status page. If this value is not set, no URI will be 136 | ; recognized as a status page. It shows the following informations: 137 | ; pool - the name of the pool; 138 | ; process manager - static, dynamic or ondemand; 139 | ; start time - the date and time FPM has started; 140 | ; start since - number of seconds since FPM has started; 141 | ; accepted conn - the number of request accepted by the pool; 142 | ; listen queue - the number of request in the queue of pending 143 | ; connections (see backlog in listen(2)); 144 | ; max listen queue - the maximum number of requests in the queue 145 | ; of pending connections since FPM has started; 146 | ; listen queue len - the size of the socket queue of pending connections; 147 | ; idle processes - the number of idle processes; 148 | ; active processes - the number of active processes; 149 | ; total processes - the number of idle + active processes; 150 | ; max active processes - the maximum number of active processes since FPM 151 | ; has started; 152 | ; max children reached - number of times, the process limit has been reached, 153 | ; when pm tries to start more children (works only for 154 | ; pm 'dynamic' and 'ondemand'); 155 | ; Value are updated in real time. 156 | ; Example output: 157 | ; pool: www 158 | ; process manager: static 159 | ; start time: 01/Jul/2011:17:53:49 +0200 160 | ; start since: 62636 161 | ; accepted conn: 190460 162 | ; listen queue: 0 163 | ; max listen queue: 1 164 | ; listen queue len: 42 165 | ; idle processes: 4 166 | ; active processes: 11 167 | ; total processes: 15 168 | ; max active processes: 12 169 | ; max children reached: 0 170 | ; 171 | ; By default the status page output is formatted as text/plain. Passing either 172 | ; 'html', 'xml' or 'json' in the query string will return the corresponding 173 | ; output syntax. Example: 174 | ; http://www.foo.bar/status 175 | ; http://www.foo.bar/status?json 176 | ; http://www.foo.bar/status?html 177 | ; http://www.foo.bar/status?xml 178 | ; 179 | ; By default the status page only outputs short status. Passing 'full' in the 180 | ; query string will also return status for each pool process. 181 | ; Example: 182 | ; http://www.foo.bar/status?full 183 | ; http://www.foo.bar/status?json&full 184 | ; http://www.foo.bar/status?html&full 185 | ; http://www.foo.bar/status?xml&full 186 | ; The Full status returns for each process: 187 | ; pid - the PID of the process; 188 | ; state - the state of the process (Idle, Running, ...); 189 | ; start time - the date and time the process has started; 190 | ; start since - the number of seconds since the process has started; 191 | ; requests - the number of requests the process has served; 192 | ; request duration - the duration in µs of the requests; 193 | ; request method - the request method (GET, POST, ...); 194 | ; request URI - the request URI with the query string; 195 | ; content length - the content length of the request (only with POST); 196 | ; user - the user (PHP_AUTH_USER) (or '-' if not set); 197 | ; script - the main script called (or '-' if not set); 198 | ; last request cpu - the %cpu the last request consumed 199 | ; it's always 0 if the process is not in Idle state 200 | ; because CPU calculation is done when the request 201 | ; processing has terminated; 202 | ; last request memory - the max amount of memory the last request consumed 203 | ; it's always 0 if the process is not in Idle state 204 | ; because memory calculation is done when the request 205 | ; processing has terminated; 206 | ; If the process is in Idle state, then informations are related to the 207 | ; last request the process has served. Otherwise informations are related to 208 | ; the current request being served. 209 | ; Example output: 210 | ; ************************ 211 | ; pid: 31330 212 | ; state: Running 213 | ; start time: 01/Jul/2011:17:53:49 +0200 214 | ; start since: 63087 215 | ; requests: 12808 216 | ; request duration: 1250261 217 | ; request method: GET 218 | ; request URI: /test_mem.php?N=10000 219 | ; content length: 0 220 | ; user: - 221 | ; script: /home/fat/web/docs/php/test_mem.php 222 | ; last request cpu: 0.00 223 | ; last request memory: 0 224 | ; 225 | ; Note: There is a real-time FPM status monitoring sample web page available 226 | ; It's available in: /usr/local/share/php/fpm/status.html 227 | ; 228 | ; Note: The value must start with a leading slash (/). The value can be 229 | ; anything, but it may not be a good idea to use the .php extension or it 230 | ; may conflict with a real PHP file. 231 | ; Default Value: not set 232 | ;pm.status_path = /status 233 | 234 | ; The ping URI to call the monitoring page of FPM. If this value is not set, no 235 | ; URI will be recognized as a ping page. This could be used to test from outside 236 | ; that FPM is alive and responding, or to 237 | ; - create a graph of FPM availability (rrd or such); 238 | ; - remove a server from a group if it is not responding (load balancing); 239 | ; - trigger alerts for the operating team (24/7). 240 | ; Note: The value must start with a leading slash (/). The value can be 241 | ; anything, but it may not be a good idea to use the .php extension or it 242 | ; may conflict with a real PHP file. 243 | ; Default Value: not set 244 | ;ping.path = /ping 245 | 246 | ; This directive may be used to customize the response of a ping request. The 247 | ; response is formatted as text/plain with a 200 response code. 248 | ; Default Value: pong 249 | ;ping.response = pong 250 | 251 | ; The access log file 252 | ; Default: not set 253 | ;access.log = log/$pool.access.log 254 | 255 | ; The access log format. 256 | ; The following syntax is allowed 257 | ; %%: the '%' character 258 | ; %C: %CPU used by the request 259 | ; it can accept the following format: 260 | ; - %{user}C for user CPU only 261 | ; - %{system}C for system CPU only 262 | ; - %{total}C for user + system CPU (default) 263 | ; %d: time taken to serve the request 264 | ; it can accept the following format: 265 | ; - %{seconds}d (default) 266 | ; - %{miliseconds}d 267 | ; - %{mili}d 268 | ; - %{microseconds}d 269 | ; - %{micro}d 270 | ; %e: an environment variable (same as $_ENV or $_SERVER) 271 | ; it must be associated with embraces to specify the name of the env 272 | ; variable. Some exemples: 273 | ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e 274 | ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e 275 | ; %f: script filename 276 | ; %l: content-length of the request (for POST request only) 277 | ; %m: request method 278 | ; %M: peak of memory allocated by PHP 279 | ; it can accept the following format: 280 | ; - %{bytes}M (default) 281 | ; - %{kilobytes}M 282 | ; - %{kilo}M 283 | ; - %{megabytes}M 284 | ; - %{mega}M 285 | ; %n: pool name 286 | ; %o: output header 287 | ; it must be associated with embraces to specify the name of the header: 288 | ; - %{Content-Type}o 289 | ; - %{X-Powered-By}o 290 | ; - %{Transfert-Encoding}o 291 | ; - .... 292 | ; %p: PID of the child that serviced the request 293 | ; %P: PID of the parent of the child that serviced the request 294 | ; %q: the query string 295 | ; %Q: the '?' character if query string exists 296 | ; %r: the request URI (without the query string, see %q and %Q) 297 | ; %R: remote IP address 298 | ; %s: status (response code) 299 | ; %t: server time the request was received 300 | ; it can accept a strftime(3) format: 301 | ; %d/%b/%Y:%H:%M:%S %z (default) 302 | ; The strftime(3) format must be encapsuled in a %{}t tag 303 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t 304 | ; %T: time the log has been written (the request has finished) 305 | ; it can accept a strftime(3) format: 306 | ; %d/%b/%Y:%H:%M:%S %z (default) 307 | ; The strftime(3) format must be encapsuled in a %{}t tag 308 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t 309 | ; %u: remote user 310 | ; 311 | ; Default: "%R - %u %t \"%m %r\" %s" 312 | ;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" 313 | 314 | ; The log file for slow requests 315 | ; Default Value: not set 316 | ; Note: slowlog is mandatory if request_slowlog_timeout is set 317 | ;slowlog = log/$pool.log.slow 318 | 319 | ; The timeout for serving a single request after which a PHP backtrace will be 320 | ; dumped to the 'slowlog' file. A value of '0s' means 'off'. 321 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 322 | ; Default Value: 0 323 | ;request_slowlog_timeout = 0 324 | 325 | ; The timeout for serving a single request after which the worker process will 326 | ; be killed. This option should be used when the 'max_execution_time' ini option 327 | ; does not stop script execution for some reason. A value of '0' means 'off'. 328 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 329 | ; Default Value: 0 330 | ;request_terminate_timeout = 0 331 | 332 | ; Set open file descriptor rlimit. 333 | ; Default Value: system defined value 334 | ;rlimit_files = 1024 335 | 336 | ; Set max core size rlimit. 337 | ; Possible Values: 'unlimited' or an integer greater or equal to 0 338 | ; Default Value: system defined value 339 | ;rlimit_core = 0 340 | 341 | ; Chroot to this directory at the start. This value must be defined as an 342 | ; absolute path. When this value is not set, chroot is not used. 343 | ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one 344 | ; of its subdirectories. If the pool prefix is not set, the global prefix 345 | ; will be used instead. 346 | ; Note: chrooting is a great security feature and should be used whenever 347 | ; possible. However, all PHP paths will be relative to the chroot 348 | ; (error_log, sessions.save_path, ...). 349 | ; Default Value: not set 350 | ;chroot = 351 | 352 | ; Chdir to this directory at the start. 353 | ; Note: relative path can be used. 354 | ; Default Value: current directory or / when chroot 355 | ;chdir = /var/www 356 | 357 | ; Redirect worker stdout and stderr into main error log. If not set, stdout and 358 | ; stderr will be redirected to /dev/null according to FastCGI specs. 359 | ; Note: on highloaded environement, this can cause some delay in the page 360 | ; process time (several ms). 361 | ; Default Value: no 362 | ;catch_workers_output = yes 363 | 364 | ; Clear environment in FPM workers 365 | ; Prevents arbitrary environment variables from reaching FPM worker processes 366 | ; by clearing the environment in workers before env vars specified in this 367 | ; pool configuration are added. 368 | ; Setting to "no" will make all environment variables available to PHP code 369 | ; via getenv(), $_ENV and $_SERVER. 370 | ; Default Value: yes 371 | ;clear_env = no 372 | 373 | ; Limits the extensions of the main script FPM will allow to parse. This can 374 | ; prevent configuration mistakes on the web server side. You should only limit 375 | ; FPM to .php extensions to prevent malicious users to use other extensions to 376 | ; execute php code. 377 | ; Note: set an empty value to allow all extensions. 378 | ; Default Value: .php 379 | ;security.limit_extensions = .php .php3 .php4 .php5 .php7 380 | 381 | ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from 382 | ; the current environment. 383 | ; Default Value: clean env 384 | ;env[HOSTNAME] = $HOSTNAME 385 | ;env[PATH] = /usr/local/bin:/usr/bin:/bin 386 | ;env[TMP] = /tmp 387 | ;env[TMPDIR] = /tmp 388 | ;env[TEMP] = /tmp 389 | 390 | ; Additional php.ini defines, specific to this pool of workers. These settings 391 | ; overwrite the values previously defined in the php.ini. The directives are the 392 | ; same as the PHP SAPI: 393 | ; php_value/php_flag - you can set classic ini defines which can 394 | ; be overwritten from PHP call 'ini_set'. 395 | ; php_admin_value/php_admin_flag - these directives won't be overwritten by 396 | ; PHP call 'ini_set' 397 | ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. 398 | 399 | ; Defining 'extension' will load the corresponding shared extension from 400 | ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not 401 | ; overwrite previously defined php.ini values, but will append the new value 402 | ; instead. 403 | 404 | ; Note: path INI options can be relative and will be expanded with the prefix 405 | ; (pool, global or /usr/local) 406 | 407 | ; Default Value: nothing is defined by default except the values in php.ini and 408 | ; specified at startup with the -d argument 409 | ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com 410 | php_flag[display_errors] = off 411 | php_admin_value[error_log] = /var/log/fpm-php.www.log 412 | php_admin_flag[log_errors] = on 413 | php_admin_value[memory_limit] = 2048M 414 | -------------------------------------------------------------------------------- /scripts/docker.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os 3 | import sys 4 | import subprocess 5 | import re 6 | import platform 7 | import locale 8 | import fileinput 9 | from shutil import copyfile 10 | system = platform.system() 11 | major = sys.version_info[0] 12 | basepath = os.getcwd() 13 | def e(v): 14 | print(v) 15 | 16 | def get_projects_count(): 17 | count = 0 18 | for file_or_dir in os.listdir("{}/sites".format(basepath)): 19 | if(os.path.isdir("sites/{}".format(file_or_dir))): 20 | count+=1 21 | return count 22 | 23 | def pull(): 24 | command=dockerCompose()+["pull"] 25 | proc = subprocess.Popen(command ,shell=False, stdout=subprocess.PIPE) 26 | output = proc.stdout.read() 27 | e(output) 28 | 29 | def node(): 30 | command="docker run --rm -v {}/sites:/sites -w /sites -ti node bash".format(basepath).split(); 31 | subprocess.call(command) 32 | 33 | def get_sites(): 34 | sites=[] 35 | for file_or_dir in os.listdir("{}/sites".format(basepath)): 36 | if(os.path.isdir("sites/{}".format(file_or_dir))): 37 | sites.append(file_or_dir) 38 | return sites 39 | 40 | def run(command): 41 | proc = subprocess.Popen(command ,shell=False, stdout=subprocess.PIPE) 42 | return proc.stdout.read() 43 | 44 | #檢測dot_env中使用的installer 45 | def dot_env_install(): 46 | fname = "{}/.env".format(basepath) 47 | if(os.path.isfile(fname)): 48 | lines = open(fname, "r").readlines() 49 | for line in lines: 50 | obj = re.search("^LARAVEL_INSTALLER=(.+)", line, re.I | re.M) 51 | if(obj): 52 | value = remove_quotes(obj.group(1)) 53 | return value 54 | return "container" 55 | 56 | #找出.env擋中定義的服務 57 | def dot_env_services(): 58 | default_compose=["docker-compose","-f","{}/docker-compose.yml".format(basepath)] 59 | fname = "{}/.env".format(basepath) 60 | if(os.path.isfile(fname)): 61 | lines = open(fname, "r").readlines() 62 | else: 63 | return default_compose 64 | 65 | env_command = ["-f","docker-compose.yml"] 66 | for line in lines: 67 | obj = re.search("^DOCKER_SERVICES=(.+)", line, re.I | re.M) 68 | if(obj): 69 | services = remove_quotes(obj.group(1)) 70 | services = re.sub("(\\s+)", " ", services) 71 | services = services.split(' ') 72 | for service in services: 73 | env_command += ["-f"]+["{}/service/{}.yml".format(basepath,service)] 74 | 75 | if(len(env_command) > 0): 76 | return ["docker-compose"]+env_command 77 | else: 78 | return default_compose 79 | 80 | def dockerCompose(): 81 | command = dot_env_services() 82 | return command; 83 | 84 | def ps(): 85 | command=dockerCompose()+["ps"] 86 | proc = subprocess.Popen(command ,shell=False, stdout=subprocess.PIPE) 87 | output = proc.stdout.read() 88 | e(output) 89 | 90 | def check_link_or_create(): 91 | if os.path.isfile(basepath+"/docker-compose.yml") == False: 92 | src=basepath+"/docker-compose-normal.yml"; 93 | dst=basepath+"/docker-compose.yml"; 94 | os.symlink(src, dst) 95 | 96 | def check_default_conf(): 97 | if os.path.isfile(basepath+"/etc/default.conf") == False: 98 | src=basepath+"/etc/default.sample"; 99 | dst=basepath+"/etc/default.conf"; 100 | copyfile(src, dst) 101 | 102 | 103 | def up(): 104 | check_default_conf() 105 | check_link_or_create() 106 | command=dockerCompose()+["up","-d"] 107 | proc = subprocess.Popen(command ,shell=False, stdout=subprocess.PIPE) 108 | output = proc.stdout.read().decode('utf-8') 109 | e(output) 110 | 111 | def down(): 112 | check_link_or_create() 113 | command=dockerCompose()+["down"] 114 | proc = subprocess.Popen(command ,shell=False, stdout=subprocess.PIPE) 115 | output = proc.stdout.read().decode('utf-8') 116 | e(output) 117 | 118 | def restart(): 119 | down() 120 | up() 121 | 122 | def get_container_name(service): 123 | #docker-compose ps db 124 | command=dockerCompose()+["ps", service] 125 | proc = subprocess.Popen(command ,shell=False, stdout=subprocess.PIPE) 126 | output = proc.stdout.read().decode('utf-8') 127 | result = re.sub("(.+\\n-+\\n)(.+)\\n", "\\2", output) 128 | result = re.sub("^(.*?)\\s.+", "\\1", result) 129 | result = re.sub("(.+)\\n?", "\\1", result) 130 | if(re.search(".+_\\w+_\\d", result, re.I | re.M)): 131 | return result 132 | else: 133 | return "" 134 | 135 | def is_running(): 136 | command=dockerCompose()+["ps", "web"] 137 | 138 | def db_ports(): 139 | container_name = get_container_name("db") 140 | if(container_name == "" ): 141 | print("db is not running.") 142 | return 143 | 144 | command=["docker","inspect","--format='{{(index (index .NetworkSettings.Ports \"3306/tcp\") 0).HostPort}}'", container_name] 145 | proc = subprocess.Popen(command ,shell=False, stdout=subprocess.PIPE) 146 | output = proc.stdout.read().decode('utf-8') 147 | print("DB:") 148 | e("host:{}".format(output)) 149 | 150 | def public(): 151 | if is_swoole_enable(): 152 | print("Currently you are configured in swoole mode.") 153 | print("You should go back to normal mode to enable public default folder.") 154 | exit(); 155 | copyfile("{}/samples/nginx/public-default.conf".format(basepath), "{}/etc/public-default.conf".format(basepath)) 156 | print("cp samples/nginx/public-default.conf etc/ \n command has been issued.") 157 | 158 | def web_ports(): 159 | container_name = get_container_name("web") 160 | if(container_name == "" ): 161 | print("web is not running.") 162 | return 163 | 164 | command=["docker","inspect","--format='{{(index (index .NetworkSettings.Ports \"80/tcp\") 0).HostPort}}'", container_name] 165 | proc = subprocess.Popen(command ,shell=False, stdout=subprocess.PIPE) 166 | http_port = int(remove_quotes(proc.stdout.read())) 167 | print("WEB:") 168 | is_enable_defualt=0 169 | for file_or_dir in os.listdir("{}/sites".format(basepath)): 170 | if(os.path.isdir("sites/{}".format(file_or_dir))): 171 | if(http_port==80): 172 | if(file_or_dir!="default"): 173 | print("http://{}.test".format(file_or_dir)) 174 | else: 175 | is_enable_default=1 176 | else: 177 | if(file_or_dir!="default"): 178 | print("http://{}.test:{}".format(file_or_dir, http_port)) 179 | else: 180 | is_enable_default=1 181 | if(is_enable_default==1): 182 | print("\nDefault folder exist") 183 | print("http://localhost or http://your_ip_address") 184 | 185 | def info(): 186 | db_ports() 187 | web_ports() 188 | 189 | def ext(): 190 | output = run(dockerCompose()+["exec","php","php","-i"]) 191 | obj = re.search("^extension_dir(.+)", output, re.I | re.M) 192 | lines = obj.group(1).split('=>') 193 | extension_dir=lines[1] 194 | e(run(dockerCompose()+["exec","php","ls",extension_dir.strip()])) 195 | 196 | def reload(): 197 | output = run(dockerCompose()+["exec","web","nginx","-s","reload"]).decode('utf-8') 198 | e(output) 199 | 200 | def remove_quotes(v): 201 | return re.sub("'", "", v.decode('utf8')) 202 | 203 | def normal(): 204 | try: 205 | os.symlink("{}/docker-compose-normal.yml".format(basepath),"{}/docker-compose.yml".format(basepath)) 206 | except: 207 | os.remove("{}/docker-compose.yml".format(basepath)) 208 | os.symlink("{}/docker-compose-normal.yml".format(basepath),"{}/docker-compose.yml".format(basepath)) 209 | restart(); 210 | def is_swoole_enable(): 211 | f = "{}/etc/default.conf".format(basepath) 212 | for line in open(f).readlines(): 213 | if re.match(".+laravels.+", line): 214 | return True 215 | return False 216 | 217 | def swoole(): 218 | if os.path.isdir("{}/sites/default".format(basepath)) == False: 219 | print("The default project not found") 220 | exit() 221 | 222 | if os.path.isfile("{}/sites/default/bin/laravels".format(basepath)) == False: 223 | msg=""" Laravel-S not found 224 | To install laravel-s, You can do something like this below: 225 | In D-laravel folder: 226 | step 1: go to the default folder. 227 | cd sites/default 228 | step 2: install laravel-s package by alias command. 229 | ce require "hhxsv5/laravel-s:~3.5.0" -vvv 230 | setp 3: laravels publish by alias command. 231 | a laravels publish""" 232 | print(msg) 233 | exit() 234 | 235 | if is_swoole_enable() and os.path.isfile("{}/etc/public-default.conf".format(basepath)): 236 | print("You should remove etc/public-default.conf to enable swoole mode.") 237 | exit() 238 | 239 | try: 240 | os.symlink("{}/docker-compose-swoole.yml".format(basepath),"{}/docker-compose.yml".format(basepath)) 241 | except: 242 | print("execpt") 243 | os.remove("{}/docker-compose.yml".format(basepath)) 244 | os.symlink("{}/docker-compose-swoole.yml".format(basepath),"{}/docker-compose.yml".format(basepath)) 245 | src=basepath+"/samples/php/swoole.ini"; 246 | dst=basepath+"/etc/php/swoole.ini"; 247 | copyfile(src, dst) 248 | src=basepath+"/etc/swoole.sample"; 249 | dst=basepath+"/etc/default.conf"; 250 | copyfile(src, dst) 251 | restart(); 252 | 253 | def random(): 254 | try: 255 | os.symlink("{}/docker-compose-random.yml".format(basepath),"{}/docker-compose.yml".format(basepath)) 256 | except: 257 | os.remove("{}/docker-compose.yml".format(basepath)) 258 | os.symlink("{}/docker-compose-random.yml".format(basepath),"{}/docker-compose.yml".format(basepath)) 259 | restart(); 260 | 261 | def custom(): 262 | try: 263 | os.symlink("{}/docker-compose-custom.yml".format(basepath),"{}/docker-compose.yml".format(basepath)) 264 | except: 265 | os.remove("{}/docker-compose.yml".format(basepath)) 266 | os.symlink("{}/docker-compose-normal.yml".format(basepath),"{}/docker-compose.yml".format(basepath)) 267 | restart(); 268 | 269 | def execute(args): 270 | command = dockerCompose()+args 271 | subprocess.call(command) 272 | 273 | def logs(service=[]): 274 | if(len(service)==0): 275 | command = dockerCompose()+["logs"] 276 | else: 277 | command = dockerCompose()+["logs"]+service 278 | try: 279 | subprocess.call(command) 280 | except: 281 | pass 282 | 283 | def mysql(): 284 | command = dockerCompose()+["exec", "db", "env"] 285 | output = run(command) 286 | obj=re.search("MYSQL_ROOT_PASSWORD=(.*)",output, re.I | re.M) 287 | #password = obj.group(1) 288 | if(obj): 289 | command = dockerCompose()+["exec","db","mysql","-uroot","-p"] 290 | else: 291 | command = dockerCompose()+["exec","db","mysql","-uroot"] 292 | subprocess.call(command) 293 | 294 | def secure(): 295 | if(system == "Darwin"): 296 | projects = get_projects_count(); 297 | if(projects == 0): 298 | msg = """No Projects are found, you can create one by following command. 299 | For example as below: 300 | ./create [project name] 301 | or 302 | To manually create new default project: 303 | mkdir -p sites/default/public;touch sites/default/public/index.php""" 304 | print(msg) 305 | exit() 306 | copyfile("{}/etc/default-ssl.sample".format(basepath), "{}/etc/default-ssl.conf".format(basepath)) 307 | copyfile("{}/etc/v3.sample".format(basepath), "{}/etc/v3.ext".format(basepath)) 308 | 309 | count=0 310 | with open("{}/etc/v3.ext".format(basepath), 'a') as v3_file: 311 | for project_name in get_sites(): 312 | count+=1 313 | v3_file.write("DNS.{}=www.{}.test\n".format(count, project_name)) 314 | count+=1 315 | v3_file.write("DNS.{}={}.test\n".format(count, project_name)) 316 | 317 | command = ["security","find-certificate","-c","\"dlaravel.test\"", 318 | "-a","-Z","|","sudo","|","awk" ,"'/SHA-1/{system(\"security delete-certificate -Z \"$NF)}'"] 319 | subprocess.call(command) 320 | 321 | command = ["openssl","req","-new","-newkey","rsa:2048","-sha256", 322 | "-days","3650","-nodes","-x509", 323 | "-keyout","{}/etc/ssl/cert.key".format(basepath), 324 | "-out","{}/etc/ssl/cert.crt".format(basepath), 325 | "-config","{}/etc/v3.ext".format(basepath),"-extensions","v3_req"] 326 | subprocess.call(command) 327 | 328 | command = ["sudo","security","add-trusted-cert","-d","-r","trustRoot","-k","/Library/Keychains/System.keychain","{}/etc/ssl/cert.crt".format(basepath)] 329 | subprocess.call(command) 330 | 331 | reload() 332 | 333 | else: 334 | print("This feature for OSX user only.") 335 | 336 | def link(): 337 | command=["ls","-l","{}/docker-compose.yml".format(basepath)] 338 | e(run(command)) 339 | 340 | def chowner(): 341 | if(system=="Linux"): 342 | whoami = run(["whoami"]).strip("\n") 343 | 344 | dlaravel_uid = run(["id","-u",whoami]) 345 | dlaravel_gid = run(["id","-g",whoami]) 346 | command = dockerCompose()+["exec","php","usermod","-u",dlaravel_uid.strip('\n'),"dlaravel"] 347 | subprocess.call(command) 348 | command = dockerCompose()+["exec","php","groupmod","-g",dlaravel_gid.strip('\n'),"dlaravel"] 349 | subprocess.call(command) 350 | command = dockerCompose()+["exec","php","chown","-R",dlaravel_uid.strip('\n'),"/home/dlaravel"] 351 | subprocess.call(command) 352 | msg ="""You have to commit your php fpm image, and restart container. 353 | Example: docker commit 67306ecd0879 deviny/fpm:7.1.9 354 | ./console restart""" 355 | print(msg) 356 | 357 | 358 | def clear(): 359 | if(major==3): 360 | ans = input("Would You like to stop / remove all Docker containers?(y/n)") 361 | else: 362 | ans = raw_input("Would You like to stop / remove all Docker containers?(y/n)") 363 | if(ans.lower() == 'y'): 364 | command = ["docker","ps","-qa"] 365 | containers = run(command).decode('utf-8').split('\n') 366 | for container_id in containers: 367 | if(container_id!=""): 368 | command = ["docker","rm","-f",container_id] 369 | subprocess.call(command) 370 | else: 371 | exit() 372 | 373 | def help(): 374 | l=locale.getdefaultlocale()[0] 375 | msg=""" 376 | usage: {} [] 377 | options: 378 | """.format(sys.argv[0]) 379 | print(msg) 380 | if(l=="zh_TW"): 381 | msg=""" up : 建立並啟動container。 382 | down : 停止並移除container。 383 | restart : 停止再啟動down and up,不明怪問題時應該有用 384 | ps : Lists Contaienrs. (docker-compose -f ${base_path}/docker-compose.yml ps) 385 | alias : 顯示consle的別名指令 386 | logs : container service的log, 用Ctrl+C中斷 387 | info : 列出web及db在host的連接埠。 388 | mysql : 快速進入mysql 389 | link : 目前docker-compose 連結的設定檔 390 | secure: 加入https設定檔 391 | normal : 變更docker-compose連結,讓docker使用標準連結埠,80:443:3306 392 | random : 變更docker-compose連結,讓docker啟用隨機的連接埠,可用./console ps查看 393 | custom : 變更docker-compose連結,產生或使用自定的設定檔 394 | exec : 執行php container內的命令,例如: ./console exec php php -v 395 | reload : 重載nginx的設定. 396 | node: 會執行node容器,並且掛載/sites資料夾。 397 | ext: 列出目前fpm可用的php exteinsions,自訂檔名新增.ini檔到etc/php下即可啟用哦。 398 | public: 使用預設目錄 sites/default/public。 399 | chowner: D-Laravel的使用者uid及gid在容器內預設為1000,在linux環境中,您可能需要調整dlaravel的uid與gid與您的目前使用者相同 400 | clear : 移除所有docker ps -a 所有停止的Container!!包含您自己過去創建的所有停止的container哦!! 401 | ./console : 進入php container內 402 | version : 顯示目前的版本. 403 | """ 404 | print(msg) 405 | else: 406 | msg=""" up : Run containers in the background. 407 | down : Stop and remove containers, networks. 408 | restart : Restart services. 409 | ps : Lists Contaienrs. (docker-compose -f ${base_path}/docker-compose.yml ps) 410 | alias : Display console's alias setting. 411 | logs : service's log, ctrl+c to stop. 412 | info : list webs and port of database. 413 | mysql : Enter mysql interactive mode. 414 | link : Display current link of docker-compose file. 415 | secure: Add self-signed ceftifiecate, to enable https support. 416 | normal : change docker-compose.yal link to docker-compose-normal.yml, for using ports 80:443:3306 417 | random : change docker-compose.yml link to docker-compose-random.yml,for using random ports,you can check issue ./console ps 418 | custom : change docker-compose.yml link link to docker-compose-custom.yml, for custom purpose. 419 | exec : exec php container's command, for example: ./console exec php php -v 420 | reload : nginx reload config file. 421 | node: run nodejs container, and mount /sites folder. 422 | ext: list php extensions. 423 | public: using default folder. sites/default/public. 424 | chowner: D-Laravel users uid and gid are 1000 in container, in the linux environment, you may need to adjust D-Laravel uid and gid with your current user the same. 425 | clear : Remove all your containers that listed by docker ps -a !! 426 | ./console : Enter php container. 427 | version : Display current version. 428 | 429 | I'm not native speaker in English, please feel free to send me a PR to fix the help. 430 | """ 431 | print(msg) 432 | 433 | def version(): 434 | file = open("{}/etc/dlaravel-release".format(basepath), "r") 435 | e(file.read()) 436 | 437 | def alias(): 438 | print("alias c={}/console".format(basepath)) 439 | 440 | def dlaravel_new(parameter): 441 | value=dot_env_install() 442 | if(os.path.isdir("{}/sites/{}".format(basepath,parameter))): 443 | print("The sites/{} folder exists.".format(parameter)) 444 | exit() 445 | if(value=="host"): 446 | print("Run laravel installer on host: laravel new {}".format(parameter)) 447 | command=["laravel","new","sites/{}".format(parameter)] 448 | print(command) 449 | subprocess.call(command) 450 | else: 451 | print("Run laravel installer in container: laravel new {}".format(parameter)) 452 | command=dockerCompose()+["exec","-u","dlaravel","php","/home/dlaravel/.composer/vendor/bin/laravel","new",parameter] 453 | print(command) 454 | subprocess.call(command) 455 | 456 | def dlaravel_config(parameter): 457 | #更新.env設定連線 458 | command=dockerCompose()+["exec","-u","dlaravel","php","sed","-i","s/DB_HOST=127.0.0.1/DB_HOST=db/","/var/www/html/{}/.env".format(parameter)] 459 | proc = subprocess.Popen(command ,shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 460 | 461 | output,error = proc.communicate() 462 | proc.wait() 463 | exit_code=proc.poll() 464 | 465 | if(exit_code==0): 466 | print("Update the sites/{}/.env file of the project.".format(parameter)) 467 | output = proc.stdout.read().decode('utf-8') 468 | else: 469 | print("Unable to update the sites/{}/.env file of the project.".format(parameter)) 470 | exit() 471 | 472 | 473 | command=dockerCompose()+["exec","-u","dlaravel","php","sed","-i","s/DB_DATABASE=homestead/DB_DATABASE={}/".format(parameter),"/var/www/html/{}/.env".format(parameter)] 474 | proc = subprocess.Popen(command ,shell=False, stdout=subprocess.PIPE) 475 | output = proc.stdout.read().decode('utf-8') 476 | command=dockerCompose()+["exec","-u","dlaravel","php","sed","-i","s/DB_USERNAME=homestead/DB_USERNAME={}/".format(parameter),"/var/www/html/{}/.env".format(parameter)] 477 | proc = subprocess.Popen(command ,shell=False, stdout=subprocess.PIPE) 478 | output = proc.stdout.read().decode('utf-8') 479 | command=dockerCompose()+["exec","-u","dlaravel","php","sed","-i","s/DB_PASSWORD=secret/DB_PASSWORD={}/".format(parameter),"/var/www/html/{}/.env".format(parameter)] 480 | proc = subprocess.Popen(command ,shell=False, stdout=subprocess.PIPE) 481 | output = proc.stdout.read().decode('utf-8') 482 | 483 | def create_host(project): 484 | fname="/etc/hosts" 485 | lines = open(fname, "r").readlines() 486 | found = 0 487 | for line in lines: 488 | if(re.search("^(127.0.0.1)\\s+(www.)?(.+).test$", line, re.I | re.M)): 489 | #移除斷行 490 | result = re.sub("(^127.0.0.1)\\s+(www.)?(.+).test", "\\3", line.rstrip()) 491 | #print("[{}]".format(result)) 492 | if(result == project): 493 | found = 1 494 | if(found == 0): 495 | command=["sudo","python","{}/scripts/update_hosts.py".format(basepath), project] 496 | subprocess.call(command) 497 | 498 | def create_db(project): 499 | command=["docker-compose","exec","db","mysql","-e","CREATE DATABASE IF NOT EXISTS `{}`".format(project)] 500 | subprocess.call(command) 501 | command=["docker-compose","exec","db","mysql","-e","CREATE USER IF NOT EXISTS \"{}\"".format(project,project)] 502 | subprocess.call(command) 503 | command=["docker-compose","exec","db","mysql","-e","SET PASSWORD FOR `{}`=\"{}\"".format(project,project)] 504 | subprocess.call(command) 505 | command=["docker-compose","exec","db","mysql","-e","GRANT ALL ON `{}`.* TO \"{}\"".format(project,project)] 506 | subprocess.call(command) 507 | command=["docker-compose","exec","db","mysql","-e","FLUSH PRIVILEGES"] 508 | subprocess.call(command) 509 | 510 | 511 | --------------------------------------------------------------------------------
45 | ./console help (幫助,console參數用法。) 46 | ./create test1 (建立test1.test) 47 | ./console down或./console up (啟用及停用container) 48 | ./console restart (./console down再./console up) 49 | `./console alias` 50 | (打./console指令太長了嗎,上方指令可暫時用c代表./console,所以執行後,輸入:c info、c up或c down..即可執行。) 51 | ./console alias (印出console的別名範本,自行加到.bashrc或.zshrc永久生效) 52 | ./console version (顯示D-Laravel的版本) 53 | 54 | 產生自我簽署憑證給目前所有的Project. (MacOS or Linux)。 55 | ./console secure 56 |
60 | etc/ (nginx、php.ini及mysql的相關設定檔) 61 | data/ (mysql的資料檔案,./console up 自動生成) 62 | dockerfiles/ (放置一些dockerfile,需要時重build自已的image使用) 63 | logs/ (用來掛載及放置服務的紀錄) 64 | service/ (放置擴充用的yml檔) 65 | sites/ (專案的資夾,例如./create blog時,會建立在這個此目錄下) 66 | samples/ (一些設定範本,例如: php.ini及一些額外的docker-compose yaml檔設定) 67 | create (簡化的bash,用來快速的建立laravel的專案) 68 | console(簡化的bash,用來快速使用各種docker-compose的命令。例如:./console mysql即可進入mysql) 69 | docker-compose.yml (一個softlink,連結到不同的設定檔,例如:./console custom,即何將連結連到docker-compose-custom.yml) 70 |
82 | $docker version 83 | Client: 84 | Version: 18.06.0-ce 85 | API version: 1.38 86 | Go version: go1.10.3 87 | Git commit: 0ffa825 88 | Built: Wed Jul 18 19:05:26 2018 89 | OS/Arch: darwin/amd64 90 | Experimental: false 91 | 92 | Server: 93 | Engine: 94 | Version: 18.06.0-ce 95 | API version: 1.38 (minimum version 1.12) 96 | Go version: go1.10.3 97 | Git commit: 0ffa825 98 | Built: Wed Jul 18 19:13:46 2018 99 | OS/Arch: linux/amd64 100 | Experimental: true 101 |
104 | Mac OS系統: 105 | https://docs.docker.com/docker-for-mac/ 106 | 107 | Ubuntu: 108 | https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#install-docker-ce 109 | 110 | Windows 10: 111 | https://docs.docker.com/docker-for-windows/install/ 112 | gitbash環境 (console及create需在gitbash環境執行,並且gitbash需可正確執行laravel installer!!) 113 | 114 |
126 | https://docs.docker.com/compose/install/ 127 |
131 | git clone https://github.com/DevinY/dlaravel.git 132 | cd dlaravel 133 |
137 | 例如: (第一次執行會自動下載所需的Image,需較長的時間) 138 | ./create test1 139 | 140 | 那麼就會建立出 http://test1.test 網站(本機測試用的外部無法存取)。 141 | 可以建立多個project站台 142 | 143 | 由於create的bash需有系統權修改/etc/hosts檔,./create的過程中會需要詢問您的系統密碼: 144 | create指令、可在Mac OS、Linux及Windows 10的gitbash(Laravel installer)環境使用。 145 |
150 | 注意事項: 這個只是拿來開發測試用的,Mysql的root是沒有密碼的。 151 | 你可能需要修改docker-compose.yml啟動時的TZ,目前設為Asia/Taipei 152 |
156 | git pull 157 | 158 | 在d-laravel的.gitignore已排除了會變動的區域了,例如: docker-compose.yml、docker-compse-custom.yml, sites專案資料夾等。 159 | 所以在dlaravel的目錄下,您可以透過git pull取得最新的版本及設定。 160 |
166 | ./console alias 167 |
174 | alias laravel='docker-compose exec -u dlaravel php /home/dlaravel/.composer/vendor/bin/laravel' 175 |
180 | alias ce="../../composer.sh" 181 |
187 | alias a="../../artisan.sh" 188 |
192 | alias phpunit='docker-compose -f ../../docker-compose.yml exec -u dlaravel php $(basename ${PWD})/vendor/bin/phpunit -c $(basename ${PWD})/phpunit.xml' 193 |
197 | ./create [project名稱] 會建立及下載laravel,搞定一切設定,包含資料庫, 198 | 但如果是一個已存在的Project,只需有nginx的設定,應該怎麼做呢? 199 | 200 | 使用--host 即可修改系統的/etc/hosts檔,加入project的域名,如: project1.test。 201 | ./create --host [project名稱] 例如:./create --host project1 202 | 203 | 可以將已存在的Laravel專案移到sites資料夾內。 204 | 205 | 或是使用composer create-project指令建立Project. 206 | 例如使用手動指令手動建立Project,這裡用lumen示範。 207 | ./console exec,可用於執行php contaiener內的命令 208 | 209 | ./console exec php composer create-project --prefer-dist laravel/lumen project1 210 |
215 | mage: deviny/fpm:7.3.5 216 | image: deviny/fpm:7.2.18 217 | image: deviny/fpm:7.1.29 218 | image: deviny/fpm:5.6.39 219 |
232 | db: 233 | image: mysql:8 234 | 略.. 235 | volumes: 236 | - ./etc/mysql/my.cnf:/etc/mysql/my.cnf 237 | - ./data_mysql8:/var/lib/mysql 238 |
244 | cd dockerfiles/fpm/7.2 245 | docker build -t myfpm . 246 |
251 | php: 252 | network_mode: "service:web" 253 | image: myfpm 254 |
49 | ./console help (help, console parameter) 50 | ./create test1 (build test1.test) 51 | ./console down or ./console up (stop or start container) 52 | ./console restart (first ./console down and then ./console up) 53 | `./console alias` 54 | (If you think ./console command is too log, you could create c alias in terminal which simplifies command to "c info", "c up", or "c down") 55 | ./console alias (print console alias samples, it can be added to .bashrc or .zshrc) 56 | ./console version 57 | 58 | Generate self-signed certificate for all current projects. (MacOS and Linux) 59 | ./console secure 60 |
65 | etc/ (nginx、php.ini and mysql settings) 66 | data/ (mysql data files, auto-generated by ./console up) 67 | dockerfiles/ (some dockerfiles) 68 | sites/ (project files, the project will be set in this folder when executes ./create test1) 69 | create (Simplified bash, to fast build laravel project) 70 | console (Simplified bash file, to use kinds of docker-compose commands. ex. login mysql by "./console mysql") 71 | docker-compose.yml (A soft link to connect different settings. ex. linking to docker-compose-custom.yml by "./console custom") 72 |
77 | Mac OS: 78 | https://docs.docker.com/docker-for-mac/ 79 | 80 | Ubuntu: 81 | https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#install-docker-ce 82 | 83 | Windows 10: (required for laravel install in gitbash!!) 84 | https://docs.docker.com/docker-for-windows/install/ 85 | 86 | To run console and create bash on Windows 10: 87 | Gitbash is required. 88 | Laravel installer have to run correctly in gitbash also. 89 |
94 | git clone https://github.com/DevinY/dlaravel.git 95 | cd dlaravel 96 | 97 | 98 | You can ignore below's pull command. It will auto download the images according to docker-compose.yml when initials. 99 | ./console pull 100 | The first time to download needed images from dockhub will take longer time. Be patient. :P 101 |
106 | ex. 107 | ./create test1 108 | It will build http://test1.test website (can't be accessed from outside) 109 | So you can use this command to build many different projects. 110 | 111 | You need to provide privilege to modify /etc/hosts file, so D-Laravel will ask for your systme password during executing "./create project". (Mac OS using only) 112 |
117 | Attention: 118 | D-Laravel is only used for development, Mysql root password is empty. 119 | You may need to revise TZ in docker-compose.yml, default is Asia/Taipei. 120 |
125 | git pull 126 | 127 | .gitignore in D-Laravel already excludes dynamic files, ex. docker-comnpose.yml, docker-compose-custom.yml, sites folder etc. 128 | You can git pull latest version and setting in D-Laravel folder. 129 |
135 | ./console alias 136 |
143 | alias laravel='docker-compose exec -u dlaravel php /home/dlaravel/.composer/vendor/bin/laravel' 144 |
148 | alias ce="../../composer.sh" 149 |
153 | alias a="../../artisan.sh" 154 |
157 | alias phpunit = 'docker-compose -f ../../docker-compose.yml exec -u dlaravel php $ (basename $ {PWD}) / vendor / bin / phpunit -c $ (basename $ {PWD}) / phpunit.xml ' 158 |
163 | ./create [project name] will create and build laravel, it would set all configures automatically including DB. 164 | But how do we do if project already exists and only needs nginx setting? 165 | 166 | Using "--host" to update /etc/hosts file, for example: "127.0.0.1 project1.test". 167 | ./create --host [project name] (./create --host project1) 168 | 169 | 170 | You can move exist Laravel project to D-Laravel site folder. 171 | 172 | Or manually executes "composer create-project" (not default version etc.) 173 | 174 | Ex. Create project manually by using lumen 175 | ./console exec //It can execute php command in container. 176 | 177 | ./console exec php composer create-project --prefer-dist laravel/lumen project1 178 |
185 | image: deviny/fpm:7.3.5 186 | image: deviny/fpm:7.2.18 187 | image: deviny/fpm:7.1.29 188 | image: deviny/fpm:5.6.39 189 |
201 | db: 202 | image: mysql:8 203 | ... 204 | volumes: 205 | - ./etc/mysql/my.cnf:/etc/mysql/my.cnf 206 | - ./data_mysql8:/var/lib/mysql 207 |
215 | cd dockerfiles/fpm/7.3 216 | docker build -t myfpm . 217 |
221 | php: 222 | network_mode: "service:web" 223 | image: myfpm 224 |