From 22dc635fbb90f3d8bea8daed7f30afa3cb73d38c Mon Sep 17 00:00:00 2001 From: Wendell Adriel Date: Thu, 2 Feb 2023 13:24:22 +0000 Subject: [PATCH] Added Docker configuration for local setup --- .gitignore | 1 + CONTRIBUTING.md | 29 +++++++++++++++++++++++++++++ Makefile | 33 +++++++++++++++++++++++++++++++++ docker-compose.yml | 13 +++++++++++++ docker/Dockerfile | 11 +++++++++++ 5 files changed, 87 insertions(+) create mode 100644 Makefile create mode 100644 docker-compose.yml create mode 100644 docker/Dockerfile diff --git a/.gitignore b/.gitignore index 487716c..2a1d68f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.phpunit.result.cache /.php-cs-fixer.cache /.php-cs-fixer.php +/.idea /composer.lock /phpunit.xml /vendor/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d2ceb41..ffbf177 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,3 +45,32 @@ Unit tests: ```bash composer test:unit ``` + +## Docker Setup + +Clone your fork, then install the dev dependencies: +```bash +make composer ARGS="install" +``` +## Lint + +Lint your code: +```bash +make lint +``` +## Tests + +Run all tests: +```bash +make test +``` + +Check types: +```bash +make test-types +``` + +Unit tests: +```bash +make test-unit +``` diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a71576b --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +# Well documented Makefiles +DEFAULT_GOAL := help +help: + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-40s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +##@ [Docker] +start: ## Spin up the container + docker-compose up -d + +stop: ## Shut down the containers + docker-compose down + +build: ## Build all docker images + docker-compose build + +##@ [Application] +composer: ## Run composer commands. Specify the command e.g. via "make composer ARGS="install|update|require " + docker-compose run --rm app composer $(ARGS) + +lint: ## Run the Linter + docker-compose run --rm app ./vendor/bin/pint -v + +test-lint: ## Run the Linter Test + docker-compose run --rm app ./vendor/bin/pint --test -v + +test-types: ## Run the PHPStan analysis + docker-compose run --rm app ./vendor/bin/phpstan analyse --ansi + +test-unit: ## Run the Pest Test Suite + docker-compose run --rm app ./vendor/bin/pest --colors=always + +test: ## Run the tests. Apply arguments via make test ARGS="--init" + make test-lint && make test-types && make test-unit diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..693b008 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3' + +services: + app: + image: termwind-docker + container_name: termwind-docker + stdin_open: true + tty: true + build: + context: . + dockerfile: docker/Dockerfile + volumes: + - .:/usr/src/app diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..53732e7 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,11 @@ +FROM php:8.2-cli-alpine + +# INSTALL AND UPDATE COMPOSER +COPY --from=composer /usr/bin/composer /usr/bin/composer +RUN composer self-update + +WORKDIR /usr/src/app +COPY . . + +# INSTALL YOUR DEPENDENCIES +RUN composer install --prefer-dist