-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #590 from Slamdunk/docker_local_build
Local build: require `docker compose` only
- Loading branch information
Showing
4 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
vendor | ||
composer.phar | ||
/vendor | ||
.env | ||
clover.xml | ||
infectionlog.txt | ||
.phpunit.result.cache | ||
.phpcs-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM php:8.2 | ||
|
||
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ | ||
|
||
RUN install-php-extensions @composer pcov | ||
|
||
ARG USER_ID | ||
ARG GROUP_ID | ||
|
||
RUN groupadd --gid ${GROUP_ID} code \ | ||
&& useradd --create-home --shell /bin/bash --uid ${USER_ID} --gid code code | ||
|
||
USER code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
ifdef CI | ||
DOCKER_PHP_EXEC := | ||
else | ||
DOCKER_PHP_EXEC := docker compose run --rm php | ||
endif | ||
|
||
SRCS := $(shell find ./src ./test -type f) | ||
|
||
default: unit cs static-analysis coverage ## all the things | ||
|
||
.PHONY: help | ||
help: | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
.env: /etc/passwd /etc/group Makefile | ||
printf "USER_ID=%s\nGROUP_ID=%s\n" `id --user "${USER}"` `id --group "${USER}"` > .env | ||
|
||
vendor: .env docker-compose.yml Dockerfile composer.json | ||
docker compose build --pull | ||
$(DOCKER_PHP_EXEC) composer update | ||
$(DOCKER_PHP_EXEC) composer bump | ||
touch --no-create $@ | ||
|
||
.PHONY: unit | ||
unit: vendor ## run unit tests | ||
$(DOCKER_PHP_EXEC) vendor/bin/phpunit | ||
|
||
.PHONY: cs | ||
cs: vendor ## verify code style rules | ||
$(DOCKER_PHP_EXEC) vendor/bin/phpcbf -p || true | ||
$(DOCKER_PHP_EXEC) vendor/bin/phpcs -p | ||
|
||
.PHONY: static-analysis | ||
static-analysis: vendor ## verify that no static analysis issues were introduced | ||
$(DOCKER_PHP_EXEC) vendor/bin/psalm | ||
|
||
.PHONY: bc-check | ||
bc-check: vendor ## check for backwards compatibility breaks | ||
mkdir -p /tmp/bc-check | ||
$(DOCKER_PHP_EXEC) composer require --no-plugins -d/tmp/bc-check roave/backward-compatibility-check | ||
$(DOCKER_PHP_EXEC) /tmp/bc-check/vendor/bin/roave-backward-compatibility-check | ||
rm -Rf /tmp/bc-check | ||
|
||
.PHONY: coverage | ||
coverage: vendor ## generate code coverage reports | ||
$(DOCKER_PHP_EXEC) vendor/bin/roave-infection-static-analysis-plugin --show-mutations | ||
|
||
.PHONY: clean | ||
clean: | ||
git clean -dfX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
services: | ||
php: | ||
build: | ||
context: . | ||
args: | ||
USER_ID: ${USER_ID} | ||
GROUP_ID: ${GROUP_ID} | ||
volumes: | ||
- .:${PWD} | ||
working_dir: ${PWD} |