From 3eb8198378b95b7c0f8059159af058deb9c36221 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Wed, 3 May 2023 10:17:02 +0200 Subject: [PATCH] fix: [gogocarto] make charm compatible with running more than one service using the same charm --- gogocarto/README.org | 10 --------- gogocarto/hooks/publish_dir-relation-joined | 24 ++++++++++++++++----- gogocarto/lib/common | 2 +- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/gogocarto/README.org b/gogocarto/README.org index 063a9c3..05e1047 100644 --- a/gogocarto/README.org +++ b/gogocarto/README.org @@ -68,20 +68,10 @@ This will be done in the =hooks/mongo_database-relation-joined= accordingly. *** create the full data release bundle this is what was made #+begin_src sh -## correct bundles links (no idea if it is needed) -( - cd web/bundles - for i in *; do - link_target=$(readlink "$i") - ln -sf /opt/apps/gogocarto"${link_target#/var/www}" "$i" - done -) ## Force original versions git co web/index.php config/packages/doctrine_mongodb.yaml bin/console sed -ri "s/^(<\?php)/\1\n\ini_set('memory.limit', '1024M');/" \ web/index.php bin/console -sed -ri "s%dirname\(__DIR__\)\.'%'/opt/apps/gogocarto%g" \ - web/index.php sed -ri "s/\"use_as_saas=%env\(resolve:USE_AS_SAAS\)%\/%env\(resolve:DATABASE_NAME\)%\"/'%env(resolve:DATABASE_NAME)%'/g" \ config/packages/doctrine_mongodb.yaml diff --git a/gogocarto/hooks/publish_dir-relation-joined b/gogocarto/hooks/publish_dir-relation-joined index 1e8aa92..81bef36 100755 --- a/gogocarto/hooks/publish_dir-relation-joined +++ b/gogocarto/hooks/publish_dir-relation-joined @@ -55,15 +55,29 @@ RewriteRule ^(.*)$ index.php/\$1 [QSA,L] EOF +## Make the web part aware of were the PHP app is located +sed -ri "s%^(\s*require\s+).*(/config/bootstrap.php'\s*;\s*)$%\1'/opt/apps/$SERVICE_NAME\2%" \ + "${GOGOCARTO_CODE}"/web/index.php || exit 1 + +## correct bundles links, these are for static resources (css, js) +## offered in PHP dependencies. +( + cd "${GOGOCARTO_CODE}"/web/bundles + for i in *; do + link_target=$(readlink "$i") + ln -svf "/opt/apps/${SERVICE_NAME}/vendor/${link_target#*/vendor/}" "$i" + done +) || exit 1 + config-add " services: $MASTER_TARGET_SERVICE_NAME: volumes: - - $GOGOCARTO_CODE:$GOGOCARTO_DIR:rw - - $SERVICE_DATASTORE/var/cache/gogocarto:$GOGOCARTO_DIR/var/cache:rw - - $SERVICE_DATASTORE/var/lib/gogocarto/sessions:$GOGOCARTO_DIR/var/sessions:rw - - $SERVICE_DATASTORE/var/log/gogocarto:$GOGOCARTO_DIR/var/log:rw + - $GOGOCARTO_CODE:/opt/apps/$SERVICE_NAME:rw + - $SERVICE_DATASTORE/var/cache/gogocarto:/opt/apps/$SERVICE_NAME/var/cache:rw + - $SERVICE_DATASTORE/var/lib/gogocarto/sessions:/opt/apps/$SERVICE_NAME/var/sessions:rw + - $SERVICE_DATASTORE/var/log/gogocarto:/opt/apps/$SERVICE_NAME/var/log:rw ## Required to give PHP access to this dir - - $upload_dir:$GOGOCARTO_DIR/web/uploads:rw + - $upload_dir:/opt/apps/$SERVICE_NAME/web/uploads:rw " diff --git a/gogocarto/lib/common b/gogocarto/lib/common index 65fdf5d..79202c6 100644 --- a/gogocarto/lib/common +++ b/gogocarto/lib/common @@ -132,7 +132,7 @@ symphony() { --without-relation="$SERVICE_NAME":web-proxy \ run \ "${symphony_docker_run_opts[@]}" \ - -T --rm -w /opt/apps/gogocarto \ + -T --rm -w /opt/apps/"$SERVICE_NAME" \ --entrypoint php \ -u www-data "$SERVICE_NAME" bin/console "$@" | cat