|
| 1 | +.PHONY: build install generate build-site serve test lint fix-lint coverage help |
| 2 | + |
| 3 | +IMAGE_NAME = mergephp-website |
| 4 | +CONTAINER_NAME = mergephp-website-container |
| 5 | +HOST_PORT = 8000 |
| 6 | +CONTAINER_PORT = 8000 |
| 7 | + |
| 8 | +# Default target |
| 9 | +help: |
| 10 | + @echo "Available commands:" |
| 11 | + @echo " make build - Build the Docker image" |
| 12 | + @echo " make install - Install Composer dependencies" |
| 13 | + @echo " make generate - Generate a new meetup" |
| 14 | + @echo " make build-site - Build the static site" |
| 15 | + @echo " make serve - Serve the site on localhost:$(HOST_PORT)" |
| 16 | + @echo " make test - Run PHPUnit tests" |
| 17 | + @echo " make lint - Check code style" |
| 18 | + @echo " make fix-lint - Fix lint errors automatically" |
| 19 | + @echo " make coverage - Generate code coverage report" |
| 20 | + @echo " make bash - Open a bash shell in the container" |
| 21 | + |
| 22 | +# Build the Docker image |
| 23 | +build: |
| 24 | + docker build -t $(IMAGE_NAME) . |
| 25 | + |
| 26 | +# Install dependencies |
| 27 | +install: |
| 28 | + docker run --rm -v $(PWD):/var/www/html $(IMAGE_NAME) composer install |
| 29 | + |
| 30 | +# Generate a new meetup |
| 31 | +generate: build |
| 32 | + docker run --rm -it -v $(PWD):/var/www/html $(IMAGE_NAME) composer generate |
| 33 | + |
| 34 | +# Build the static site |
| 35 | +build-site: build |
| 36 | + docker run --rm -v $(PWD):/var/www/html $(IMAGE_NAME) composer build |
| 37 | + |
| 38 | +# Serve the site |
| 39 | +serve: build |
| 40 | + docker run --rm -p $(HOST_PORT):$(CONTAINER_PORT) -v $(PWD):/var/www/html --name $(CONTAINER_NAME) $(IMAGE_NAME) php -S 0.0.0.0:$(CONTAINER_PORT) -t docs/ |
| 41 | + |
| 42 | +# Run tests |
| 43 | +test: build |
| 44 | + docker run --rm -v $(PWD):/var/www/html $(IMAGE_NAME) composer test |
| 45 | + |
| 46 | +# Run lint check |
| 47 | +lint: build |
| 48 | + docker run --rm -v $(PWD):/var/www/html $(IMAGE_NAME) composer lint |
| 49 | + |
| 50 | +# Fix lint errors |
| 51 | +fix-lint: build |
| 52 | + docker run --rm -v $(PWD):/var/www/html $(IMAGE_NAME) composer fix-lint-errors |
| 53 | + |
| 54 | +# Generate code coverage |
| 55 | +coverage: build |
| 56 | + docker run --rm -v $(PWD):/var/www/html $(IMAGE_NAME) composer coverage |
| 57 | + |
| 58 | +# Open a bash shell in the container |
| 59 | +bash: build |
| 60 | + docker run --rm -it -v $(PWD):/var/www/html $(IMAGE_NAME) bash |
0 commit comments