diff --git a/.github/workflows/ALL-phpunit.yml b/.github/workflows/ALL-phpunit.yml index e8c1e67af..a556abb21 100644 --- a/.github/workflows/ALL-phpunit.yml +++ b/.github/workflows/ALL-phpunit.yml @@ -14,11 +14,20 @@ jobs: php-version: - "8.1" - "8.2" + - "8.3" pgsql-version: - "13" drupal-version: - "10.0.x-dev" - "10.1.x-dev" + - "10.2.x-dev" + exclude: + - php-version: "8.3" + pgsql-version: "13" + drupal-version: "10.0.x-dev" + - php-version: "8.3" + pgsql-version: "13" + drupal-version: "10.1.x-dev" steps: # Check out the repo diff --git a/.github/workflows/MAIN-buildDocker.yml b/.github/workflows/MAIN-buildDocker.yml index 347d9be28..3ca104197 100644 --- a/.github/workflows/MAIN-buildDocker.yml +++ b/.github/workflows/MAIN-buildDocker.yml @@ -15,11 +15,20 @@ jobs: php-version: - "8.1" - "8.2" + - "8.3" pgsql-version: - "13" drupal-version: - "10.0.x-dev" - "10.1.x-dev" + - "10.2.x-dev" + exclude: + - php-version: "8.3" + pgsql-version: "13" + drupal-version: "10.0.x-dev" + - php-version: "8.3" + pgsql-version: "13" + drupal-version: "10.1.x-dev" name: Docker Build (drupal${{ matrix.drupal-version }}) steps: - uses: actions/checkout@v3 @@ -59,8 +68,8 @@ jobs: buildArgs: "drupalversion=${{ matrix.drupal-version }}" labels: 'tripal.branch=4.x,drupal.version.label="${{ matrix.label }}",php.version.label="${{ matrix.php-version }}", postgresql.version.label="${{ matrix.pgsql-version }}"' - uses: mr-smithers-excellent/docker-build-push@v6 - name: Build latest using 10.0.x-dev, PHP 8.1, PgSQL 13 - if: ${{ matrix.drupal-version == '10.0.x-dev' && matrix.php-version == '8.1' && matrix.pgsql-version == '13' }} + name: Build latest using 10.2.x-dev, PHP 8.3, PgSQL 13 + if: ${{ matrix.drupal-version == '10.2.x-dev' && matrix.php-version == '8.3' && matrix.pgsql-version == '13' }} with: image: tripalproject/tripaldocker tags: latest diff --git a/.github/workflows/MAIN-phpunit-php8.1_D10_0x.yml b/.github/workflows/MAIN-phpunit-php8.1_D10_0x.yml index d76ce0384..94eebeb89 100644 --- a/.github/workflows/MAIN-phpunit-php8.1_D10_0x.yml +++ b/.github/workflows/MAIN-phpunit-php8.1_D10_0x.yml @@ -3,7 +3,6 @@ on: push: branches: - 4.x - - tv4g0-issue1673-remove-drupal-9 jobs: running-tests: name: "Drupal 10.0: PHP 8.1" diff --git a/.github/workflows/MAIN-phpunit-php8.1_D10_1x.yml b/.github/workflows/MAIN-phpunit-php8.1_D10_1x.yml index 7cf1a219d..9a8b9fc9b 100644 --- a/.github/workflows/MAIN-phpunit-php8.1_D10_1x.yml +++ b/.github/workflows/MAIN-phpunit-php8.1_D10_1x.yml @@ -3,7 +3,6 @@ on: push: branches: - 4.x - - tv4g0-issue1673-remove-drupal-9 jobs: running-tests: name: "Drupal 10.1: PHP 8.1" diff --git a/.github/workflows/MAIN-phpunit-php8.1_D10_2x.yml b/.github/workflows/MAIN-phpunit-php8.1_D10_2x.yml new file mode 100644 index 000000000..69010775c --- /dev/null +++ b/.github/workflows/MAIN-phpunit-php8.1_D10_2x.yml @@ -0,0 +1,22 @@ +name: PHPUnit +on: + push: + branches: + - 4.x +jobs: + running-tests: + name: "Drupal 10.2: PHP 8.1" + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Run Automated testing + uses: tripal/test-tripal-action@v1.2 + with: + directory-name: 'tripal' + modules: 'tripal tripal_biodb tripal_chado' + php-version: '8.1' + pgsql-version: '13' + drupal-version: '10.2.x-dev' + build-image: true + dockerfile: "UseTripalDockerBackupClause" diff --git a/.github/workflows/MAIN-phpunit-php8.2_D10_0x.yml b/.github/workflows/MAIN-phpunit-php8.2_D10_0x.yml index a56148d27..94c54b6e3 100644 --- a/.github/workflows/MAIN-phpunit-php8.2_D10_0x.yml +++ b/.github/workflows/MAIN-phpunit-php8.2_D10_0x.yml @@ -3,7 +3,6 @@ on: push: branches: - 4.x - - tv4g0-issue1673-remove-drupal-9 jobs: running-tests: name: "Drupal 10.0: PHP 8.2" diff --git a/.github/workflows/MAIN-phpunit-php8.2_D10_1x.yml b/.github/workflows/MAIN-phpunit-php8.2_D10_1x.yml index 068f834b8..0861fea5d 100644 --- a/.github/workflows/MAIN-phpunit-php8.2_D10_1x.yml +++ b/.github/workflows/MAIN-phpunit-php8.2_D10_1x.yml @@ -3,7 +3,6 @@ on: push: branches: - 4.x - - tv4g0-issue1673-remove-drupal-9 jobs: running-tests: name: "Drupal 10.1: PHP 8.2" diff --git a/.github/workflows/MAIN-phpunit-php8.2_D10_2x.yml b/.github/workflows/MAIN-phpunit-php8.2_D10_2x.yml new file mode 100644 index 000000000..4d94f7183 --- /dev/null +++ b/.github/workflows/MAIN-phpunit-php8.2_D10_2x.yml @@ -0,0 +1,22 @@ +name: PHPUnit +on: + push: + branches: + - 4.x +jobs: + running-tests: + name: "Drupal 10.2: PHP 8.2" + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Run Automated testing + uses: tripal/test-tripal-action@v1.2 + with: + directory-name: 'tripal' + modules: 'tripal tripal_biodb tripal_chado' + php-version: '8.2' + pgsql-version: '13' + drupal-version: '10.2.x-dev' + build-image: true + dockerfile: "UseTripalDockerBackupClause" diff --git a/.github/workflows/MAIN-phpunit-php8.3_D10_2x.yml b/.github/workflows/MAIN-phpunit-php8.3_D10_2x.yml new file mode 100644 index 000000000..aa9a0b672 --- /dev/null +++ b/.github/workflows/MAIN-phpunit-php8.3_D10_2x.yml @@ -0,0 +1,22 @@ +name: PHPUnit +on: + push: + branches: + - 4.x +jobs: + running-tests: + name: "Drupal 10.2: PHP 8.3" + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Run Automated testing + uses: tripal/test-tripal-action@v1.2 + with: + directory-name: 'tripal' + modules: 'tripal tripal_biodb tripal_chado' + php-version: '8.3' + pgsql-version: '13' + drupal-version: '10.2.x-dev' + build-image: true + dockerfile: "UseTripalDockerBackupClause" diff --git a/README.md b/README.md index e7527630d..6444d59e3 100755 --- a/README.md +++ b/README.md @@ -18,16 +18,21 @@ ![PostgreSQL 13](https://img.shields.io/badge/PostreSQL-13-success) -| Drupal | 10.0.x | 10.1.x | -|-------------|-----------------|-----------------| -| **PHP 8.1** | ![Grid1A-Badge] | ![Grid1B-Badge] | -| **PHP 8.2** | ![Grid2A-Badge] | ![Grid2B-Badge] | +| Drupal | 10.0.x | 10.1.x | 10.2.x | +|-------------|-----------------|-----------------|-----------------| +| **PHP 8.1** | ![Grid1A-Badge] | ![Grid1B-Badge] | ![Grid1C-Badge] | +| **PHP 8.2** | ![Grid2A-Badge] | ![Grid2B-Badge] | ![Grid2C-Badge] | +| **PHP 8.3** | | | ![Grid3C-Badge] | [Grid1A-Badge]: https://github.com/tripal/tripal/actions/workflows/MAIN-phpunit-php8.1_D10_0x.yml/badge.svg [Grid1B-Badge]: https://github.com/tripal/tripal/actions/workflows/MAIN-phpunit-php8.1_D10_1x.yml/badge.svg +[Grid1C-Badge]: https://github.com/tripal/tripal/actions/workflows/MAIN-phpunit-php8.1_D10_2x.yml/badge.svg [Grid2A-Badge]: https://github.com/tripal/tripal/actions/workflows/MAIN-phpunit-php8.2_D10_0x.yml/badge.svg [Grid2B-Badge]: https://github.com/tripal/tripal/actions/workflows/MAIN-phpunit-php8.2_D10_1x.yml/badge.svg +[Grid2C-Badge]: https://github.com/tripal/tripal/actions/workflows/MAIN-phpunit-php8.2_D10_2x.yml/badge.svg + +[Grid3C-Badge]: https://github.com/tripal/tripal/actions/workflows/MAIN-phpunit-php8.3_D10_2x.yml/badge.svg ### Code Coverage diff --git a/tripal/.tripal.routing.yml.swp b/tripal/.tripal.routing.yml.swp new file mode 100644 index 000000000..e8675048a Binary files /dev/null and b/tripal/.tripal.routing.yml.swp differ diff --git a/tripal/src/TripalDBX/TripalDbx.php b/tripal/src/TripalDBX/TripalDbx.php index 5b3447a07..872080e19 100644 --- a/tripal/src/TripalDBX/TripalDbx.php +++ b/tripal/src/TripalDBX/TripalDbx.php @@ -99,7 +99,8 @@ public function getDrupalSchemaName() :string { // Get Drupal connection details. $drupal_database = \Drupal::database(); $connection_options = $drupal_database->getConnectionOptions(); - if (array_key_exists('driver', $connection_options) AND ($connection_options['driver'] != 'pgsql')) { + // Drupal <= 10.1 driver will be 'pgsql', Drupal 10.2 it will be 'Drupal\pgsql\Driver\Database\pgsql' + if (array_key_exists('driver', $connection_options) AND (!preg_match('/pgsql$/', $connection_options['driver']))) { // Not using PostgreSQL. There might be something wrong! // @todo we may want to evaluate this further as it does tie our Drupal // database to being in pgsql. It doesn't support the case where Drupal diff --git a/tripal/tests/src/Functional/TripalRoutePermissionsTest.php b/tripal/tests/src/Functional/Permissions/TripalRoutePermissionsTest.php similarity index 98% rename from tripal/tests/src/Functional/TripalRoutePermissionsTest.php rename to tripal/tests/src/Functional/Permissions/TripalRoutePermissionsTest.php index 4937ccb8b..5802c1fe7 100644 --- a/tripal/tests/src/Functional/TripalRoutePermissionsTest.php +++ b/tripal/tests/src/Functional/Permissions/TripalRoutePermissionsTest.php @@ -35,16 +35,18 @@ public function testTripalAdminPages() { 'Tripal' => 'admin/tripal', 'Registration' => 'admin/tripal/register', 'Jobs' => 'admin/tripal/tripal_jobs', - 'Data Loaders' => 'admin/tripal/loaders', 'Data Collections' => 'admin/tripal/data-collections', 'Tripal Managed Files' => 'admin/tripal/files', 'Tripal Content Terms' => 'admin/tripal/config/terms', - 'Data Storage' => 'admin/tripal/storage', - 'Extensions' => 'admin/tripal/extension', + // Under Drupal ~10.2, if there are no extensions present, and there aren't, then + // we won't be able to access the 'admin/tripal/extension' menu, even as admin. + // To test, we would have to create an extension first. + // 'Extensions' => 'admin/tripal/extension', ]; $userAuthenticatedOnly = $this->drupalCreateUser(); - $userTripalAdmin = $this->drupalCreateUser(['administer tripal']); + // Drupal 10.2 tightens permissions, second permission is needed to access files path + $userTripalAdmin = $this->drupalCreateUser(['administer tripal', 'admin tripal files']); // First check all the URLs with no user logged in. // This checks the anonymous user cannot access these pages. diff --git a/tripal_chado/src/Plugin/TripalImporter/GFF3Importer.php b/tripal_chado/src/Plugin/TripalImporter/GFF3Importer.php index d50197e7d..3ea7a20ff 100644 --- a/tripal_chado/src/Plugin/TripalImporter/GFF3Importer.php +++ b/tripal_chado/src/Plugin/TripalImporter/GFF3Importer.php @@ -1920,6 +1920,7 @@ private function getCachedFeature($findex) { ['%findex' => $findex, '%file' -> $this->gff_cache_file])); } $feature = fgets($this->gff_cache_file); + $feature = rtrim($feature, "\n"); $feature = unserialize($feature); return $feature; } diff --git a/tripal_chado/src/Task/ChadoPreparer.php b/tripal_chado/src/Task/ChadoPreparer.php index fe4cafea6..483198e49 100644 --- a/tripal_chado/src/Task/ChadoPreparer.php +++ b/tripal_chado/src/Task/ChadoPreparer.php @@ -136,7 +136,7 @@ public function performTask() :bool { $this->chado_schema_main = $schema_name; $chado = \Drupal::service('tripal_chado.database'); $chado->setSchemaName($schema_name); - $chado->useTripalDbxSchemaFor(get_class()); + $chado->useTripalDbxSchemaFor(self::class); try { diff --git a/tripal_chado/src/TripalImporter/ChadoImporterBase.php b/tripal_chado/src/TripalImporter/ChadoImporterBase.php index 26a46578c..8995f9f81 100644 --- a/tripal_chado/src/TripalImporter/ChadoImporterBase.php +++ b/tripal_chado/src/TripalImporter/ChadoImporterBase.php @@ -103,7 +103,7 @@ public function getChadoConnection() { if ($chado->getSchemaName() != $schema_name) { $chado->setSchemaName($schema_name); } - $chado->useTripalDbxSchemaFor(get_class()); + $chado->useTripalDbxSchemaFor(self::class); return $chado; } diff --git a/tripal_chado/tests/src/Functional/Permissions/TripalChadoRoutePermissionsTest.php b/tripal_chado/tests/src/Functional/Permissions/TripalChadoRoutePermissionsTest.php new file mode 100644 index 000000000..8328d2c3a --- /dev/null +++ b/tripal_chado/tests/src/Functional/Permissions/TripalChadoRoutePermissionsTest.php @@ -0,0 +1,94 @@ +getSession(); + + // The URLs to check with the key being the label expected in the + // Tripal admin menu listing. + $urls = [ + 'Data Loaders' => 'admin/tripal/loaders', + 'Data Storage' => 'admin/tripal/storage', + ]; + + $userAuthenticatedOnly = $this->drupalCreateUser(); + // Drupal 10.2 tightens permissions, second permission is needed to access importers + $userTripalAdmin = $this->drupalCreateUser(['administer tripal', 'allow tripal import']); + + // First check all the URLs with no user logged in. + // This checks the anonymous user cannot access these pages. + foreach ($urls as $title => $path) { + $html = $this->drupalGet($path); + $status_code = $session->getStatusCode(); + $this->assertEquals(403, $status_code, "The anonymous user should not be able to access this admin page: $title."); + } + + // Next check all the URLs with the authenticated, unprivileged user. + // This checks generic authenticated users cannot access these pages. + $this->drupalLogin($userAuthenticatedOnly); + $this->assertFalse($userAuthenticatedOnly->hasPermission('administer tripal'), "The unprivileged user should not have the 'administer tripal' permission."); + foreach ($urls as $title => $path) { + $html = $this->drupalGet($path); + $status_code = $session->getStatusCode(); + $this->assertEquals(403, $status_code, "The unprivileged user should not be able to access this admin page: $title."); + } + + // Finally check all URLs with the authenticated, privileged user. + // This checks privileged users can access these pages. + $this->drupalLogin($userTripalAdmin); + $this->assertTrue($this->drupalUserIsLoggedIn($userTripalAdmin), "The privileged user should be logged in."); + $this->assertTrue($userTripalAdmin->hasPermission('administer tripal'), "The privileged user should have the 'administer tripal' permission."); + foreach ($urls as $title => $path) { + $html = $this->drupalGet($path); + $status_code = $session->getStatusCode(); + $this->assertEquals(200, $status_code, "The privileged user should be able to access this admin page: $title which should be at '$path'."); + } + + // Test that the Tripal admin menu includes the above links. + // We use try/catch here because WebAssert throws exceptions which are not very readable. + $assert = $this->assertSession(); + $html = $this->drupalGet('admin/tripal'); + unset($urls['Tripal']); + foreach ($urls as $label => $path) { + // -- Find links with the label. + try { + $assert->linkExists($label, 0); + } + catch (Exception $e) { + $this->assertTrue(FALSE, "The '$label' link should exist in the Tripal admin listing."); + } + + // -- Find links with the URL/path. + try { + $assert->linkByHrefExists($path, 0); + } + catch (Exception $e) { + $this->assertTrue(FALSE, "The '$path' link should exist in the Tripal admin listing."); + } + } + } + +} diff --git a/tripaldocker/Dockerfile-php8.1-pgsql13 b/tripaldocker/Dockerfile-php8.1-pgsql13 index 7443bcb60..0f51f18bb 100644 --- a/tripaldocker/Dockerfile-php8.1-pgsql13 +++ b/tripaldocker/Dockerfile-php8.1-pgsql13 @@ -1,13 +1,13 @@ FROM php:8.1-apache-bullseye -ARG drupalversion='10.0.x-dev' +ARG drupalversion='~10.1.0' ARG modules='devel devel_php' ARG chadoschema='chado' ARG installchado=TRUE # Label docker image LABEL drupal.version=${drupalversion} -LABEL drupal.stability="development" +LABEL drupal.stability="production" LABEL tripal.version="4.x-dev" LABEL tripal.stability="development" LABEL os.version="bullseye" @@ -178,7 +178,7 @@ RUN cd /var/www/drupal \ --account-name=drupaladmin \ --account-pass=some_admin_password \ --site-mail="drupaladmin@localhost" \ - --site-name="Tripal 4 on Drupal 10 DEVELOPMENT" \ + --site-name="Tripal 4.x-dev on Drupal ${drupalversion}" \ && service apache2 stop \ && service postgresql stop @@ -210,7 +210,7 @@ RUN mv /app/tripaldocker/init_scripts/supervisord.conf /etc/supervisord.conf \ && mv /app/tripaldocker/default_files/xdebug/xdebug_toggle.sh /usr/bin/xdebug_toggle.sh \ && echo "\$config['system.logging']['error_level'] = 'verbose';" >> /var/www/drupal/web/sites/default/settings.php -## Make global commands. +## Make global commands. Symlink for drupal9 is for backward compatibility. RUN ln -s /var/www/drupal/vendor/phpunit/phpunit/phpunit /usr/local/bin/ \ && ln -s /var/www/drupal/vendor/drush/drush/drush /usr/local/bin/ \ && ln -s /var/www/drupal /var/www/drupal9 diff --git a/tripaldocker/Dockerfile-php8.2-pgsql13 b/tripaldocker/Dockerfile-php8.2-pgsql13 index 79a4252aa..e9e045510 100644 --- a/tripaldocker/Dockerfile-php8.2-pgsql13 +++ b/tripaldocker/Dockerfile-php8.2-pgsql13 @@ -210,7 +210,7 @@ RUN mv /app/tripaldocker/init_scripts/supervisord.conf /etc/supervisord.conf \ && mv /app/tripaldocker/default_files/xdebug/xdebug_toggle.sh /usr/bin/xdebug_toggle.sh \ && echo "\$config['system.logging']['error_level'] = 'verbose';" >> /var/www/drupal/web/sites/default/settings.php -## Make global commands. +## Make global commands. Symlink for drupal9 is for backward compatibility. RUN ln -s /var/www/drupal/vendor/phpunit/phpunit/phpunit /usr/local/bin/ \ && ln -s /var/www/drupal/vendor/drush/drush/drush /usr/local/bin/ \ && ln -s /var/www/drupal /var/www/drupal9 diff --git a/tripaldocker/Dockerfile-php8.3-pgsql13 b/tripaldocker/Dockerfile-php8.3-pgsql13 new file mode 100644 index 000000000..8288840ad --- /dev/null +++ b/tripaldocker/Dockerfile-php8.3-pgsql13 @@ -0,0 +1,224 @@ +FROM php:8.3-apache-bullseye + +ARG drupalversion='~10.2.0' +ARG modules='devel devel_php' +ARG chadoschema='chado' +ARG installchado=TRUE + +# Label docker image +LABEL drupal.version=${drupalversion} +LABEL drupal.stability="production" +LABEL tripal.version="4.x-dev" +LABEL tripal.stability="development" +LABEL os.version="bullseye" +LABEL php.version="8.3" +LABEL postgresql.version="13" + +COPY . /app + +## Install some basic support programs and update apt-get. +RUN chmod -R +x /app && apt-get update 1> ~/aptget.update.log \ + && apt-get install git unzip zip wget gnupg2 supervisor vim --yes -qq 1> ~/aptget.extras.log + +########## POSTGRESQL ######################################################### + +## See https://stackoverflow.com/questions/51033689/how-to-fix-error-on-postgres-install-ubuntu +RUN mkdir -p /usr/share/man/man1 && mkdir -p /usr/share/man/man7 + +## Install PostgreSQL 13 +RUN DEBIAN_FRONTEND=noninteractive apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql-13 postgresql-client-13 postgresql-contrib-13 + +## Run the rest of the commands as the ``postgres`` user +## created by the ``postgres-13`` package when it was installed. +USER postgres + +## Create a PostgreSQL role named ``docker`` with ``docker`` as the password and +## then create a database `docker` owned by the ``docker`` role. +RUN /etc/init.d/postgresql start &&\ + psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" \ + && createdb -O docker docker \ + && psql --command="CREATE USER drupaladmin WITH PASSWORD 'drupaldevelopmentonlylocal'" \ + && psql --command="ALTER USER drupaladmin WITH LOGIN" \ + && psql --command="ALTER USER drupaladmin WITH CREATEDB" \ + && psql --command="CREATE DATABASE sitedb WITH OWNER drupaladmin" \ + && psql sitedb --command="CREATE EXTENSION pg_trgm" \ + && service postgresql stop + +## Now back to the root user. +USER root + +## Adjust PostgreSQL configuration so that remote connections to the +## database are possible. +RUN mv /app/tripaldocker/default_files/postgresql/pg_hba.conf /etc/postgresql/13/main/pg_hba.conf + +## And add ``listen_addresses`` to ``/etc/postgresql/13/main/postgresql.conf`` +RUN echo "listen_addresses='*'" >> /etc/postgresql/13/main/postgresql.conf \ + && echo "max_locks_per_transaction = 1024" >> /etc/postgresql/13/main/postgresql.conf + +########## PHP EXTENSIONS ##################################################### +RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" + +## Xdebug +RUN pecl install xdebug-3.3.1 \ + && docker-php-ext-enable xdebug \ + && cat /app/tripaldocker/default_files/xdebug/xdebug-coverage.ini >> /usr/local/etc/php/php.ini \ + && echo "error_reporting=E_ALL" >> /usr/local/etc/php/conf.d/error_reporting.ini \ + && cp /app/tripaldocker/default_files/xdebug/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.dis \ + && rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + +## install the PHP extensions we need +RUN set -eux; \ + \ + if command -v a2enmod; then \ + a2enmod rewrite; \ + fi; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libfreetype6-dev \ + libjpeg-dev \ + libpng-dev \ + libwebp-dev \ + libpq-dev \ + libzip-dev \ + ; \ + \ + docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp; \ + \ + docker-php-ext-install -j "$(nproc)" \ + gd \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + pgsql \ + zip \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +## set recommended PHP.ini settings +## see https://secure.php.net/manual/en/opcache.installation.php +RUN { \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=60'; \ + echo 'opcache.fast_shutdown=1'; \ + echo 'opcache.memory_limit=1028M';\ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini + +RUN echo 'memory_limit = 1028M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini + +WORKDIR /var/www/html + +############# APACHE ########################################################## + +# Fix Could not determine server's fully qualified domain name. +RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf + +############# DRUPAL ########################################################## + +## Environment variables used for phpunit testing. +ENV SIMPLETEST_BASE_URL=http://localhost +ENV SIMPLETEST_DB=pgsql://drupaladmin:drupaldevelopmentonlylocal@localhost/sitedb +ENV BROWSER_OUTPUT_DIRECTORY=/var/www/drupal/web/sites/default/files/simpletest +ENV COMPOSER_MEMORY_LIMIT=-1 +ENV COMPOSER_NO_INTERACTION=1 +ENV COMPOSER_ALLOW_SUPERUSER=1 + +## Install composer and Drush. +WORKDIR /var/www +RUN chmod a+x /app/tripaldocker/init_scripts/composer-init.sh \ + && /app/tripaldocker/init_scripts/composer-init.sh + +## Use composer to install Drupal. +WORKDIR /var/www +ARG requiredcomposerpackages="drupal/core:${drupalversion} drupal/core-dev:${drupalversion} drush/drush phpspec/prophecy-phpunit" +ARG composerpackages="drupal/devel drupal/devel_php" +RUN composer create-project drupal/recommended-project:${drupalversion} --stability dev --no-install drupal \ + && cd drupal \ + && composer config --no-plugins allow-plugins.composer/installers true \ + && composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true \ + && composer config --no-plugins allow-plugins.drupal/core-project-message true \ + && composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true \ + && rm composer.lock \ + && composer require --dev ${requiredcomposerpackages} ${composerpackages} \ + && composer install + +## Set files directory permissions +RUN mkdir /var/www/drupal/web/sites/default/files \ + && mkdir /var/www/drupal/web/sites/default/files/simpletest \ + && chown -R www-data:www-data /var/www/drupal \ + && chmod 02775 -R /var/www/drupal/web/sites/default/files \ + && usermod -g www-data root + +## Install Drupal. +RUN cd /var/www/drupal \ + && service apache2 start \ + && service postgresql start \ + && sleep 30 \ + && /var/www/drupal/vendor/drush/drush/drush site-install standard \ + --db-url=pgsql://drupaladmin:drupaldevelopmentonlylocal@localhost/sitedb \ + --account-mail="drupaladmin@localhost" \ + --account-name=drupaladmin \ + --account-pass=some_admin_password \ + --site-mail="drupaladmin@localhost" \ + --site-name="Tripal 4.x-dev on Drupal ${drupalversion}" \ + && service apache2 stop \ + && service postgresql stop + +############# Tripal ########################################################## + +WORKDIR /var/www/drupal +RUN service apache2 start \ + && service postgresql start \ + && sleep 30 \ + && mkdir -p /var/www/drupal/web/modules/contrib \ + && cp -R /app /var/www/drupal/web/modules/contrib/tripal \ + && vendor/bin/drush en tripal tripal_biodb tripal_chado ${modules} -y \ + && if [ "$installchado" = "TRUE" ]; then \ + vendor/bin/drush trp-install-chado --schema-name=${chadoschema} \ + && vendor/bin/drush trp-prep-chado --schema-name=${chadoschema} \ + && vendor/bin/drush trp-import-types --collection_id=general_chado --username=drupaladmin; \ + fi \ + && service apache2 stop \ + && service postgresql stop + +############# Scripts ######################################################### + +## Configuration files & Activation script +RUN mv /app/tripaldocker/init_scripts/supervisord.conf /etc/supervisord.conf \ + && mv /app/tripaldocker/default_files/000-default.conf /etc/apache2/sites-available/000-default.conf \ + && echo "\$settings['trusted_host_patterns'] = [ '^localhost$', '^127\.0\.0\.1$', \$_SERVER['SERVER_NAME'] ];" >> /var/www/drupal/web/sites/default/settings.php \ + && mv /app/tripaldocker/init_scripts/init.sh /usr/bin/init.sh \ + && chmod +x /usr/bin/init.sh \ + && mv /app/tripaldocker/default_files/xdebug/xdebug_toggle.sh /usr/bin/xdebug_toggle.sh \ + && echo "\$config['system.logging']['error_level'] = 'verbose';" >> /var/www/drupal/web/sites/default/settings.php + +## Make global commands. Symlink for drupal9 is for backward compatibility. +RUN ln -s /var/www/drupal/vendor/phpunit/phpunit/phpunit /usr/local/bin/ \ + && ln -s /var/www/drupal/vendor/drush/drush/drush /usr/local/bin/ \ + && ln -s /var/www/drupal /var/www/drupal9 + +## Set the working directory to DRUPAL_ROOT +WORKDIR /var/www/drupal/web + +## Expose http, xdebug and psql port +EXPOSE 80 5432 9003 + +ENTRYPOINT ["init.sh"]