Browse Source

fix: [gogocarto] make charm compatible with running more than one service using the same charm

odoo_fix_webhook_url
Valentin Lab 2 years ago
parent
commit
3eb8198378
  1. 10
      gogocarto/README.org
  2. 24
      gogocarto/hooks/publish_dir-relation-joined
  3. 2
      gogocarto/lib/common

10
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 *** create the full data release bundle this is what was made
#+begin_src sh #+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 ## Force original versions
git co web/index.php config/packages/doctrine_mongodb.yaml bin/console git co web/index.php config/packages/doctrine_mongodb.yaml bin/console
sed -ri "s/^(<\?php)/\1\n\ini_set('memory.limit', '1024M');/" \ sed -ri "s/^(<\?php)/\1\n\ini_set('memory.limit', '1024M');/" \
web/index.php bin/console 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" \ 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 config/packages/doctrine_mongodb.yaml

24
gogocarto/hooks/publish_dir-relation-joined

@ -55,15 +55,29 @@ RewriteRule ^(.*)$ index.php/\$1 [QSA,L]
EOF 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 " config-add "
services: services:
$MASTER_TARGET_SERVICE_NAME: $MASTER_TARGET_SERVICE_NAME:
volumes: 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 ## Required to give PHP access to this dir
- $upload_dir:$GOGOCARTO_DIR/web/uploads:rw
- $upload_dir:/opt/apps/$SERVICE_NAME/web/uploads:rw
" "

2
gogocarto/lib/common

@ -132,7 +132,7 @@ symphony() {
--without-relation="$SERVICE_NAME":web-proxy \ --without-relation="$SERVICE_NAME":web-proxy \
run \ run \
"${symphony_docker_run_opts[@]}" \ "${symphony_docker_run_opts[@]}" \
-T --rm -w /opt/apps/gogocarto \
-T --rm -w /opt/apps/"$SERVICE_NAME" \
--entrypoint php \ --entrypoint php \
-u www-data "$SERVICE_NAME" bin/console "$@" | cat -u www-data "$SERVICE_NAME" bin/console "$@" | cat

Loading…
Cancel
Save