Jump to content

Fundraising/External-facing/CiviProxy

From Wikitech

CiviProxy On Docker

Overview

As part of the email preferences work relating to this ticket, we added Civiproxy to the fundraising tech docker stack.

Setup

CiviProxy should work under docker-compose after running setup.sh. Here are some of the things we had to do to get it running:

Hard-code CIVICRM_SITE_KEY to docker_site_key

CiviProxy and CiviCRM need to have the same value set for their site key to let CiviProxy make requests to CiviCRM.

We set an environment variable at the top level in docker-compose.yml:

 x-civicrm-site-key:
   &civicrm-site-key FR_DOCKER_CIVI_SITE_KEY=docker_site_key

The we pass it through to the civiproxy and civicrm containers:

 civiproxy:
   environment:
     - *logger-host
     - *civicrm-api-key
     - *civicrm-site-key

In the civibuild wmff install.sh we pass through the environment variable to set a local env variable that is used by Civi setup so it skips generating a random key.

In our CiviProxy public config (checked into the fundraising-dev repo) we pass that env var through to the $sys_key_map:

  $sys_key_map = array('SITE_KEY' => getenv('FR_DOCKER_CIVI_SITE_KEY'));

Update `civicrm`.`contact` api_key field for admin user to 'docker-api-key'

The two systems also need to agree on an api key that can be used by CiviProxy to authorize calls to CiviCRM. We automated this setup by adding an API call to the install.sh script in civibuild's wmff config. See a screengrab of why it was necessary.

Other

Docker stack CiviProxy Test URL

https://localhost:9005/rest.php?entity=civiproxy&action=getpreferences&key=SITE_KEY&version=3&json=1&api_key=API_KEY&hash=256fa6f5a00bce4598bc9144f203132f&contact_id=204

Gerrit patches

  • dev-images: (only needed if building locally): https://gerrit.wikimedia.org/r/c/releng/dev-images/+/664919
  • Fundraising-dev: https://gerrit.wikimedia.org/r/c/wikimedia/fundraising/dev/+/673094
  • CiviCRM: https://gerrit.wikimedia.org/r/c/wikimedia/fundraising/crm/+/649729

Local Troubleshooting

See Fundraising/External-facing/E-mail_preference_center#Local_Troubleshooting