Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional boot.settings to enable running Standalone without a civicrm.settings.php #31155

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ufundo
Copy link
Contributor

@ufundo ufundo commented Sep 20, 2024

Overview

Following on from #30533 - this brings a few more constants into the *.boot.setting.php system, in order that they can be loaded from environment variables or defaults.

It's based upon #31150 - between the two I was able to run Standalone without civicrm.settings.php - just providing a three env vars.

Before

  • civicrm.settings.php provides many critical constants

After

  • provide CIVICRM_DSN, CIVICRM_UF_BASEURL and CIVICRM_UF as environment variables
  • set CIVICRM_SETTINGS_PATH to a non-existent path (to work around current is installed check)

image

  • delete civicrm.settings.php
  • Standalone still runs 😀

Comments

It's running Smarty2, but it's running....

@michaelmcandrew could you have a go testing this branch with the Docker container?

Copy link

civibot bot commented Sep 20, 2024

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers...

➡️ Online demo of this PR 🔗

@civibot civibot bot added the master label Sep 20, 2024
@ufundo ufundo added the run-distmaker Civibot should make tarballs for PR label Sep 20, 2024
@ufundo ufundo marked this pull request as ready for review September 20, 2024 21:18
@michaelmcandrew
Copy link
Contributor

michaelmcandrew commented Sep 25, 2024

@ufundo - I tried this out as follows:

  1. Added the following two lines to the civicrm Dockerfile
ENV CIVICRM_SETTINGS_PATH=/var/www/html/setting-stub # presume that this path is OK

RUN touch setting-stub
  1. Built an image with the build.php script from https://github.com/civicrm/civicrm-docker as follows: php build.php --download-url=https://storage.googleapis.com/civicrm-build/pr/core-31155/civicrm-5.79.alpha1-standalone-202409202150.tar.gz --image-prefix=pr31155 --php-version=8.3 --skip-push --no-cache.
  2. Used the current example compose.yaml file but with services.app.image set to pr31155/civicrm:latest
  3. docker compose up -d and waited for the database to initialise (you'll likely need/want to docker compose down -v if you have existing volumes from a previous 'up -d')
  4. Installed civicrm with docker compose exec -e CIVICRM_ADMIN_USER=admin -e CIVICRM_ADMIN_PASS=password app civicrm-docker-install
  5. Visited http://localhost:8760 and noted that I can log in with my username and password 👍
  6. Removed /var/www/html/private/civicrm.settings.php and (sadly 👎) be confronted with the installer and the following warnings:
Warning: Constant CIVICRM_UF already defined in /var/www/html/core/setup/src/Setup/UI/SetupController.php on line 130

Warning: Constant CIVICRM_UF_BASEURL already defined in /var/www/html/core/setup/src/Setup/UI/SetupController.php on line 132

Warning: http_response_code(): Cannot set response code - headers already sent (output started at /var/www/html/core/setup/src/Setup/UI/SetupController.php:130) in /var/www/html/core/setup/src/Setup/BasicRunner.php on line 31

I wasn't sure where /var/www/html/setting-stub should exist or not so I removed it but got the same message.

I also tried passing CIVICRM_DSN instead of, and as well as CIVICRM_DB_* variables but but got the same message.

Let me know if I am missing something or you want me to test again.

@ufundo
Copy link
Contributor Author

ufundo commented Sep 25, 2024

CIVICRM_SETTINGS_PATH=/var/www/html/setting-stub

Sorry @michaelmcandrew that doesnt exist as an env var (yet)

For now I got it working by adding

define('CIVICRM_SETTINGS_PATH', '/var/www/html/setting-stub');

at the top of civicrm.standalone.php

@michaelmcandrew
Copy link
Contributor

michaelmcandrew commented Sep 26, 2024

I can confirm that adding that line works for me :) I was able to log in successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master run-distmaker Civibot should make tarballs for PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants