forked from EC-CUBE/ec-cube2
-
Notifications
You must be signed in to change notification settings - Fork 0
デバッグ ‐ Docker、PHPStan、E2Eテスト (Playwright) など
Seasoft edited this page Jan 7, 2025
·
11 revisions
Dockerfile-local を作成する。公式リポジトリ をベースにデバッグに都合が良いよう手を加える。
ARG TAG
FROM ${REGISTRY:-ghcr.io}/${IMAGE_NAME:-ec-cube/ec-cube2-php}:${TAG:-8.1-apache}
RUN apt update
RUN apt -y install inetutils-ping telnet
ARG XDEBUG
RUN pecl install ${XDEBUG:-xdebug}
RUN docker-php-ext-enable xdebug
RUN apt -y install iproute2
ただし、最新の構成を使う必要がある場合などは、Dockerfile をコピーして、末尾に RUN apt update
以下を追記する。
php.ini を作成する。
; Xdebug 3 向けの設定
;xdebug.mode = debug
xdebug.mode = coverage
;xdebug.start_with_request = yes
xdebug.client_host = host.docker.internal
docker-compose.debug.yml を作成する。
services:
ec-cube:
volumes:
- type: bind
source: "./php.ini"
target: "/usr/local/etc/php/conf.d/zz-composer.php.ini"
# docker-compose.yml の定義を無効化する。
- type: bind
source: "./data/vendor"
target: "/var/www/app/data/vendor"
https://github.com/EC-CUBE/ec-cube2/pull/886 をベースに考えた手順。
$ export TAG=8.2-apache
$ export REGISTRY=local
$ export -n XDEBUG
$ export COMPOSE_FILE=docker-compose.yml:docker-compose.pgsql.yml:docker-compose.dev.yml:docker-compose.debug.yml
$ docker build -f Dockerfile-local -t local/ec-cube/ec-cube2-php:${TAG} --pull --build-arg TAG=${TAG} --build-arg XDEBUG=${XDEBUG} .
$ docker compose down --remove-orphans --volumes
$ docker compose up -d --wait --build --remove-orphans
$ sudo rm -rf data/vendor/
$ git restore composer.json composer.lock yarn.lock
$ docker compose exec -T ec-cube composer install
$ docker compose exec -T ec-cube composer require ec-cube2/cli "dev-master@dev" -W
$ docker compose exec -T ec-cube composer update 'symfony/*' -W
$ export TAG=7.4-apache
$ export REGISTRY=local
$ export XDEBUG=xdebug-3.1.6
- PHP 7.4 は、Xdebug 2.8 - 3.1 が対応する。公式資料
$ yarn install
$ yarn run playwright install --with-deps chromium
$ yarn playwright install-deps chromium
PostgreSQL
$ docker compose exec -T -e DBSERVER=postgres ec-cube ./eccube_install.sh pgsql
$ docker compose exec -T postgres psql --user=eccube_db_user eccube_db -c "DELETE FROM dtb_customer"
$ docker compose exec -T ec-cube php -ddisplay_errors=1 data/vendor/bin/eccube eccube:fixtures:generate --products=5 --customers=1 --orders=5
$ docker compose exec -T postgres psql --user=eccube_db_user eccube_db -c "UPDATE dtb_customer SET email = '[email protected]' WHERE NOT EXISTS (SELECT * FROM dtb_customer WHERE email = '[email protected]' AND status = 2 AND del_flg = 0) AND customer_id = (SELECT MAX(customer_id) FROM dtb_customer WHERE status = 2 AND del_flg = 0);"
# 主に後日実行用途
$ docker compose exec -T postgres psql --user=eccube_db_user eccube_db -c "UPDATE dtb_order SET create_date = create_date + (SELECT CURRENT_TIMESTAMP - MAX(create_date) FROM dtb_order);"
MySQL
$ docker compose exec -T -e DBSERVER=mysql ec-cube ./eccube_install.sh mysql
$ docker compose exec -T mysql mysql --user=eccube_db_user --password=password eccube_db -e "DELETE FROM dtb_customer"
$ docker compose exec -T ec-cube php -ddisplay_errors=1 data/vendor/bin/eccube eccube:fixtures:generate --products=5 --customers=1 --orders=5
$ docker compose exec -T mysql mysql --user=eccube_db_user --password=password eccube_db -e "UPDATE dtb_customer tgt SET email = '[email protected]' WHERE NOT EXISTS (SELECT * FROM (SELECT * FROM dtb_customer) sub1 WHERE email = '[email protected]' AND status = 2 AND del_flg = 0) AND customer_id = (SELECT MAX(customer_id) FROM (SELECT * FROM dtb_customer) sub2 WHERE status = 2 AND del_flg = 0);"
# 主に後日実行用途
$ docker compose exec -T mysql mysql --user=eccube_db_user --password=password eccube_db -e "UPDATE dtb_order SET create_date = create_date + (SELECT CURRENT_TIMESTAMP - MAX(create_date) FROM (SELECT * FROM dtb_order) sub);"
$ docker-compose exec ec-cube data/vendor/bin/phpstan --memory-limit=512M analyse data/
$ docker-compose exec ec-cube data/vendor/bin/phpunit
$ yarn test:e2e --workers=1 --timeout=45000 e2e-tests/test/admin e2e-tests/test/front_guest e2e-tests/test/front_login
- PHPUnit 実行後は、ダミーデータ生成をやり直す。(dtb_customer が書き換わって、ログインできない。)
- xdebug の debug を有効にして IDE でデバッグを開始していないと非常に遅くなる。