diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..148f1607 --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +# https://docs.docker.com/compose/reference/envvars/#compose_project_name +# With custom namespace provided, it will be used to prefix all services +# in Docker network for current project +COMPOSE_PROJECT_NAME=trap + +XDEBUG_MODE=coverage diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 00000000..77f382df --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint/main/schema/markdownlint-config-schema.json", + "line-length": false, + "no-inline-html": false, + "first-line-h1": false, + "no-duplicate-heading": false +} diff --git a/Makefile b/Makefile index 1247a3b0..d49ca9ee 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,10 @@ # https://docs.docker.com/compose/environment-variables/envvars/ export DOCKER_BUILDKIT ?= 1 +# User ID and Group ID to use inside docker containers +HOST_UID ?= $(shell id -u) +HOST_GID ?= $(shell id -g) + # Docker binary to use, when executing docker tasks DOCKER ?= docker @@ -49,8 +53,9 @@ PHIVE_RUNNER ?= $(DOCKER_COMPOSE) run --rm --no-deps app EXPORT_VARS = '\ $${COMPOSE_PROJECT_NAME} \ - $${COMPOSER_AUTH}' - + $${COMPOSER_AUTH} \ + $${HOST_UID} \ + $${HOST_GID}' # # Self documenting Makefile code @@ -170,9 +175,17 @@ update: ## Updates composer dependencies by running composer update command .PHONY: update phive: ## Installs dependencies with phive - $(APP_RUNNER) /usr/local/bin/phive install --trust-gpg-keys 0x033E5F8D801A2F8D + $(APP_RUNNER) /usr/local/bin/phive install --trust-gpg-keys 0xC00543248C87FB13,0x033E5F8D801A2F8D,0x2DF45277AEF09A2F .PHONY: phive +phar: + $(APP_RUNNER) sh -c "git config --global --add safe.directory /app \ + && .phive/box validate \ + && .phive/box compile \ + && .phive/box info .build/phar/trap.phar \ + && .build/phar/trap.phar" +.PHONY: phar + # # Code Quality, Git, Linting # ------------------------------------------------------------------------------------ diff --git a/box.json.dist b/box.json.dist new file mode 100644 index 00000000..5fe1f90c --- /dev/null +++ b/box.json.dist @@ -0,0 +1,22 @@ +{ + "$schema": "https://raw.githubusercontent.com/box-project/box/main/res/schema.json", + "compactors": [ + "KevinGH\\Box\\Compactor\\Json", + "KevinGH\\Box\\Compactor\\Php" + ], + "compression": "GZ", + "git": "git", + "directories": [ + "resources", + "src", + "vendor" + ], + "files": [ + "trap.xml", + "bin/trap", + "LICENSE.md", + "composer.json", + "composer.lock" + ], + "output": ".build/phar/trap.phar" +} diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..623965f8 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,24 @@ +--- + +version: '3.9' + +services: + app: + image: wayofdev/php-dev:8.3-cli-alpine-latest + container_name: ${COMPOSE_PROJECT_NAME}-app + restart: on-failure + networks: + - default + volumes: + - ./:/app:rw + - ~/.composer:/.composer + env_file: + - .env + environment: + PHIVE_HOME: /app/.phive + +networks: + default: + name: project.${COMPOSE_PROJECT_NAME} + +...