$ bin/console doctrine:database:create $ bin/console doctrine:migrations:migrate $ bin/console doctrine:fixtures:load $ bin/console server:run [OK] Server listening // Quit the server with CONTROL-C. PHP 7.3.5 Development Server started Listening on http://localhost1:8000 Document root is ~/ewok/public Press Ctrl-C to quit. executar
imagens, instalar binários e configurar bibliotecas. vhost.conf Configurar o serviço httpd, apontar paths e definir fallback. Makefile Organizar comandos de gerenciamento do ambiente. Configurar serviços que usam imagens para criar containers.
php7.3-intl \ php7.3-pdo_pgsql \ php7.3-redis COPY .docker/vhost.conf \ /etc/apache2/conf.d/vhost.conf WORKDIR /workspace FROM base as development RUN apk add --no-cache \ composer \ yarn && \ mkdir -p /var/www/.composer \ /var/www/.cache/yarn && \ chown -R apache:apache /var/www Multiestágio Com o mesmo Dockerfile é possível trabalhar com diferentes estágios e otimizar a preparação de imagens para diferentes ambientes desde o desenvolvimento até a produção.
php7.3-intl \ php7.3-pdo_pgsql COPY .docker/vhost.conf \ /etc/apache2/conf.d/vhost.conf WORKDIR /workspace FROM base as development RUN apk add --no-cache \ composer \ yarn && \ mkdir -p /var/www/.composer \ /var/www/.cache/yarn && \ chown -R apache:apache /var/www ./docker-compose.yml version: ‘3.7’ services: httpd: build: context: . target: development ports: - 8080:80 ... Multiestágio Com o mesmo Dockerfile é possível trabalhar com diferentes estágios e otimizar a preparação de imagens para diferentes ambientes desde o desenvolvimento até a produção.
... FROM staging AS build COPY . /workspace RUN composer install --no-scripts \ --optimize-autoloader --no-suggest \ --no-dev && \ composer dump-env prod --empty && \ yarn install && \ yarn encore production && \ rm -rf .docker/ .git/ assets/ node_modules/ tests/ var/ FROM base AS production COPY --from=build /workspace /workspace RUN chown apache:apache -R /workspace BASE DEVELOPMENT BUILD PRODUCTION volume copy copy
up vendor/ public/build/ up: docker-compose up -d down: docker-compose down sh: $(EXEC) /bin/sh vendor/: $(EXEC) composer install node_modules/: $(EXEC) yarn install public/build/: node_modules/ $(EXEC) yarn encore dev $ make up $ make down $ make sh $ make vendor/ $ make node_modules/ $ make public/build/
data-migrations: $(EXEC) bin/console \ doctrine:database:create $(EXEC) bin/console \ doctrine:migrations:migrate data-fixtures: $(EXEC) bin/console \ doctrine:fixtures:load $ make up $ make down $ make sh $ make vendor/ $ make node_modules/ $ make public/build/ $ make data-migrations $ make data-fixtures
lint-twig: $(EXEC) bin/console lint:twig templates/ lint-yaml: $(EXEC) bin/console lint:yaml config/ \ translations/ *.yml phpcs: $(EXEC) vendor/bin/php-cs-fixer fix \ --diff --dry-run --no-interaction -v phpunit: $(EXEC) bin/phpunit $ make up $ make down $ make sh $ make vendor/ $ make node_modules/ $ make public/build/ $ make data-migrations $ make data-fixtures $ make lint-twig $ make lint-yaml $ make phpcs $ make phpunit
make phpunit Testing Project Test Suite ....................................... Time: 1.02 minutes, Memory: 62.50MB OK (54 tests, 101 assertions) verificar
build-production.yml Configurações utilizadas para criar a imagem a ser publicada em produção. build-staging.yml Configurações utilizadas para criar a imagem onde as validações e os testes serão realizados.
httpd - make up - make vendor/ only: changes: - composer.json Yarn: stage: dependencies script: - docker-compose pull -q httpd - make up - make node_modules/ only: changes: - package.json
expectations. PHPspec Toolset to drive emergent design by specification. Panther Library to scrape websites and to run end-to-end tests using real browsers. PHPUnit Programmer- oriented testing framework for PHP. Psalm Static analysis tool for finding errors in PHP applications, built on top of PHP Parser. PHPStan Focuses on finding errors in your code without actually running it. Qual estratégia de teste utilizar?