diff --git a/.env b/.env new file mode 100644 index 0000000..78c73af --- /dev/null +++ b/.env @@ -0,0 +1,17 @@ +###> dvlpm/docker ### +NGINX_PORT=80 +POSTGRES_PORT=5432 +POSTGRES_TEST_PORT=5433 +DEBUG_REMOTE_HOST=192.168.99.1 +DEBUG_SERVER_NAME=0.0.0.0 +###> dvlpm/docker ### + +###> dvlpm/database ### +DATABASE_NAME=poster +DATABASE_USER=postgres +DATABASE_PASSWORD=postgres +###< dvlpm/database ### + +###> doctrine/doctrine-bundle ### +DATABASE_URL=pgsql://${DATABASE_USER}:${DATABASE_PASSWORD}@postgres:5432/${DATABASE_NAME} +###< doctrine/doctrine-bundle ### diff --git a/.env.dist b/.env.dist new file mode 100644 index 0000000..78c73af --- /dev/null +++ b/.env.dist @@ -0,0 +1,17 @@ +###> dvlpm/docker ### +NGINX_PORT=80 +POSTGRES_PORT=5432 +POSTGRES_TEST_PORT=5433 +DEBUG_REMOTE_HOST=192.168.99.1 +DEBUG_SERVER_NAME=0.0.0.0 +###> dvlpm/docker ### + +###> dvlpm/database ### +DATABASE_NAME=poster +DATABASE_USER=postgres +DATABASE_PASSWORD=postgres +###< dvlpm/database ### + +###> doctrine/doctrine-bundle ### +DATABASE_URL=pgsql://${DATABASE_USER}:${DATABASE_PASSWORD}@postgres:5432/${DATABASE_NAME} +###< doctrine/doctrine-bundle ### diff --git a/.env.example b/.env.example deleted file mode 100644 index 856dd00..0000000 --- a/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -APP_NAME=appname -NGINX_PORT=88 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6ab5c9b..0a5a701 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,18 @@ .idea -docker-compose.yml -.env \ No newline at end of file +docker-compose.override.yml +docker-compose.test.override.yml + +###> symfony/framework-bundle ### +/.env.local +/.env.local.php +/.env.*.local +/config/secrets/prod/prod.decrypt.private.php +/public/bundles/ +/var/ +/vendor/ +###< symfony/framework-bundle ### + +###> phpunit/phpunit ### +/phpunit.xml +.phpunit.result.cache +###< phpunit/phpunit ### diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..09db691 --- /dev/null +++ b/Makefile @@ -0,0 +1,64 @@ +ENV?=dev + +dca := docker-compose \ + -f docker-compose.yml \ + -f docker-compose.override.yml + +dct := $(dca) \ + -f docker-compose.test.yml \ + -f docker-compose.test.override.yml + +de-php := docker-compose exec php sh -c + +### --------------------- +### Init +### --------------------- +init: up composer-install migrate + +### +composer: + $(de-php) '$(MAKECMDGOALS)' + +migrate: + $(de-php) 'bin/console doctrine:migrations:migrate' + +### --------------------- +### Develop +### --------------------- +up: + $(dca) up -d + +ups: + $(dca) up + +down: + $(dca) down + +sh: + $(de-php) 'bash' + +### --------------------- +### Test +### --------------------- +test-up: + $(dct) up -d + +test-ups: + $(dct) up + +test-down: + $(dct) down + +test-migrate: + $(de-php) 'bin/console doctrine:migrations:migrate --env=test' + +### --------------------- +### Builds +### --------------------- + +### --------------------- +### Help +### --------------------- +# ignore all not-found targets +%: + @: \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..8eb7ffb --- /dev/null +++ b/composer.json @@ -0,0 +1,81 @@ +{ + "name": "dvlpm/skeleton", + "type": "project", + "license": "proprietary", + "require": { + "php": "^7.4", + "ext-ctype": "*", + "ext-iconv": "*", + "ext-json": "*", + "league/tactician": "^1.0", + "ramsey/uuid": "^3.8", + "sensio/framework-extra-bundle": "^5.4", + "symfony/console": "5.*", + "symfony/dotenv": "5.*", + "symfony/flex": "^1.3.1", + "symfony/framework-bundle": "5.*", + "symfony/orm-pack": "^1.0", + "symfony/serializer-pack": "^1.0", + "symfony/validator": "5.*", + "symfony/yaml": "5.*" + }, + "require-dev": { + "codeception/codeception": "^4.1", + "codeception/module-asserts": "^1.2", + "codeception/module-doctrine2": "^1.0", + "codeception/module-phpbrowser": "^1.0", + "codeception/module-rest": "^1.2", + "codeception/module-symfony": "^1.1", + "doctrine/doctrine-fixtures-bundle": "^3.2", + "jdorn/sql-formatter": "^1.2", + "lamoda/codeception-wiremock-extension": "^1.4", + "phpunit/phpunit": "^8.3", + "symfony/browser-kit": "5.*", + "symfony/maker-bundle": "^1.13" + }, + "config": { + "preferred-install": { + "*": "dist" + }, + "sort-packages": true + }, + "autoload": { + "psr-4": { + "App\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": ["tests/"] + } + }, + "replace": { + "paragonie/random_compat": "2.*", + "symfony/polyfill-ctype": "*", + "symfony/polyfill-iconv": "*", + "symfony/polyfill-php71": "*", + "symfony/polyfill-php70": "*", + "symfony/polyfill-php56": "*" + }, + "scripts": { + "auto-scripts": { + "cache:clear": "symfony-cmd", + "assets:install %PUBLIC_DIR%": "symfony-cmd" + }, + "post-install-cmd": [ + "@auto-scripts" + ], + "post-update-cmd": [ + "@auto-scripts" + ] + }, + "conflict": { + "symfony/symfony": "*" + }, + "extra": { + "symfony": { + "allow-contrib": false, + "require": "5.0.*" + } + } +} diff --git a/docker-compose.example.yml b/docker-compose.example.yml deleted file mode 100644 index e3d6388..0000000 --- a/docker-compose.example.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: '3' -services: - nginx: - image: nginx:alpine - container_name: ${APP_NAME}_nginx - ports: - - ${NGINX_PORT}:80 - volumes: - - ./volumes/nginx/default.conf:/etc/nginx/conf.d/default.conf:cached - - ./:/var/www/html:cached - php: - user: 1000:www-data - image: dvlpm/php7.4-dev:latest - volumes: - - ./:/var/www/html - - ./volumes/php/conf.d/docker-php-ext-xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini - environment: - XDEBUG_CONFIG: remote_host=192.168.99.1 \ No newline at end of file diff --git a/docker-compose.override.dist.yml b/docker-compose.override.dist.yml new file mode 100644 index 0000000..6bdf591 --- /dev/null +++ b/docker-compose.override.dist.yml @@ -0,0 +1 @@ +version: '3' diff --git a/docker-compose.test.override.dist.yml b/docker-compose.test.override.dist.yml new file mode 100644 index 0000000..6bdf591 --- /dev/null +++ b/docker-compose.test.override.dist.yml @@ -0,0 +1 @@ +version: '3' diff --git a/docker-compose.test.yml b/docker-compose.test.yml new file mode 100644 index 0000000..febff82 --- /dev/null +++ b/docker-compose.test.yml @@ -0,0 +1,27 @@ +version: '3' +services: + postgres-test: + image: postgres:12-alpine + ports: + - ${POSTGRES_TEST_PORT}:5432 + volumes: + - pgdata-test:/var/lib/postgresql/data/pgdata + environment: + - PGDATA=/var/lib/postgresql/data/pgdata + - POSTGRES_USER=${DATABASE_USER} + - POSTGRES_PASSWORD=${DATABASE_PASSWORD} + - POSTGRES_DB=${DATABASE_NAME} + php: + environment: + APP_ENV: test + + wiremock: + image: rodolpheche/wiremock:latest + ports: + - 8888:8080 + environment: + - TZ=Europe/Moscow + command: "--global-response-templating" + +volumes: + pgdata-test: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c045053 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,33 @@ +version: '3' +services: + nginx: + image: nginx:alpine + ports: + - ${NGINX_PORT}:80 + volumes: + - ./volumes/nginx/default.conf:/etc/nginx/conf.d/default.conf:cached + - ./:/var/www/html:cached + - composer:/var/www/.composer + php: + image: dvlpm/php7.4-dev:latest + volumes: + - ./:/var/www/html + - ./volumes/php/conf.d/docker-php-ext-xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + environment: + XDEBUG_CONFIG: remote_host=${DEBUG_REMOTE_HOST} + PHP_IDE_CONFIG: serverName=${DEBUG_SERVER_NAME} + + postgres: + image: postgres:12-alpine + ports: + - ${POSTGRES_PORT}:5432 + volumes: + - pgdata:/var/lib/postgresql/data/pgdata + environment: + - PGDATA=/var/lib/postgresql/data/pgdata + - POSTGRES_USER=${DATABASE_USER} + - POSTGRES_PASSWORD=${DATABASE_PASSWORD} + - POSTGRES_DB=${DATABASE_NAME} +volumes: + pgdata: + composer: