Skip to content

Commit fa1eb74

Browse files
authored
Merge pull request #6 from andrzejenne/master
xdebug, mailhog, php-fpm dockerfile fixes
2 parents 87d90ce + 847015e commit fa1eb74

File tree

8 files changed

+36
-19
lines changed

8 files changed

+36
-19
lines changed

bin/variables

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ export DOCKER_IMAGE_FOLDER="images" # used in Dockerfiles as relative path to th
1212
export MAGENTO_DIRECTORY=${APP_DIRECTORY}/magento
1313

1414
export NUXT_DIRECTORY=${APP_DIRECTORY}/nuxt
15+
16+
export CLI_XDEBUG_SERVER_NAME=magento.local

bin/xdebug/cli

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,10 @@
55
cd ${DOCKER_DIRECTORY}
66

77
if [ -z $1 ]
8-
then echo "First argument has to be relative path (magento/<FILE_PATH>) to target file";
8+
then echo "First argument has to be relative path (<FILE_PATH>) to target file";
99
exit;
10-
else
11-
FILE_PATH=$1
1210
fi
1311

14-
if [ -z $2 ]
15-
then
16-
SERVER_NAME="magento.local"
17-
else
18-
SERVER_NAME=$2
19-
fi
20-
21-
bin/run/php-fpm sh -c "export XDEBUG_SESSION=1 && export PHP_IDE_CONFIG=\"serverName=$SERVER_NAME\" && php magento/$FILE_PATH"
12+
docker-compose exec -e XDEBUG_SESSION=1 -e PHP_IDE_CONFIG="serverName=$CLI_XDEBUG_SERVER_NAME" php-fpm "$@"
2213

2314
cd ${APP_DIRECTORY}

bin/xdebug/mode

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@
2727
# trace
2828
# - 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.
2929

30-
if [ $(uname) == "Darwin" ]
30+
cd ${DOCKER_DIRECTORY}
31+
32+
if [ $(uname) = "Darwin" ]
3133
then
32-
sed -i '' "s/xdebug.mode=.*/xdebug.mode=$1/g" ${DOCKER_DIRECTORY}/images/php-fpm/php.ini
34+
docker-compose exec php-fpm sed -i '' "s/xdebug.mode=.*/xdebug.mode=$1/g" /usr/local/etc/php/php.ini
3335
else
34-
sed -i "s/xdebug.mode=.*/xdebug.mode=$1/g" ${DOCKER_DIRECTORY}/images/php-fpm/php.ini
36+
docker-compose exec php-fpm sed -i "s/xdebug.mode=.*/xdebug.mode=$1/g" /usr/local/etc/php/php.ini
3537
fi
3638

37-
cd ${DOCKER_DIRECTORY}
38-
39-
docker-compose restart php-fpm
39+
echo "reloading php-fpm configuration"
40+
docker-compose exec php-fpm kill -USR2 1
4041

4142
cd ${APP_DIRECTORY}

docker-compose.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ services:
1616
networks:
1717
- external
1818
- internal
19+
extra_hosts:
20+
- "host.docker.internal:host-gateway"
1921
volumes:
2022
- $MAGENTO_DIRECTORY:/home/dockeruser/magento
21-
- $DOCKER_DIRECTORY/images/php-fpm/php.ini:/usr/local/etc/php/php.ini
23+
- $DOCKER_DIRECTORY/images/php-fpm/custom-php.ini:/usr/local/etc/php/conf.d/custom-php.ini
2224
- $DOCKER_DIRECTORY/images/php-fpm/.composer:/home/dockeruser/.composer
2325

2426
node:
@@ -54,6 +56,7 @@ services:
5456
- kibana
5557
- rabbitmq
5658
- redis-admin
59+
- mailhog
5760
networks:
5861
- external
5962
ports:
@@ -196,6 +199,7 @@ services:
196199
container_name: docker-magento_mailhog
197200
networks:
198201
- internal
202+
- external
199203

200204
networks:
201205
internal:

images/nginx/default.conf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ server {
5252
}
5353
}
5454

55+
server {
56+
server_name "mailhog.magento.local";
57+
58+
listen 8080;
59+
listen [::]:8080;
60+
61+
location / {
62+
proxy_pass http://mailhog:8025;
63+
}
64+
}
65+
5566
server {
5667
server_name "nuxt.magento.local";
5768

images/php-fpm/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ RUN addgroup -g $GROUP_ID -S dockeruser
5454

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

57+
RUN chown -R dockeruser: /usr/local/etc/php
58+
5759
USER dockeruser
5860

59-
WORKDIR /home/dockeruser
61+
WORKDIR /home/dockeruser/magento
6062

6163
EXPOSE 9000

images/php-fpm/custom-php.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
; php.ini customization, feel free to edit

images/php-fpm/php.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
; do not edit, used during image build
2+
[php]
13
memory_limit = 2G
24
max_execution_time = 1800
35
zlib.output_compression = On
@@ -12,3 +14,6 @@ xdebug.mode=off
1214
xdebug.client_host="host.docker.internal"
1315
xdebug.start_with_request=yes
1416
xdebug.discover_client_host = 1
17+
18+
[mail]
19+
sendmail_path = /usr/sbin/sendmail -S mailhog:1025

0 commit comments

Comments
 (0)