From 1c8d5c87f9c1e15402a05646e1b980ec404f32ed Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 14 Mar 2023 20:20:48 +0000 Subject: [PATCH] build: update configuration files --- .dockerignore | 33 +----------- .env.example | 8 +++ Dockerfile | 27 ++++++++-- docker-compose.yaml | 10 ++-- justfile | 8 +++ phpcs.xml.dist | 1 + phpstan.neon.dist | 2 + phpunit.xml.dist | 53 ++++++++++++------- .../root/usr/local/bin/docker-entrypoint-php | 2 + .../web/root/etc/nginx/conf.d/default.conf | 2 + 10 files changed, 88 insertions(+), 58 deletions(-) diff --git a/.dockerignore b/.dockerignore index 94e2ede..6b276be 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,31 +1,2 @@ -/.editorconfig -/.gitattributes -/vendor/ -/web/.csslintrc -/web/.eslintignore -/web/.eslintrc.json -/web/.ht.router.php -/web/.htaccess -/web/INSTALL.txt -/web/README.md -/web/autoload.php -/web/core/ -/web/example.gitignore -/web/index.php -/web/modules/README.txt -/web/profiles/README.txt -/web/robots.txt -/web/sites/*/files/ -/web/sites/*/private/ -/web/sites/*/services*.yml -/web/sites/*/settings*.php -/web/sites/README.txt -/web/sites/default/default.services.yml -/web/sites/default/default.settings.php -/web/sites/development.services.yml -/web/sites/example.settings.local.php -/web/sites/example.sites.php -/web/sites/simpletest/ -/web/themes/README.txt -/web/update.php -/web/web.config +/.github +/README.md diff --git a/.env.example b/.env.example index 01b5668..cf1d14c 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,12 @@ +# Do not edit this file. It is automatically generated by 'build-configs'. + +export DOCKER_UID=1000 + export COMPOSE_PROJECT_NAME=docker-example-drupal export COMPOSE_PROFILES=web,php,database export DOCKER_WEB_VOLUME=.:/app + +export MYSQL_DATABASE=drupal +export MYSQL_PASSWORD=drupal +export MYSQL_USER=drupal diff --git a/Dockerfile b/Dockerfile index fb10f5d..3457b40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,46 @@ +# Do not edit this file. It is automatically generated by 'build-configs'. + FROM php:8.1-fpm-bullseye AS base COPY --from=composer:2 /usr/bin/composer /usr/bin/composer RUN which composer && composer -V +ARG DOCKER_UID=1000 +ENV DOCKER_UID="${DOCKER_UID}" + WORKDIR /app -ENV PATH="${PATH}:/app/vendor/bin" +RUN adduser --disabled-password --uid "${DOCKER_UID}" app \ + && chown app:app -R /app -COPY composer.* ./ +USER app + +ENV PATH="${PATH}:/app/bin:/app/vendor/bin" + +COPY --chown=app:app composer.* ./ ################################################################################ FROM base AS build +USER root + RUN apt-get update -yqq \ && apt-get install -yqq --no-install-recommends \ git libpng-dev libzip-dev mariadb-client unzip RUN docker-php-ext-install gd pdo_mysql zip +COPY --chown=app:app phpunit.xml* ./ + + + +USER app RUN composer validate RUN composer install -COPY tools/docker/images/php/root / +COPY --chown=app:app tools/docker/images/php/root / ENTRYPOINT ["/usr/local/bin/docker-entrypoint-php"] CMD ["php-fpm"] @@ -32,13 +49,15 @@ CMD ["php-fpm"] FROM base AS test -COPY . . +COPY --chown=app:app . . RUN parallel-lint src --no-progress \ && phpcs -vv \ && phpstan \ && phpunit --testdox + + ################################################################################ FROM nginx:1 as web diff --git a/docker-compose.yaml b/docker-compose.yaml index 4c51799..3fd36d2 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,3 +1,5 @@ +# Do not edit this file. It is automatically generated by 'build-configs'. + x-app: &default-app volumes: - "${DOCKER_WEB_VOLUME:-./web:/app/web}" @@ -32,12 +34,14 @@ services: `${COMPOSE_PROJECT_NAME}.localhost`, )" profiles: [web] - + php: <<: *default-app build: context: . target: build + volumes: + - .:/app depends_on: - database profiles: [php] @@ -57,14 +61,10 @@ services: - "traefik.enabled=false" environment: MYSQL_RANDOM_ROOT_PASSWORD: true - MYSQL_DATABASE: drupal - MYSQL_PASSWORD: drupal - MYSQL_USER: drupal profiles: [database] volumes: db-data: {} - networks: web: name: traefik_proxy diff --git a/justfile b/justfile index f49acb5..b675064 100644 --- a/justfile +++ b/justfile @@ -1,3 +1,5 @@ +# Do not edit this file. It is automatically generated by 'build-configs'. + default: @just --list @@ -7,5 +9,11 @@ composer *args: drush *args: just _exec php drush {{ args }} +install *args: + just _exec php drush site:install -y {{ args }} + + + + _exec +args: docker compose exec {{ args }} diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 4fcef96..2595fde 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,3 +1,4 @@ + PHPCS configuration file for docker-example-drupal. diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 76bd437..b629b09 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,3 +1,5 @@ +# Do not edit this file. It is automatically generated by 'build-configs'. + parameters: level: max paths: diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 76faa41..b996820 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,20 +1,37 @@ + - - - - tests - - + + + + + + + + + + + + + + + + + ./web/modules/custom/**/tests/**/Functional + + + ./web/modules/custom/**/tests/**/Kernel + + + ./web/modules/custom/**/tests/**/Unit + + diff --git a/tools/docker/images/php/root/usr/local/bin/docker-entrypoint-php b/tools/docker/images/php/root/usr/local/bin/docker-entrypoint-php index 564778b..bf993a7 100755 --- a/tools/docker/images/php/root/usr/local/bin/docker-entrypoint-php +++ b/tools/docker/images/php/root/usr/local/bin/docker-entrypoint-php @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# Do not edit this file. It is automatically generated by 'build-configs'. + [[ -f composer.json && ! -d vendor ]] && composer install eval "$@" diff --git a/tools/docker/images/web/root/etc/nginx/conf.d/default.conf b/tools/docker/images/web/root/etc/nginx/conf.d/default.conf index b032e23..a2dd12d 100644 --- a/tools/docker/images/web/root/etc/nginx/conf.d/default.conf +++ b/tools/docker/images/web/root/etc/nginx/conf.d/default.conf @@ -1,3 +1,5 @@ +# Do not edit this file. It is automatically generated by 'build-configs'. + server { server_name _;