Skip to content

Commit

Permalink
feat: add docker compose support
Browse files Browse the repository at this point in the history
Added base PHP image to run local development and PHAR builds

ci: added default markdownlint config

feat: add box-project/box, composer-require-checker and composer-normalize PHARs

feat: Makefile now builds trap PHAR locally using `make phar` command
  • Loading branch information
lotyp committed May 11, 2024
1 parent 735deaa commit d86a1e0
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -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
}
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
# ------------------------------------------------------------------------------------
Expand Down
22 changes: 22 additions & 0 deletions box.json.dist
Original file line number Diff line number Diff line change
@@ -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"
}
24 changes: 24 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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}

...

0 comments on commit d86a1e0

Please sign in to comment.