From 131fd8990819510b9b92d442106a17a1b07b5445 Mon Sep 17 00:00:00 2001 From: Andrey Selin Date: Tue, 7 Sep 2021 14:45:36 +0300 Subject: [PATCH] added docker, removed broadway/broadway, added micro-module/broadway --- .docker/php7.3-dev/Dockerfile | 16 ------------- .docker/php8.0-dev/Dockerfile | 32 ++++++++++++++++++++++++++ .env | 11 +-------- Makefile | 23 ++++++------------- composer.json | 22 +++++++++--------- default.env | 5 ++++ docker-compose.yml | 8 ++++--- phpunit.xml.dist | 43 ++++++++++++++++------------------- 8 files changed, 80 insertions(+), 80 deletions(-) delete mode 100644 .docker/php7.3-dev/Dockerfile create mode 100644 .docker/php8.0-dev/Dockerfile create mode 100644 default.env diff --git a/.docker/php7.3-dev/Dockerfile b/.docker/php7.3-dev/Dockerfile deleted file mode 100644 index 3d5e25d..0000000 --- a/.docker/php7.3-dev/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM php:7.3-cli - -RUN apt-get update && apt-get install -y git unzip - -ENV COMPOSER_ALLOW_SUPERUSER 1 -ENV COMPOSER_MEMORY_LIMIT -1 - -RUN mkdir /.composer_cache -ENV COMPOSER_CACHE_DIR /.composer_cache - -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - -# php extensions - -RUN pecl install xdebug -RUN docker-php-ext-enable xdebug diff --git a/.docker/php8.0-dev/Dockerfile b/.docker/php8.0-dev/Dockerfile new file mode 100644 index 0000000..504dbda --- /dev/null +++ b/.docker/php8.0-dev/Dockerfile @@ -0,0 +1,32 @@ +ARG PHP_VER + +FROM php:8.0-cli-alpine3.13 + +RUN apk update +RUN apk add --no-cache bash +RUN apk add --no-cache build-base +RUN apk add --no-cache autoconf +RUN apk add --no-cache automake + +RUN apk add --no-cache --upgrade bash && \ + apk add libpq zip unzip tree + +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +RUN mkdir /.composer_cache +ENV COMPOSER_CACHE_DIR /.composer_cache + +# curl for cmd +RUN apk add --no-cache curl + +#develop layer +RUN pecl install xdebug +RUN docker-php-ext-enable xdebug + +# bcmath +RUN docker-php-ext-install bcmath +RUN docker-php-ext-enable bcmath + +# intl +RUN apk add --no-cache icu-dev +RUN docker-php-ext-install intl +RUN docker-php-ext-enable intl diff --git a/.env b/.env index 2ef5087..7e295b8 100644 --- a/.env +++ b/.env @@ -1,13 +1,4 @@ -# This file is a "template" of which env vars need to be defined for your application -# Copy this file to .env file for development, create environment variables when deploying to production -# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration - -###> symfony/framework-bundle ### -APP_ENV=dev -APP_SECRET=secret -###< symfony/framework-bundle ### - ###> common variables ### -MICROTSK_COMPOSE_PROJECT_NAME=micro-task +MICROTASK_COMPOSE_PROJECT_NAME=micro-task CI_COMMIT_REF_SLUG=master ###< common variables ### diff --git a/Makefile b/Makefile index 328007c..42affe9 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,8 @@ -version = $(shell git describe --tags --dirty --always) -build_name = application-$(version) -# use the rest as arguments for "run" -RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) -# ...and turn them into do-nothing targets -#$(eval $(RUN_ARGS):;@:) +$(shell (if [ ! -e .env ]; then cp default.env .env; fi)) +include .env +export + +RUN_ARGS = $(filter-out $@,$(MAKECMDGOALS)) .PHONY: fix-permission fix-permission: ## fix permission for docker env @@ -15,10 +14,6 @@ build: ## build environment and initialize composer and project dependencies docker-compose build make composer-install -.PHONY: stop -stop: - docker-compose stop - .PHONY: composer-install composer-install: ## Install project dependencies docker-compose run --rm --no-deps php sh -lc 'composer install' @@ -50,11 +45,7 @@ style: ## executes php analizers .PHONY: lint lint: ## checks syntax of PHP files - docker-compose run --rm --no-deps php sh -lc './vendor/bin/parallel-lint ./ --exclude vendor --exclude bin/.phpunit' - -.PHONY: layer -layer: ## Check issues with layers (deptrac tool) - docker-compose run --rm --no-deps php sh -lc './vendor/bin/deptrac analyze --formatter-graphviz=0' + docker-compose run --rm --no-deps php sh -lc './vendor/bin/parallel-lint ./ --exclude vendor' .PHONY: logs logs: ## look for service logs @@ -71,7 +62,7 @@ php-shell: ## PHP shell unit-tests: ## Run unit-tests suite docker-compose run --rm php sh -lc 'vendor/bin/phpunit --testsuite unit-tests' -static-analysis: style layer coding-standards ## Run phpstan, deprac, easycoding standarts code static analysis +static-analysis: style coding-standards ## Run phpstan, easycoding standarts code static analysis coding-standards: ## Run check and validate code standards tests docker-compose run --rm --no-deps php sh -lc 'vendor/bin/ecs check src tests' diff --git a/composer.json b/composer.json index ef9e4d3..828185a 100644 --- a/composer.json +++ b/composer.json @@ -4,33 +4,33 @@ "description": "Micro module Task common library", "license": "proprietary", "require": { - "php": "^7.3 || ^8.0", + "php": "^8.0", "beberlei/assert": "^3.2", - "broadway/broadway": "^2.2", - "queue-interop/amqp-interop": "^0.8", - "queue-interop/queue-interop": "^0.7|^0.8", "enqueue/enqueue": "^0.10", "enqueue/fs": "^0.10", "enqueue/null": "^0.10", "league/tactician-bundle": "^1.1", - "micro-module/tactician-command-events": "~0.7", - "micro-module/base": "~0.7", + "micro-module/base": "^0.7.0", + "micro-module/broadway": "^2.6", "micro-module/job-queue": "~0.10", - "psr/log": "^1.1" + "micro-module/tactician-command-events": "~0.7", + "psr/log": "^1.1", + "queue-interop/amqp-interop": "^0.8", + "queue-interop/queue-interop": "^0.7|^0.8" }, "require-dev": { + "mockery/mockery": "^1.3", "php-parallel-lint/php-console-highlighter": "^0.4", "php-parallel-lint/php-parallel-lint": "^1.0", - "mockery/mockery": "^1.3", "phpmd/phpmd": "^2.8", "phpstan/phpstan": "^0.12", "phpstan/phpstan-mockery": "^0.12", "phpstan/phpstan-phpunit": "^0.12", "phpunit/phpunit": "^9.0", "roave/security-advisories": "dev-master", - "sensiolabs-de/deptrac-shim": "^0.4", - "symplify/easy-coding-standard": "^7.2", - "vimeo/psalm": "^3.11" + "sensiolabs-de/deptrac-shim": "^0.15.2", + "symplify/easy-coding-standard": "^9.4", + "vimeo/psalm": "^4.10" }, "config": { "preferred-install": { diff --git a/default.env b/default.env new file mode 100644 index 0000000..e7806ae --- /dev/null +++ b/default.env @@ -0,0 +1,5 @@ +###> common variables ### +MICROTASK_COMPOSE_PROJECT_NAME=micro-task +CI_COMMIT_REF_SLUG=master +PHP_VER=8.0 +###< common variables ### diff --git a/docker-compose.yml b/docker-compose.yml index 609c0dd..077e3f4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,11 +2,13 @@ version: "3.7" services: php: - container_name: ${MICROTSK_COMPOSE_PROJECT_NAME}_php + container_name: ${MICROTASK_COMPOSE_PROJECT_NAME}_php user: 1000:1000 build: - context: .docker/php7.3-dev + context: .docker/php8.0-dev volumes: - ~/.composer/cache/:/.composer_cache/:rw - - .:/app:rw + - ./:/app:rw working_dir: /app + env_file: + - .env diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4539d9e..bc0e370 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,27 +1,22 @@ - - - - - - - - - - - - - tests/unit - - - - - - + + + + + + + + + + + + + + + + tests/unit + + +