diff --git a/.dockerignore b/.dockerignore index 42366c5..61d63c0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ /README.md +/.github/ \ No newline at end of file diff --git a/.env.example b/.env.example index 1ca2a4c..51b7c72 100644 --- a/.env.example +++ b/.env.example @@ -2,6 +2,12 @@ export DOCKER_UID=1000 +export COMPOSE_PROJECT_NAME=atdc +export COMPOSE_PROFILES=web,php,database + +export DOCKER_WEB_VOLUME=.:/app + +export DRUSH_OPTIONS_URI="https://${COMPOSE_PROJECT_NAME}.docker.localhost" export MYSQL_DATABASE=app export MYSQL_PASSWORD=app diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100755 index 0000000..54ac104 --- /dev/null +++ b/.githooks/pre-push @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. + +set -o errexit + +export TTY="-T" + +./run test:commit diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..868fe2e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: CI + +on: + pull_request: + push: + workflow_dispatch: + +env: + COMPOSE_DOCKER_CLI_BUILD: 1 + DOCKER_BUILDKIT: 1 + DOCKER_UID: 1001 + +jobs: + build_and_test: + name: Build and test + + runs-on: ubuntu-latest + + steps: + - name: Checkout the code + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + + - name: Build and test + run: | + ./run ci:test diff --git a/.gitignore b/.gitignore index dc4f724..01d9ebb 100644 --- a/.gitignore +++ b/.gitignore @@ -36,5 +36,7 @@ web/themes/contrib/ web/update.php web/web.config +# Docker. +.env +docker-compose.override.yaml -.dir-env/ diff --git a/Dockerfile b/Dockerfile index 1bbd1c8..8c50188 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. -FROM php: AS base +FROM php:8.2-fpm-bullseye AS base COPY --from=composer:2 /usr/bin/composer /usr/bin/composer RUN which composer && composer -V @@ -42,6 +42,8 @@ COPY --chown=app:app phpunit.xml* ./ USER app +RUN composer validate --strict +RUN composer install COPY --chown=app:app tools/docker/images/php/root / @@ -51,3 +53,12 @@ CMD ["php-fpm"] +################################################################################ + +FROM nginx:1 as web + +EXPOSE 8080 + +WORKDIR /app + +COPY tools/docker/images/web/root / diff --git a/build-configs.yaml b/build-configs.yaml index 129f333..92febf7 100644 --- a/build-configs.yaml +++ b/build-configs.yaml @@ -2,18 +2,43 @@ name: atdc template: drupal parameters: - flake: - devshell: - packages: - - php82 - - php82Packages.composer + web: + type: nginx - git: - ignore: - - '!/_lessons/**' - - '!/phpstan.neon' - - '!/tests/**' + database: + type: mariadb + version: 10 + + php: + version: 8.2-fpm-bullseye + phpcs: + paths: + - web/modules/custom + standards: + - Drupal + - DrupalPractice + phpstan: + level: max + paths: + - web/modules/custom + + drupal: + docroot: web + + docker-compose: + services: + - database + - php + - web + + dockerfile: + stages: + build: + commands: + - composer validate --strict + - composer install experimental: - createTmuxStartupFile: true - createInclusiveGitIgnoreFile: true + createGitHubActionsConfiguration: true + runGitHooksBeforePush: true + useNewDatabaseCredentials: true diff --git a/docker-compose.yaml b/docker-compose.yaml index 4d74a4f..dcbebe0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -30,6 +30,14 @@ x-app: &default-app tty: true services: + web: + <<: [*default-proxy, *default-app] + build: + context: . + target: web + depends_on: + - php + profiles: [web] php: <<: [*default-app] @@ -40,10 +48,12 @@ services: - "DOCKER_UID=${DOCKER_UID:-1000}" volumes: - .:/app + depends_on: + - database profiles: [php] database: - image: : + image: mariadb:10 deploy: resources: limits: diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 9912848..85d076e 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -4,6 +4,7 @@ PHPCS configuration file for atdc. + web/modules/custom diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 8a1dc84..a5a696c 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,9 +1,9 @@ # Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. parameters: - level: + level: max excludePaths: - *Test.php - *TestBase.php paths: - + - web/modules/custom 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 new file mode 100644 index 0000000..13e395a --- /dev/null +++ b/tools/docker/images/web/root/etc/nginx/conf.d/default.conf @@ -0,0 +1,22 @@ +# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. + +server { + server_name _; + + root /app/web; + + location / { + try_files $uri /index.php?$query_string; + } + + location ~ \.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(|/.*)$; + try_files $fastcgi_script_name =404; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param QUERY_STRING $query_string; + fastcgi_intercept_errors on; + fastcgi_pass php:9000; + } +}