Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Docker configuration for local setup #163

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/.phpunit.result.cache
/.php-cs-fixer.cache
/.php-cs-fixer.php
/.idea
/composer.lock
/phpunit.xml
/vendor/
Expand Down
29 changes: 29 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Well documented Makefiles
DEFAULT_GOAL := help
help:
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\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 <dependency>"
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
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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