Skip to content

Commit

Permalink
7.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
atlance committed Jan 25, 2024
1 parent fd5bffd commit c1af779
Show file tree
Hide file tree
Showing 16 changed files with 166 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/.github export-ignore
/config export-ignore
/docker export-ignore
/make export-ignore
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/Makefile export-ignore
2 changes: 1 addition & 1 deletion .github/workflows/php-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: composer php-analyze

- name: Run PHPUnit Tests
run: composer paratest
run: composer php-tests

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@main
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/*
!/.github
!/config
!/docker
!/docs
!/make
!/src
!/tests
/tests/Kernel/var
Expand All @@ -13,4 +15,5 @@
!/*.dist

!/LICENSE.md
!/Makefile
!/README.md
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
$(shell cp -n make/dev/infrastructure/.env.dist .env && mkdir -p ./var)

include ./.env
export $(shell sed 's/=.*//' ./.env)

-include ./make/${APP_ENV}/**/*.mk
-include ./make/${APP_ENV}/*.mk

RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(RUN_ARGS):;@:)

env:
cp -n make/${RUN_ARGS}/infrastructure/.env.dist .env

down-clear: ## Down service and remove volumes.
docker-compose down --remove-orphans -v
rm -rf var vendor composer.lock docker-compose.yml

.PHONY: help

help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-12s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)

.DEFAULT_GOAL := help
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
"scripts": {
"cs-check": "vendor/bin/php-cs-fixer fix --config config/php_cs.dist.php --dry-run",
"cs-fix": "vendor/bin/php-cs-fixer fix --config config/php_cs.dist.php",
"paratest": "XDEBUG_MODE=coverage vendor/bin/paratest -c config/phpunit.xml.dist --colors --runner=WrapperRunner --coverage-clover ./coverage.xml",
"php-analyze": [
"@psalm",
"@cs-check",
"@phplint",
"@phpstan"
],
"php-tests": "XDEBUG_MODE=coverage vendor/bin/paratest -c config/phpunit.xml.dist --colors --runner=WrapperRunner --coverage-clover ./coverage.xml",
"phplint": "vendor/bin/phplint -c config/phplint.yaml.dist",
"phpstan": "vendor/bin/phpstan analyse -c config/phpstan.neon.dist --no-progress --memory-limit=-1",
"psalm": "vendor/bin/psalm -c config/psalm.xml.dist --no-cache --threads=6 --memory-limit=-1 --shepherd",
Expand Down
1 change: 1 addition & 0 deletions docker/php-cli/conf.d/timezone.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
date.timezone=Europe/Moscow
7 changes: 7 additions & 0 deletions docker/php-cli/conf.d/xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
xdebug.mode=${XDEBUG_MODE}
xdebug.client_host=host.docker.internal
xdebug.client_port=9003
xdebug.idekey=PHPSTORM
xdebug.start_with_request=yes
xdebug.log_level=3
xdebug.log="/tmp/xdebug.log"
56 changes: 56 additions & 0 deletions docker/php-cli/php-cli.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# syntax=docker/dockerfile:experimental
ARG php_cli_image
FROM $php_cli_image AS php-common

ARG pear_ext_dir_date
ENV PHP_EXT_DIR "/usr/local/lib/php/extensions/no-debug-non-zts-$pear_ext_dir_date"
RUN set -ex \
&& if [ `pear config-get ext_dir` != ${PHP_EXT_DIR} ]; then echo PHP_EXT_DIR must be `pear config-get ext_dir` && exit 1; fi

FROM php-common AS php-build
RUN --mount=type=cache,target=/var/cache/apk set -ex \
&& apk add --update-cache $PHPIZE_DEPS

FROM php-build AS php-ext-intl
RUN --mount=type=cache,target=/var/cache/apk set -ex \
&& apk add \
icu-dev \
&& docker-php-ext-install intl

FROM php-build AS php-ext-xdebug
RUN set -ex \
&& apk add --update linux-headers \
&& pecl install xdebug

FROM php-build AS php-ext-pcntl
RUN set -ex \
&& docker-php-ext-install pcntl

FROM php-common AS php-base
COPY --from=php-ext-intl ${PHP_EXT_DIR}/intl.so ${PHP_EXT_DIR}/
COPY --from=php-ext-intl /usr/local /usr/local
COPY --from=php-ext-pcntl ${PHP_EXT_DIR}/pcntl.so ${PHP_EXT_DIR}/
COPY --from=php-ext-xdebug ${PHP_EXT_DIR}/xdebug.so ${PHP_EXT_DIR}/
RUN --mount=type=cache,target=/var/cache/apk \
set -ex \
&& apk add libpq icu shadow gettext git \
&& docker-php-ext-enable intl pcntl xdebug \
&& mv $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini

COPY ./php-cli/conf.d /usr/local/etc/php/conf.d

ARG user
ARG uid

RUN addgroup $user \
&& adduser -DS -h /home/$user -u 1000 -G $user $user \
&& adduser www-data $user \
&& mkdir -p /home/$user/.composer \
&& chown -R $user:$user /home/$user

COPY --chown=$user:$user --from=composer:latest /usr/bin/composer /usr/local/bin/composer

USER $user:$user

ARG app_dir
WORKDIR $app_dir
5 changes: 5 additions & 0 deletions make/dev/analyze.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
php-analyze: ## Run static analyze - phpcs, phplint, phpstan, psalm.
docker-compose run --rm php-cli composer php-analyze

php-cs-fix:
docker-compose run --rm php-cli composer cs-fix
8 changes: 8 additions & 0 deletions make/dev/composer.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
composer-install: ## Install composer dependecies.
docker-compose run --rm php-cli composer install --no-interaction --no-progress

composer-normalize:
docker-compose run --rm php-cli composer normalize

composer-require:
docker-compose run --rm php-cli composer req ${RUN_ARGS}
8 changes: 8 additions & 0 deletions make/dev/docker.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
docker-compose:
envsubst < make/${APP_ENV}/infrastructure/docker-compose.yml > docker-compose.yml

docker-build: ## Buid dev images
docker-compose build

docker-up: ## Start service.
docker-compose up -d
19 changes: 19 additions & 0 deletions make/dev/infrastructure/.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# app.
APP_NAME=jwt-core
APP_VERSION=0.3.1
APP_DIR=/app
APP_ENV=dev
APP_DEBUG=true
APP_SECRET=11b2c9dfc2dbecf56941327b7c84cdf9
# php.
PHP_VERSION=8.3.1
PHP_CLI_IMAGE=php:${PHP_VERSION}-cli-alpine
XDEBUG_MODE=develop,debug,coverage
# php 8.2.1
# PEAR_EXT_DIR_DATE=20220829
# php 8.3.1
PEAR_EXT_DIR_DATE=20230831
# docker.
COMPOSE_DOCKER_CLI_BUILD=1
DOCKER_BUILDKIT=1
UID=1000
22 changes: 22 additions & 0 deletions make/dev/infrastructure/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: "3.9"

services:
php-cli:
build:
context: ./docker
dockerfile: php-cli/php-cli.dockerfile
args:
php_cli_image: ${PHP_CLI_IMAGE}
app_dir: ${APP_DIR}
user: ${USER}
uid: ${UID}
pear_ext_dir_date: ${PEAR_EXT_DIR_DATE}
env_file: [ .env ]
networks: [ backend ]
dns: [ 8.8.4.4, 8.8.8.8 ]
extra_hosts: [ "host.docker.internal:host-gateway" ]
volumes:
- .:${APP_DIR}:rw

networks:
backend:
5 changes: 5 additions & 0 deletions make/dev/install.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
prepare:
@make env dev
@make docker-compose dev

install: prepare docker-build docker-up composer-install ## Build & run app developments containers.
2 changes: 2 additions & 0 deletions make/dev/phpunit.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
php-tests: ## Run phpunit tests.
docker-compose run --rm php-cli composer php-tests
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(private UrlGeneratorInterface $urlGenerator)
{
}

public function start(Request $request, AuthenticationException $authException = null): RedirectResponse
public function start(Request $request, ?AuthenticationException $authException = null): RedirectResponse
{
return new RedirectResponse($this->urlGenerator->generate(Login\Controller::class));
}
Expand Down

0 comments on commit c1af779

Please sign in to comment.