Skip to content

Commit

Permalink
Add support for customizable session storage in Magento environment
Browse files Browse the repository at this point in the history
  • Loading branch information
mescalantea committed Dec 18, 2024
1 parent b19e149 commit c8c436c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ COMPOSER_AUTH='{"http-basic":{"repo.magento.com":{"username":"<public-key>","pas
# Outside /bitnami/magento/
COMPOSER_CACHE_DIR=/opt/.composer/cache

BITNAMI_DEBUG=false
BITNAMI_DEBUG=false

# Customize env.php file.
MAGENTO_ENV_SESSION="['save' => 'files']"
# Example: use Redis as session storage
# MAGENTO_ENV_SESSION="[ 'save' => 'redis', 'redis' => [ 'host' => 'redis', 'port' => '6379', 'password' => '', 'timeout' => '4', 'persistent_identifier' => '', 'database' => '2', 'compression_threshold' => '2048', 'compression_library' => 'gzip', 'log_level' => '3', 'max_concurrency' => '25', 'break_after_frontend' => '5', 'break_after_adminhtml' => '30', 'first_lifetime' => '600', 'bot_first_lifetime' => '60', 'bot_lifetime' => '7200', 'disable_locking' => '1', 'min_lifetime' => '60', 'max_lifetime' => '7776000' ] ]"
16 changes: 16 additions & 0 deletions docker-entrypoint-init.d/03-custom_env_values.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# check if MAGENTO_ENV_SESSION is set and it is different from the default value
if [ -z "$MAGENTO_ENV_SESSION" ] || [ "$MAGENTO_ENV_SESSION" = "['save' => 'files']" ]; then
echo "MAGENTO_ENV_SESSION is not set or is set use the default value, skipping..."
exit 0
fi

cd /bitnami/magento/app/etc || exit 0

file="env.php"
sed -i.bak "/'session' => \[/,/\],/c\
'session' => $MAGENTO_ENV_SESSION \
," "$file"

echo "Updated /bitnami/magento/app/etc/$file with MAGENTO_ENV_SESSION. Backup saved as /bitnami/magento/app/etc/$file.bak"

0 comments on commit c8c436c

Please sign in to comment.