Dockerコンテナ内にXdebugを導入 (#33)

* コンテナにxdebugをインストール
* env fileをDockerに読ませるようにした
* 環境変数 APP_DEBUG に応じてXdebugをロードしてApacheを起動するようにした
* シェルスクリプトのWindows対策 (.gitattribute)
This commit is contained in:
shibafu 2019-01-16 00:42:05 +09:00 committed by GitHub
parent 0d4a61ef15
commit 2ca6c4c60d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 13 deletions

View File

@ -5,12 +5,12 @@ APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
DB_CONNECTION=pgsql
DB_HOST=db
DB_PORT=5432
DB_DATABASE=tissue
DB_USERNAME=tissue
DB_PASSWORD=tissue
BROADCAST_DRIVER=log
CACHE_DRIVER=file

1
.gitattributes vendored
View File

@ -3,3 +3,4 @@
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
*.sh text eol=lf

View File

@ -5,10 +5,17 @@ ENV APACHE_DOCUMENT_ROOT /var/www/html/public
RUN apt-get update \
&& apt-get install -y git libpq-dev unzip \
&& docker-php-ext-install pdo_pgsql \
&& pecl install xdebug \
&& curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer \
&& sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf \
&& sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf \
&& a2enmod rewrite
COPY dist/bin /usr/local/bin/
COPY dist/php.d /usr/local/etc/php/php.d/
ENTRYPOINT ["tissue-entrypoint.sh"]
CMD ["apache2-foreground"]
WORKDIR /var/www/html

8
dist/bin/tissue-entrypoint.sh vendored Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
set -e
if [[ "$APP_DEBUG" == "true" ]]; then
export PHP_INI_SCAN_DIR=":/usr/local/etc/php/php.d"
fi
exec docker-php-entrypoint "$@"

5
dist/php.d/99-xdebug.ini vendored Normal file
View File

@ -0,0 +1,5 @@
; Dockerでのデバッグ用設定
zend_extension=xdebug.so
xdebug.remote_enable=true
xdebug.remote_autostart=true
xdebug.remote_host=host.docker.internal

View File

@ -3,13 +3,8 @@ version: "3"
services:
web:
build: .
environment:
DB_CONNECTION: pgsql
DB_HOST: db
DB_PORT: 5432
DB_DATABASE: tissue
DB_USERNAME: tissue
DB_PASSWORD: tissue
env_file:
- .env
volumes:
- .:/var/www/html
networks: