diff --git a/README.md b/README.md index c80ab34..bf3dc66 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,25 @@ # Enter -We use [DDEV](https://ddev.com/) and [Task](https://taskfile.dev/) for development: +We use [ITK-dev docker setup] or [DDEV](https://ddev.com/) and [Task](https://taskfile.dev/) for development: ``` shell task site:install ``` +Set + +``` dotenv +TASK_USE_DDEV=true +``` + +in `.env.local` to make `task` use `ddev` rather than `docker compose` for running commands. + ``` shell task site:update -ddev launch +task site:open ``` -Run `task` to see what cool task are available. Running `ddev` can help with other stuff. +Run `task` to see what cool task are available. ## Adapter @@ -51,5 +59,14 @@ Design decisions are recorded in [docs/adr](docs/adr/README.md). A [Scorpio Broker](https://scorpio.readthedocs.io/) is part of the development setup. ``` shell -ddev exec "curl --silent http://scorpio.local:9090/ngsi-ld/v1/types | jq" +docker compose exec phpfpm curl --silent http://scorpio.local:9090/ngsi-ld/v1/types | jq ``` + +If you're using the [ITK-dev docker setup], the broker can also be +accessed on , e.g. + +``` php +curl --silent http://scorpio.enter.local.itkdev.dk/ngsi-ld/v1/types | jq +``` + +[ITK-dev docker setup]: https://github.com/itk-dev/devops_itkdev-docker/ diff --git a/Taskfile.yml b/Taskfile.yml index 84fbd88..a1b1178 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -8,17 +8,36 @@ tasks: desc: Install site from scratch prompt: Really (re)install site? cmds: - - ddev delete --omit-snapshot --yes - - rm -fr .ddev/data/scorpio-db/ + - if: '[ "$TASK_USE_DDEV" = "true" ]' + cmd: | + ddev delete --omit-snapshot --yes + rm -fr .ddev/data/scorpio-db/ - task: site:update site:update: desc: Update site cmds: - - ddev restart - - ddev composer install - # - ddev console doctrine:migrations:migrate --no-interaction - - ddev console cache:clear + - if: '[ "$TASK_USE_DDEV" != "true" ]' + task: compose + vars: + TASK_ARGS: pull + - if: '[ "$TASK_USE_DDEV" = "true" ]' + cmd: ddev restart + - task: composer:install + # - task: console + # vars: + # TASK_ARGS: doctrine:migrations:migrate --no-interaction + - task: console + vars: + TASK_ARGS: cache:clear + + site:open: + desc: Open the site in a browser + cmds: + - if: '[ "$TASK_USE_DDEV" != "true" ]' + cmd: open 'http://enter.local.itkdev.dk/' + - if: '[ "$TASK_USE_DDEV" = "true" ]' + cmd: ddev launch test: desc: Run all tests @@ -31,14 +50,20 @@ tasks: env: APP_ENV: test desc: 'Run all {{.TASK | replace "test:" "" }} tests' - cmd: ddev php bin/phpunit tests/{{.TASK | replace "test:" "" | title }} + cmd: + task: php + vars: + TASK_ARGS: bin/phpunit tests/{{.TASK | replace "test:" "" | title }} test:integration: *test_task test:application: *test_task import: - desc: 'Import a source into the broker, e.g. task import -- mtm_spatialmaps-handicap-parking' - cmd: ddev console app:import {{.CLI_ARGS}} + desc: 'Import a source into the broker, e.g. `task {{.TASK}} -- mtm_spatialmaps-handicap-parking`' + cmd: + task: console + vars: + TASK_ARGS: app:import coding-standards:apply: desc: 'Apply coding standards' @@ -114,26 +139,38 @@ tasks: coding-standards:php:apply: desc: 'Apply coding standards for PHP' cmds: - - ddev php vendor/bin/rector - - ddev php vendor/bin/php-cs-fixer fix + - task: php + vars: + TASK_ARGS: vendor/bin/rector + - task: php + vars: + TASK_ARGS: vendor/bin/php-cs-fixer fix coding-standards:php:check: desc: 'Apply and check coding standards for PHP' cmds: - task: coding-standards:php:apply - - ddev php vendor/bin/rector --dry-run - - ddev php vendor/bin/php-cs-fixer check + - task: php + vars: + TASK_ARGS: vendor/bin/rector --dry-run + - task: php + vars: + TASK_ARGS: vendor/bin/php-cs-fixer check coding-standards:twig:apply: desc: 'Apply coding standards for Twig' cmds: - - ddev php vendor/bin/twig-cs-fixer fix + - task: php + vars: + TASK_ARGS: vendor/bin/twig-cs-fixer fix coding-standards:twig:check: desc: 'Apply and check coding standards for Twig' cmds: - task: coding-standards:twig:apply - - ddev php vendor/bin/twig-cs-fixer check + - task: php + vars: + TASK_ARGS: vendor/bin/twig-cs-fixer check coding-standards:yaml:apply: desc: 'Apply coding standards for YAML' @@ -172,9 +209,39 @@ tasks: composer: internal: true - task: compose - vars: - TASK_ARGS: run --rm --no-deps phpfpm composer + cmd: + task: compose + vars: + TASK_ARGS: run --rm --no-deps phpfpm composer {{.TASK_ARGS}} + + composer:install: + internal: true + cmds: + - if: '[ "$APP_ENV" != "prod" ]' + task: composer + vars: + TASK_ARGS: install + - if: '[ "$APP_ENV" = "prod" ]' + task: composer + vars: + TASK_ARGS: install --no-dev --classmap-authoritative + + console: + internal: true + cmd: + task: php + vars: + TASK_ARGS: bin/console {{.TASK_ARGS}} + + php: + internal: true + cmds: + - if: '[ "$TASK_USE_DDEV" != "true" ]' + task: compose + vars: + TASK_ARGS: exec phpfpm php {{.TASK_ARGS}} + - if: '[ "$TASK_USE_DDEV" = "true" ]' + cmd: ddev php {{.TASK_ARGS}} default: cmds: diff --git a/composer.json b/composer.json index fad8d55..95ff344 100644 --- a/composer.json +++ b/composer.json @@ -30,17 +30,17 @@ }, "require-dev": { "ergebnis/composer-normalize": "^2.52", - "friendsofphp/php-cs-fixer": "^3.95.24", - "phpstan/phpstan": "^2.2.12", - "phpunit/phpunit": "^13.3", - "rector/rector": "^2.6", + "friendsofphp/php-cs-fixer": "^3.95.25", + "phpstan/phpstan": "^2.2.13", + "phpunit/phpunit": "^13.3.3", + "rector/rector": "^2.6.6", "symfony/browser-kit": "~8.1.0", "symfony/css-selector": "~8.1.6", "symfony/debug-bundle": "~8.1.0", "symfony/maker-bundle": "^1.67", "symfony/stopwatch": "~8.1.0", "symfony/web-profiler-bundle": "~8.1.0", - "vincentlanglet/twig-cs-fixer": "^4.1" + "vincentlanglet/twig-cs-fixer": "^4.1.1" }, "replace": { "symfony/polyfill-ctype": "*", diff --git a/composer.lock b/composer.lock index 2d8ddb4..5eceb64 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "dfaceee7643a3761619ee1e8ae943e6a", + "content-hash": "15f5017ca0bc1b5d638704a1f9d9a303", "packages": [ { "name": "composer/semver", @@ -5165,16 +5165,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.95.24", + "version": "v3.95.25", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "9a4b8050f8768646bf3693ee7416978ceeca6206" + "reference": "2cdfc1f3daf173d83a1ebb6177949b58c95de6ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/9a4b8050f8768646bf3693ee7416978ceeca6206", - "reference": "9a4b8050f8768646bf3693ee7416978ceeca6206", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/2cdfc1f3daf173d83a1ebb6177949b58c95de6ff", + "reference": "2cdfc1f3daf173d83a1ebb6177949b58c95de6ff", "shasum": "" }, "require": { @@ -5257,7 +5257,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.95.24" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.95.25" }, "funding": [ { @@ -5265,20 +5265,20 @@ "type": "github" } ], - "time": "2026-08-31T15:31:12+00:00" + "time": "2026-09-08T11:11:37+00:00" }, { "name": "justinrainbow/json-schema", - "version": "6.11.0", + "version": "6.12.0", "source": { "type": "git", "url": "https://github.com/jsonrainbow/json-schema.git", - "reference": "7e420a943a6fbc95e60e3cf67acfbee85b3b4da7" + "reference": "8ef236a1a37df364b518b7411a4b5bb95b040d79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/7e420a943a6fbc95e60e3cf67acfbee85b3b4da7", - "reference": "7e420a943a6fbc95e60e3cf67acfbee85b3b4da7", + "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/8ef236a1a37df364b518b7411a4b5bb95b040d79", + "reference": "8ef236a1a37df364b518b7411a4b5bb95b040d79", "shasum": "" }, "require": { @@ -5328,9 +5328,9 @@ ], "support": { "issues": "https://github.com/jsonrainbow/json-schema/issues", - "source": "https://github.com/jsonrainbow/json-schema/tree/6.11.0" + "source": "https://github.com/jsonrainbow/json-schema/tree/6.12.0" }, - "time": "2026-08-21T10:30:42+00:00" + "time": "2026-09-04T12:54:20+00:00" }, { "name": "localheinz/diff", @@ -5697,11 +5697,11 @@ }, { "name": "phpstan/phpstan", - "version": "2.2.12", + "version": "2.2.13", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/174b0d88710f00a42598886504dd7a146f91ace5", - "reference": "174b0d88710f00a42598886504dd7a146f91ace5", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9ba9ac76ee9c5cf5b56d58eb5deec6315b7a0260", + "reference": "9ba9ac76ee9c5cf5b56d58eb5deec6315b7a0260", "shasum": "" }, "require": { @@ -5757,20 +5757,20 @@ "type": "github" } ], - "time": "2026-08-31T19:09:43+00:00" + "time": "2026-09-03T20:38:19+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "14.3.1", + "version": "14.3.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "6ce313bb110384148d1dc7695a99175f59529069" + "reference": "93d62632fb675b76c9b941fdcfcfa10ffb9dea75" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6ce313bb110384148d1dc7695a99175f59529069", - "reference": "6ce313bb110384148d1dc7695a99175f59529069", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/93d62632fb675b76c9b941fdcfcfa10ffb9dea75", + "reference": "93d62632fb675b76c9b941fdcfcfa10ffb9dea75", "shasum": "" }, "require": { @@ -5789,7 +5789,7 @@ "theseer/tokenizer": "^2.0.1" }, "require-dev": { - "phpunit/phpunit": "^13.3.1" + "phpunit/phpunit": "^13.3.2" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -5827,7 +5827,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/14.3.1" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/14.3.2" }, "funding": [ { @@ -5847,7 +5847,7 @@ "type": "tidelift" } ], - "time": "2026-08-16T05:23:47+00:00" + "time": "2026-09-04T03:46:43+00:00" }, { "name": "phpunit/php-file-iterator", @@ -6144,16 +6144,16 @@ }, { "name": "phpunit/phpunit", - "version": "13.3.2", + "version": "13.3.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "22104a5ceb8d642e6b30ab00211d53d88e2db368" + "reference": "0d8711067516c1f6ba1a66f762e16c2fb1a8ccd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/22104a5ceb8d642e6b30ab00211d53d88e2db368", - "reference": "22104a5ceb8d642e6b30ab00211d53d88e2db368", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0d8711067516c1f6ba1a66f762e16c2fb1a8ccd1", + "reference": "0d8711067516c1f6ba1a66f762e16c2fb1a8ccd1", "shasum": "" }, "require": { @@ -6167,14 +6167,14 @@ "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=8.4.1", - "phpunit/php-code-coverage": "^14.3.1", + "phpunit/php-code-coverage": "^14.3.2", "phpunit/php-file-iterator": "^7.0.2", "phpunit/php-invoker": "^7.0.0", "phpunit/php-text-template": "^6.0.0", "phpunit/php-timer": "^9.0.0", "sebastian/cli-parser": "^5.0.1", "sebastian/comparator": "^8.4", - "sebastian/diff": "^9.0", + "sebastian/diff": "^9.0.1", "sebastian/environment": "^9.3.2", "sebastian/exporter": "^8.2.1", "sebastian/file-filter": "^1.0", @@ -6224,7 +6224,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/13.3.2" + "source": "https://github.com/sebastianbergmann/phpunit/tree/13.3.3" }, "funding": [ { @@ -6232,7 +6232,7 @@ "type": "other" } ], - "time": "2026-08-27T08:40:49+00:00" + "time": "2026-09-09T04:50:32+00:00" }, { "name": "react/cache", @@ -6762,16 +6762,16 @@ }, { "name": "rector/rector", - "version": "2.6.5", + "version": "2.6.6", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "f8686605798c755456327a3597201c3b5be76294" + "reference": "ca069d6c79feaa6651b423c15d101a27a436093e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/f8686605798c755456327a3597201c3b5be76294", - "reference": "f8686605798c755456327a3597201c3b5be76294", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/ca069d6c79feaa6651b423c15d101a27a436093e", + "reference": "ca069d6c79feaa6651b423c15d101a27a436093e", "shasum": "" }, "require": { @@ -6807,7 +6807,7 @@ ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/2.6.5" + "source": "https://github.com/rectorphp/rector/tree/2.6.6" }, "funding": [ { @@ -6815,7 +6815,7 @@ "type": "github" } ], - "time": "2026-08-30T22:02:04+00:00" + "time": "2026-09-02T09:38:46+00:00" }, { "name": "sebastian/cli-parser", @@ -8699,16 +8699,16 @@ }, { "name": "vincentlanglet/twig-cs-fixer", - "version": "4.1.0", + "version": "4.1.1", "source": { "type": "git", "url": "https://github.com/VincentLanglet/Twig-CS-Fixer.git", - "reference": "73f6474720fce9a6709e7b6cdd26574efe36d09b" + "reference": "53c1234b6e5d87ac2beaf686774bba013697f9c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/VincentLanglet/Twig-CS-Fixer/zipball/73f6474720fce9a6709e7b6cdd26574efe36d09b", - "reference": "73f6474720fce9a6709e7b6cdd26574efe36d09b", + "url": "https://api.github.com/repos/VincentLanglet/Twig-CS-Fixer/zipball/53c1234b6e5d87ac2beaf686774bba013697f9c5", + "reference": "53c1234b6e5d87ac2beaf686774bba013697f9c5", "shasum": "" }, "require": { @@ -8764,7 +8764,7 @@ "homepage": "https://github.com/VincentLanglet/Twig-CS-Fixer", "support": { "issues": "https://github.com/VincentLanglet/Twig-CS-Fixer/issues", - "source": "https://github.com/VincentLanglet/Twig-CS-Fixer/tree/4.1.0" + "source": "https://github.com/VincentLanglet/Twig-CS-Fixer/tree/4.1.1" }, "funding": [ { @@ -8772,7 +8772,7 @@ "type": "github" } ], - "time": "2026-08-30T16:07:04+00:00" + "time": "2026-09-08T21:26:25+00:00" } ], "aliases": [], diff --git a/docker-compose.override.yml b/docker-compose.override.yml new file mode 100644 index 0000000..d63ff9a --- /dev/null +++ b/docker-compose.override.yml @@ -0,0 +1,10 @@ +include: + - docker-compose.scorpio.yml + +services: + # We don't (yet?) need a database. + mariadb: !reset + + phpfpm: + image: itkdev/php8.5-fpm:latest + depends_on: !reset diff --git a/docker-compose.scorpio.yml b/docker-compose.scorpio.yml new file mode 100644 index 0000000..2a5bb02 --- /dev/null +++ b/docker-compose.scorpio.yml @@ -0,0 +1,36 @@ +networks: + scorpio: + +services: + scorpio: + image: scorpiobroker/all-in-one-runner:java-latest + restart: "no" + ports: + - "9090" + environment: + - HTTP_EXPOSE=9090:9999 + - DBHOST=scorpio-db + depends_on: + - "scorpio-db" + networks: + frontend: + app: + aliases: [scorpio.local] + scorpio: + platform: "linux/amd64" + labels: + - "traefik.enable=true" + - "traefik.docker.network=frontend" + - "traefik.http.routers.scorpio_${COMPOSE_PROJECT_NAME:?}.rule=Host(`scorpio.${COMPOSE_DOMAIN:?}`)" + + scorpio-db: + image: postgis/postgis + environment: + - POSTGRES_USER=ngb + - POSTGRES_PASSWORD=ngb + - POSTGRES_DB=ngb + networks: + - scorpio + platform: "linux/amd64" + # https://stackoverflow.com/a/58806511 + command: ["postgres", "-c", "log_statement=all"] diff --git a/docker-compose.server.override.yml b/docker-compose.server.override.yml index 9a3a124..3eabfdd 100644 --- a/docker-compose.server.override.yml +++ b/docker-compose.server.override.yml @@ -1,15 +1,13 @@ networks: scorpio: -# https://docs.ddev.com/en/stable/users/extend/custom-docker-services/ services: phpfpm: image: itkdev/php8.5-fpm:alpine scorpio: - hostname: scorpio.local image: scorpiobroker/all-in-one-runner:java-latest - restart: "no" + restart: unless-stopped ports: - "9090" environment: @@ -17,20 +15,25 @@ services: depends_on: - "scorpio-db" networks: - - app - - scorpio + app: + aliases: [scorpio.local] + scorpio: platform: "linux/amd64" scorpio-db: image: postgis/postgis + restart: unless-stopped environment: - POSTGRES_USER=ngb - POSTGRES_PASSWORD=ngb - POSTGRES_DB=ngb + healthcheck: + test: ["CMD-SHELL", "pg_isready --username=ngb --dbname=ngb"] + start_period: 10s + interval: 5s + timeout: 5s + retries: 10 networks: - scorpio volumes: - ./.docker/data/scorpio-db:/var/lib/postgresql/data - platform: "linux/amd64" - # https://stackoverflow.com/a/58806511 - command: ["postgres", "-c", "log_statement=all"]