Skip to content

Commit ed883a6

Browse files
authored
7 move xdebugini out of container (#8)
* Create xdebug.ini * Update Dockerfile * Update compose.yaml * typo * Update README.md * Update README.md
1 parent 9f35f33 commit ed883a6

File tree

4 files changed

+18
-24
lines changed

4 files changed

+18
-24
lines changed

Dockerfile

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ FROM php:8.3.12-apache as final
55

66
# We're going to use this path multile times. So save it in a variable.
77
ARG UPLOADS_INI="/usr/local/etc/php/conf.d/uploads.ini"
8-
ARG XDEBUG_INI="/usr/local/etc/php/conf.d/xdebug.ini"
98

109
# enable Rewrites and setup mysqli, pdo, and xdebug
1110
RUN a2enmod rewrite \
@@ -21,14 +20,6 @@ RUN a2enmod rewrite \
2120
#
2221
# Install and enable xdebug. Check PHP version compatibility! (https://xdebug.org/docs/compat#versions)
2322
&& pecl install xdebug-3.4.1 \
24-
&& docker-php-ext-enable xdebug \
25-
#
26-
# Move production php.ini and configure xdebug
27-
&& { \
28-
echo "xdebug.mode = debug"; \
29-
echo "xdebug.client_host = host.docker.internal"; \
30-
echo "xdebug.start_with_request = trigger"; \
31-
echo "xdebug.log = /dev/stdout"; \
32-
} > ${XDEBUG_INI}
23+
&& docker-php-ext-enable xdebug
3324

3425
USER www-data

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
### create develop network
1212

13-
Adapt `.env` to set the network name and than create the network if not already done
13+
Adapt `.env` to set the project and network name and than create the network if not already done
1414

1515
```sh
1616
docker network create network-name-here
@@ -23,6 +23,8 @@ When you're ready, start your application by running:
2323

2424
## Setup xdebug launch.json
2525

26+
The `xdebug.ini` file sits in the root. After changing make sure to restart the webserver!
27+
2628
* Install xdebug extension
2729
* create launch.json (open the xdebug tab and click "create a launch.json file" )
2830
* add thist to the configurations section in the launnch.json file (for instance just below the port: 9003 section)

compose.yaml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
1-
# Comments are provided throughout this file to help you get started.
2-
# If you need more help, visit the Docker Compose reference guide at
3-
# https://docs.docker.com/go/compose-spec-reference/
41

5-
# Here the instructions define your application as a service called "server".
6-
# This service is built from the Dockerfile in the current directory.
7-
# You can add other services your application may depend on here, such as a
8-
# database or a cache. For examples, see the Awesome Compose repository:
9-
# https://github.com/docker/awesome-compose
10-
name: ${PROEJECT_NAME}
2+
name: ${PROJECT_NAME}
113
networks:
124
default:
135
name: ${NETWORK_NAME}
146

157
services:
168
server:
17-
container_name: ${PROJECT_NAME}
9+
container_name: ${PROJECT_NAME}-web
1810

1911
build:
2012
context: .
13+
restart: on-failure
2114
ports: ["9080:80"]
22-
volumes: ["../htdocs/:/var/www/html"]
15+
volumes:
16+
- ../htdocs/:/var/www/html
17+
- ../logs/:/var/www/logs
18+
- ./xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
2319

2420
db:
2521
container_name: ${PROJECT_NAME}-db
2622

2723
image: mariadb
28-
restart: always
24+
volumes: ["./db/:/var/lib/mysql"]
25+
restart: on-failure
2926
ports: ["9306:3306"]
3027
environment:
3128
MARIADB_ROOT_PASSWORD: geheim
@@ -34,5 +31,5 @@ services:
3431
container_name: ${PROJECT_NAME}-adminer
3532

3633
image: adminer
37-
restart: always
34+
restart: on-failure
3835
ports: ["9081:8080"]

xdebug.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
xdebug.mode = debug
2+
xdebug.client_host = host.docker.internal
3+
xdebug.start_with_request = trigger
4+
xdebug.log = /dev/stdout

0 commit comments

Comments
 (0)