Sign inSign up

prometsource/php7.2-fpm-acquia

By prometsource

Updated about 7 years ago

Image
1

5.4K

prometsource/php7.2-fpm-acquia repository overview

GAO Website Redesign / Drupal 8 implementation

Build Status

Getting Started

Prerequisites for Developer Environments
  • Docker / Docker Compose
  • AWS Command Line tool, configured with the Travis CI credentials

To install the AWS command line tool on Mac OS X, please reference: https://docs.aws.amazon.com/cli/latest/userguide/install-macos.html

To configure the AWS comamnd line tool, please reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html

The AWS secret and key can be found in a .txt file attached to the following JIRA (GGWR-375) issue comment: https://prometprojects.atlassian.net/browse/GGWR-375?focusedCommentId=206783&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-206783. You can ignore the user included in that file.

Standing up a Local Developer Environment

This project utilizes a Docker stack with the following containers:

  • NginX (custom)
  • PHP 7.2 (fpm) (custom, configured to simulate Acquia Cloud PHP installation)
  • MariaDB
  • Solr 7 (to simulate Acquia Search)
  • MailHog
  • MemCache
  • FE Tools (to provide Grunt / Gulp tools for theming)
  • Selenium (for Behat Test execution)
  • pa11y-ci (to run automated accessibility tests)

This project also has a Makefile which will execute convenience commands for you, including commands to spin up and down a local developer environment.

To see all convenience commands included in the Makefile, execute:

make help

To stand up a local developer environment:

  • Add a named profile called "travis-ci" to your aws command line tool configuration. The AWS secret and key can be found in the .txt file attached to JIRA issue For more information see: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html
  • Make sure port 80 and port 443 on your local machine are available (no services are binding this port)
  • clone this repo into a directory named gao (default git clone directory)
  • create a .env file in the project root from the template below
  • add 127.0.0.1 gao.test to your hosts file (/etc/hosts for MacOS / Linux)
  • execute make devinit from the project root

make devinit will execute a command to spin up the docker stack, initialize the database from a seed database downloaded from Amazon S3, and import the configuration files from the config/sync directory. This will take a few minutes to spin up.

Once your environment has been initialized, you can spin down the environment by executing make docker-down, and reinitialize it with make devsetup.

If you need to completely reset your environment, execute make devclean, followed by make devinit to drop the database, reinstall drupal, download and reimport the database and re-import the configuration data.

.env file for local development
#
# GAO project .env file for local developer environments
#

MYSQL_DATABASE=drupal
MYSQL_HOSTNAME=db
MYSQL_PASSWORD=drupal
MYSQL_PORT=3306
MYSQL_USER=drupal

DRUSH_OPTIONS_URI=https://gao.test

SITE_ENVIRONMENT=local

macOS Mojave Performance
Disabling encryption by turning off "FileVault" significantly increases performance.

Please note that a reboot is required after decryption is complete.

SOCKS 5 Proxy for browsing Acquia Cloud dev and staging sites.

Access to the dev and staging sites on Acquia Cloud is protected via a lan-to-lan VPN appliance. In order for the Promet team to browse the site, we'll need to configure your local machine to set up a SOCKS 5 SSH proxy tunnel and route a browser's traffic through that tunnel. Firefox can be configured through the "Preferences" UI fairly easily. Instructions are included here to set up Firefox for browsing through a SOCKS 5 proxy tunnel.

Prerequisites
  • A Public key on your user profile on Acquia Cloud
  • Access to the "U.S. Government Accountability Office (GAO)" project on Acquia Cloud with SSH access to the dev and staging environments
Establishing a tunnel connection

(1). Open a terminal window and issue the following command:

make start-proxy

This will configure the network settings on Mac OS X to route traffic through the proxy.

(2) Browse to one of the domains for Acquia Cloud dev or staging in Chrome or Safari:

Exception instructions for Firefox on OS X

For Firefox, you have to configure your proxy connection directly in the browser.

(2) Open a Firefox browser, and browse to about:preferences.

(3) In the search bar filter the Preferences on "network", and click the "Settings..." button next to "Network Settings"

(4) Click on the "Manual proxy configuration" radio button, enter "localhost" in the SOCKS Host field, enter "8443" in the associated Port field, select the "SOCKS v5" radio button and click "OK".

(5) execute make start-proxy

(6) Browse to one of the domains for Acquia Cloud dev or staging:

Terminating the tunnel connection

(1). Open a terminal window and issue the following command:

make stop-proxy

NOTE: If you are using Firefox, you will also need to remove the Firefox browser specific settings added from above.

Semantic Versioning

This project adheres to Semantic Versioning 2.0.0 for releases.

The tentative version roadmap is as follows:

  • Release v0.10 -- User Roles, initial content types for API, and Taxonomy Vocabularies
  • Release v0.20 -- API Interface
  • Release v0.30 -- Remaining Content Types, finalization of Taxonomy Vocabulary structures
  • Release v0.40 -- Views construction and page layouts, part 1
  • Release v0.50 -- Theming part 1, Views construction and page layouts, part 2
  • Release v0.60 -- Theming part 2, Finalizing Views construction and page layouts, part 3
  • Release v0.70 -- Data Migrations and Feeds, Theming part 3
  • Release v0.80 -- Menus, sitemaps, Theming part 4
  • Release v0.90 -- Full QA / Testing, bug fixes identified from QA, begin End User && Technical documentation
  • Release v1.0-alpha1+ -- Initial Client acceptance testing, refining acceptance test suite, bug fixes, continued documentation
  • Release v1.0-beta1+ -- Finalize Client acceptance testing, prepare for soft launch, bug fixes, finalize documentation
  • Release v1.0-rc1+ -- Internal launch at GAO, bug fixes, requested changes to documentation
  • Release v1.0.0 -- Public launch, Go Live

