├── .env-example ├── .gitignore ├── README.md ├── aliases └── php71 │ └── bash.bashrc ├── docker-compose.yml ├── hosts ├── first.conf └── two.conf ├── images ├── hub │ └── Dockerfile ├── hub70 │ └── Dockerfile └── php71 │ ├── Dockerfile │ └── php.ini ├── logs └── .gitignore ├── mysql └── data │ └── .gitignore ├── remove.sh ├── up.sh └── www ├── .gitignore ├── first.loc ├── http.http └── index.php └── two.loc └── index.php /.env-example: -------------------------------------------------------------------------------- 1 | USER_ID=1000 2 | GROUP_ID=1000 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | 3 | .env 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Docker + php-fpm + PhpStorm + Xdebug 2 | 3 | Подробности на https://habr.com/ru/post/473184/ 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /aliases/php71/bash.bashrc: -------------------------------------------------------------------------------- 1 | # System-wide .bashrc file for interactive bash(1) shells. 2 | 3 | # To enable the settings / commands in this file for login shells as well, 4 | # this file has to be sourced in /etc/profile. 5 | 6 | # If not running interactively, don't do anything 7 | [ -z "$PS1" ] && return 8 | 9 | # check the window size after each command and, if necessary, 10 | # update the values of LINES and COLUMNS. 11 | shopt -s checkwinsize 12 | 13 | # set variable identifying the chroot you work in (used in the prompt below) 14 | if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then 15 | debian_chroot=$(cat /etc/debian_chroot) 16 | fi 17 | 18 | # set a fancy prompt (non-color, overwrite the one in /etc/profile) 19 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 20 | 21 | # Commented out, don't overwrite xterm -T "title" -n "icontitle" by default. 22 | # If this is an xterm set the title to user@host:dir 23 | #case "$TERM" in 24 | #xterm*|rxvt*) 25 | # PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' 26 | # ;; 27 | #*) 28 | # ;; 29 | #esac 30 | 31 | # enable bash completion in interactive shells 32 | #if ! shopt -oq posix; then 33 | # if [ -f /usr/share/bash-completion/bash_completion ]; then 34 | # . /usr/share/bash-completion/bash_completion 35 | # elif [ -f /etc/bash_completion ]; then 36 | # . /etc/bash_completion 37 | # fi 38 | #fi 39 | 40 | # if the command-not-found package is installed, use it 41 | if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then 42 | function command_not_found_handle { 43 | # check because c-n-f could've been removed in the meantime 44 | if [ -x /usr/lib/command-not-found ]; then 45 | /usr/lib/command-not-found -- "$1" 46 | return $? 47 | elif [ -x /usr/share/command-not-found/command-not-found ]; then 48 | /usr/share/command-not-found/command-not-found -- "$1" 49 | return $? 50 | else 51 | printf "%s: command not found\n" "$1" >&2 52 | return 127 53 | fi 54 | } 55 | fi 56 | 57 | alias cl='clear' 58 | 59 | alias ll='ls -alF' 60 | alias l='ls -la' 61 | alias cdf='cd /var/www/first.loc' 62 | alias cdt='cd /var/www/two.loc' 63 | 64 | 65 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | php71-first: 4 | build: 5 | context: ./images/php71 6 | args: 7 | - USER_ID 8 | - GROUP_ID 9 | volumes: 10 | - ./www:/var/www 11 | - ./aliases/php71/bash.bashrc:/etc/bash.bashrc 12 | environment: 13 | XDEBUG_CONFIG: "remote_host=192.168.220.1 remote_enable=1 remote_autostart=off remote_port=9008" 14 | PHP_IDE_CONFIG: "serverName=first" 15 | networks: 16 | - test-network 17 | php71-two: 18 | build: 19 | context: ./images/php71 20 | args: 21 | - USER_ID 22 | - GROUP_ID 23 | volumes: 24 | - ./www:/var/www 25 | - ./aliases/php71/bash.bashrc:/etc/bash.bashrc 26 | environment: 27 | XDEBUG_CONFIG: "remote_host=192.168.220.1 remote_enable=1 remote_autostart=off remote_port=9009" 28 | PHP_IDE_CONFIG: "serverName=two" 29 | networks: 30 | - test-network 31 | nginx-test: 32 | image: nginx 33 | volumes: 34 | - ./hosts:/etc/nginx/conf.d 35 | - ./www:/var/www 36 | - ./logs:/var/log/nginx 37 | ports: 38 | - "8080:80" 39 | depends_on: 40 | - php71-first 41 | - php71-two 42 | networks: 43 | test-network: 44 | aliases: # алиасы нужны если нужно общаться внутри сети между хостами. Например, если вы используете api 45 | - first.loc 46 | - two.loc 47 | # mysql: 48 | # image: mysql:5.7 49 | # ports: 50 | # - "3306:3306" 51 | # volumes: 52 | # - ./mysql/data:/var/lib/mysql 53 | # environment: 54 | # MYSQL_ROOT_PASSWORD: secret 55 | # networks: 56 | # - test-network 57 | networks: 58 | test-network: 59 | driver: bridge 60 | ipam: 61 | driver: default 62 | config: 63 | - subnet: 192.168.220.0/28 64 | -------------------------------------------------------------------------------- /hosts/first.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | index index.php; 4 | server_name first.loc; 5 | error_log /var/log/nginx/first_error.log; 6 | root /var/www/first.loc; 7 | 8 | location / { 9 | try_files $uri /index.php?$args; 10 | } 11 | 12 | location ~ \.php$ { 13 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 14 | # контейнер php-fpm 15 | fastcgi_pass php71-first:9000; 16 | fastcgi_index index.php; 17 | fastcgi_read_timeout 1000; 18 | include fastcgi_params; 19 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 20 | fastcgi_param PATH_INFO $fastcgi_path_info; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /hosts/two.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | index index.php; 4 | server_name two.loc; 5 | error_log /var/log/nginx/two_error.log; 6 | root /var/www/two.loc; 7 | 8 | location / { 9 | try_files $uri /index.php?$args; 10 | } 11 | 12 | location ~ \.php$ { 13 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 14 | fastcgi_pass php71-two:9000; 15 | fastcgi_index index.php; 16 | fastcgi_read_timeout 1000; 17 | include fastcgi_params; 18 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 19 | fastcgi_param PATH_INFO $fastcgi_path_info; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /images/hub/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.1-fpm 2 | 3 | RUN apt-get update && apt-get install -y \ 4 | git \ 5 | curl \ 6 | wget \ 7 | libfreetype6-dev \ 8 | libjpeg62-turbo-dev \ 9 | libmcrypt-dev \ 10 | libpng-dev zlib1g-dev libicu-dev g++ libmagickwand-dev --no-install-recommends libxml2-dev \ 11 | && docker-php-ext-configure intl \ 12 | && docker-php-ext-install intl \ 13 | && docker-php-ext-install mbstring zip xml gd mcrypt pdo_mysql \ 14 | && pecl install imagick \ 15 | && docker-php-ext-enable imagick \ 16 | && pecl install xdebug-2.5.0 \ 17 | && docker-php-ext-enable xdebug 18 | 19 | -------------------------------------------------------------------------------- /images/hub70/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.0-fpm 2 | 3 | RUN apt-get update && apt-get install -y \ 4 | git \ 5 | wkhtmltopdf xvfb \ 6 | curl \ 7 | wget \ 8 | libfreetype6-dev \ 9 | libjpeg62-turbo-dev \ 10 | libmcrypt-dev \ 11 | libpng-dev zlib1g-dev libicu-dev g++ libmagickwand-dev libxml2-dev \ 12 | && docker-php-ext-configure intl \ 13 | && docker-php-ext-install intl \ 14 | && docker-php-ext-install mbstring zip xml gd mcrypt pdo_mysql \ 15 | && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ 16 | && docker-php-ext-install -j$(nproc) gd \ 17 | && pecl install imagick \ 18 | && docker-php-ext-enable imagick \ 19 | && pecl install xdebug \ 20 | && docker-php-ext-enable xdebug 21 | -------------------------------------------------------------------------------- /images/php71/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM composer:latest AS composer 2 | FROM ale10257/php7.1-fpm 3 | 4 | COPY --from=composer /usr/bin/composer /usr/bin/composer 5 | 6 | ARG USER_ID 7 | ARG GROUP_ID 8 | 9 | ADD ./php.ini /usr/local/etc/php/php.ini 10 | 11 | #RUN wget https://getcomposer.org/installer -O - -q | php -- --install-dir=/bin --filename=composer --quiet 12 | 13 | RUN usermod -u ${USER_ID} www-data && groupmod -g ${GROUP_ID} www-data 14 | 15 | WORKDIR /var/www 16 | 17 | USER "${USER_ID}:${GROUP_ID}" 18 | 19 | CMD ["php-fpm"] 20 | -------------------------------------------------------------------------------- /images/php71/php.ini: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /mysql/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /remove.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q) && docker rmi $(docker images -a -q) 4 | -------------------------------------------------------------------------------- /up.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker-compose up 4 | -------------------------------------------------------------------------------- /www/.gitignore: -------------------------------------------------------------------------------- 1 | .composer/ 2 | .bash_history 3 | -------------------------------------------------------------------------------- /www/first.loc/http.http: -------------------------------------------------------------------------------- 1 | POST http://two.loc:8080/ 2 | Content-Type: application/json 3 | 4 | {} 5 | 6 | ### -------------------------------------------------------------------------------- /www/first.loc/index.php: -------------------------------------------------------------------------------- 1 |