Skip to content

Commit

Permalink
Merge pull request #6 from andrzejenne/master
Browse files Browse the repository at this point in the history
xdebug, mailhog, php-fpm dockerfile fixes
  • Loading branch information
ironexdev authored Mar 16, 2022
2 parents 87d90ce + 847015e commit fa1eb74
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 19 deletions.
2 changes: 2 additions & 0 deletions bin/variables
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ export DOCKER_IMAGE_FOLDER="images" # used in Dockerfiles as relative path to th
export MAGENTO_DIRECTORY=${APP_DIRECTORY}/magento

export NUXT_DIRECTORY=${APP_DIRECTORY}/nuxt

export CLI_XDEBUG_SERVER_NAME=magento.local
13 changes: 2 additions & 11 deletions bin/xdebug/cli
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,10 @@
cd ${DOCKER_DIRECTORY}

if [ -z $1 ]
then echo "First argument has to be relative path (magento/<FILE_PATH>) to target file";
then echo "First argument has to be relative path (<FILE_PATH>) to target file";
exit;
else
FILE_PATH=$1
fi

if [ -z $2 ]
then
SERVER_NAME="magento.local"
else
SERVER_NAME=$2
fi

bin/run/php-fpm sh -c "export XDEBUG_SESSION=1 && export PHP_IDE_CONFIG=\"serverName=$SERVER_NAME\" && php magento/$FILE_PATH"
docker-compose exec -e XDEBUG_SESSION=1 -e PHP_IDE_CONFIG="serverName=$CLI_XDEBUG_SERVER_NAME" php-fpm "$@"

cd ${APP_DIRECTORY}
13 changes: 7 additions & 6 deletions bin/xdebug/mode
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@
# trace
# - Enables the Function Trace feature, which allows you record every function call, including arguments, variable assignment, and return value that is made during a request to a file.

if [ $(uname) == "Darwin" ]
cd ${DOCKER_DIRECTORY}

if [ $(uname) = "Darwin" ]
then
sed -i '' "s/xdebug.mode=.*/xdebug.mode=$1/g" ${DOCKER_DIRECTORY}/images/php-fpm/php.ini
docker-compose exec php-fpm sed -i '' "s/xdebug.mode=.*/xdebug.mode=$1/g" /usr/local/etc/php/php.ini
else
sed -i "s/xdebug.mode=.*/xdebug.mode=$1/g" ${DOCKER_DIRECTORY}/images/php-fpm/php.ini
docker-compose exec php-fpm sed -i "s/xdebug.mode=.*/xdebug.mode=$1/g" /usr/local/etc/php/php.ini
fi

cd ${DOCKER_DIRECTORY}

docker-compose restart php-fpm
echo "reloading php-fpm configuration"
docker-compose exec php-fpm kill -USR2 1

cd ${APP_DIRECTORY}
6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ services:
networks:
- external
- internal
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- $MAGENTO_DIRECTORY:/home/dockeruser/magento
- $DOCKER_DIRECTORY/images/php-fpm/php.ini:/usr/local/etc/php/php.ini
- $DOCKER_DIRECTORY/images/php-fpm/custom-php.ini:/usr/local/etc/php/conf.d/custom-php.ini
- $DOCKER_DIRECTORY/images/php-fpm/.composer:/home/dockeruser/.composer

node:
Expand Down Expand Up @@ -54,6 +56,7 @@ services:
- kibana
- rabbitmq
- redis-admin
- mailhog
networks:
- external
ports:
Expand Down Expand Up @@ -196,6 +199,7 @@ services:
container_name: docker-magento_mailhog
networks:
- internal
- external

networks:
internal:
Expand Down
11 changes: 11 additions & 0 deletions images/nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ server {
}
}

server {
server_name "mailhog.magento.local";

listen 8080;
listen [::]:8080;

location / {
proxy_pass http://mailhog:8025;
}
}

server {
server_name "nuxt.magento.local";

Expand Down
4 changes: 3 additions & 1 deletion images/php-fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ RUN addgroup -g $GROUP_ID -S dockeruser

RUN adduser -S -G dockeruser -u $USER_ID -s /bin/ash dockeruser

RUN chown -R dockeruser: /usr/local/etc/php

USER dockeruser

WORKDIR /home/dockeruser
WORKDIR /home/dockeruser/magento

EXPOSE 9000
1 change: 1 addition & 0 deletions images/php-fpm/custom-php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; php.ini customization, feel free to edit
5 changes: 5 additions & 0 deletions images/php-fpm/php.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
; do not edit, used during image build
[php]
memory_limit = 2G
max_execution_time = 1800
zlib.output_compression = On
Expand All @@ -12,3 +14,6 @@ xdebug.mode=off
xdebug.client_host="host.docker.internal"
xdebug.start_with_request=yes
xdebug.discover_client_host = 1

[mail]
sendmail_path = /usr/sbin/sendmail -S mailhog:1025

0 comments on commit fa1eb74

Please sign in to comment.