Using xDebug

See xDebug README.

Mac OS requires that you run the following command on your host: sudo ifconfig lo0 alias 10.254.254.254. Note, you may have to re-run this command if you restart your computer or rebuild local environment.

To disable xDebug

Update xDebug settings in docker-compose.yml if you wish to disable xDebug on your development environment.

XDEBUG_CONFIG: "remote_enable=0 remote_host=10.254.254.254"
To use xDebug on Linux

Update xDebug settings in docker-compose.yml and follow instructions for IDE configuration specific to Linux in xDebug README:

XDEBUG_CONFIG: "remote_enable=1 remote_host=127.0.0.1"

Unit Tests

How to run unit tests?

To run project's PHPUnit test on your local environment, run make phpunit.

To run a specific single PHPUnit test, use the following command:

 docker-compose exec -T php /var/www/bin/phpunit -c /var/www/phpunit.xml.dist
  <relative_path_to_test_class_file_within_the_container>

E.g.

 docker-compose exec -T php /var/www/bin/phpunit -c /var/www/phpunit.xml.dist /var/www/docroot/modules/custom/gao_core/tests/src/Kernel/ProductIdUniqueConstraintValidationTest.php
How to add unit tests?

PHPUnit test should be added per module within module's tests/src/<test_type> directory.

Add module's tests as a new test suite in phpunit.xml.dist file to ensure newly added tests are included in automated builds. See <testsuites> in phpunit.xml.dist tag for a sample suite inclusion.

API documentation

GAO API Documentation

File Storage

Public files directory location has been reconfigured due to the requirement to serve all files via path assets/[path]/files. Symlink to the default Drupal file location is created during the build process. See Makefile file-symlink target and Acquia post-code-deploy hook script hooks/common/post-code-deploy/deploy.sh.

Composer template for Drupal projects

This project uses the Composer Template for Drupal Projects as the starting composer template. As a result, the project supports the application of patches using Composer.

What does the template do?

When installing the given composer.json some tasks are taken care of:

  • Drupal will be installed in the web-directory.
  • Autoloader is implemented to use the generated composer autoloader in vendor/autoload.php, instead of the one provided by Drupal (web/vendor/autoload.php).
  • Modules (packages of type drupal-module) will be placed in web/modules/contrib/
  • Theme (packages of type drupal-theme) will be placed in web/themes/contrib/
  • Profiles (packages of type drupal-profile) will be placed in web/profiles/contrib/
  • Creates default writable versions of settings.php and services.yml.
  • Creates web/sites/default/files-directory.
  • Latest version of drush is installed locally for use at vendor/bin/drush.
  • Latest version of DrupalConsole is installed locally for use at vendor/bin/drupal.
  • Creates environment variables based on your .env file. See .env.example.
Updating Drupal Core

This project will attempt to keep all of your Drupal Core files up-to-date; the project drupal-composer/drupal-scaffold is used to ensure that your scaffold files are updated every time drupal/core is updated. If you customize any of the "scaffolding" files (commonly .htaccess), you may need to merge conflicts if any of your modified files are updated in a new release of Drupal core.

Follow the steps below to update your core files.

  1. Run composer update drupal/core webflo/drupal-core-require-dev symfony/* --with-dependencies to update Drupal Core and its dependencies.
  2. Run git diff to determine if any of the scaffolding files have changed. Review the files for any changes and restore any customizations to .htaccess or robots.txt.
  3. Commit everything all together in a single commit, so web will remain in sync with the core when checking out branches or running git bisect.
  4. In the event that there are non-trivial conflicts in step 2, you may wish to perform these steps on a branch, and use git merge to combine the updated core files with your customized files. This facilitates the use of a three-way merge tool such as kdiff3. This setup is not necessary if your changes are simple; keeping all of your modifications at the beginning or end of the file is a good strategy to keep merges easy.
FAQ
Should I commit the scaffolding files?

The drupal-scaffold plugin can download the scaffold files (like index.php, update.php, …) to the web/ directory of your project. If you have not customized those files you could choose to not check them into your version control system (e.g. git). If that is the case for your project it might be convenient to automatically run the drupal-scaffold plugin after every install or update of your project. You can achieve that by registering @composer drupal:scaffold as post-install and post-update command in your composer.json:

"scripts": {
    "post-install-cmd": [
        "@composer drupal:scaffold",
        "..."
    ],
    "post-update-cmd": [
        "@composer drupal:scaffold",
        "..."
    ]
},
How can I apply patches to downloaded modules?

If you need to apply patches (depending on the project being modified, a pull request is often a better solution), you can do so with the composer-patches plugin.

To add a patch to drupal module foobar insert the patches section in the extra section of composer.json:

"extra": {
    "patches": {
        "drupal/foobar": {
            "Patch description": "URL or local path to patch"
        }
    }
}

Tag summary

Content type

Image

Digest

Size

245.1 MB

Last updated

about 7 years ago

docker pull prometsource/php7.2-fpm-acquia