Skip to content

Commit

Permalink
Merge pull request #6044 from mailcow/feat/redis-session-store
Browse files Browse the repository at this point in the history
[PHP-FPM] Use redis as session store
  • Loading branch information
FreddleSpl0it authored Sep 5, 2024
2 parents bb6f405 + c62b467 commit 462137e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions data/Dockerfiles/phpfpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,25 @@ done

# Do not attempt to write to slave
if [[ ! -z ${REDIS_SLAVEOF_IP} ]]; then
REDIS_CMDLINE="redis-cli -h ${REDIS_SLAVEOF_IP} -p ${REDIS_SLAVEOF_PORT}"
REDIS_HOST=$REDIS_SLAVEOF_IP
REDIS_PORT=$REDIS_SLAVEOF_PORT
else
REDIS_CMDLINE="redis-cli -h redis -p 6379"
REDIS_HOST="redis"
REDIS_PORT="6379"
fi
REDIS_CMDLINE="redis-cli -h ${REDIS_HOST} -p ${REDIS_PORT}"

until [[ $(${REDIS_CMDLINE} PING) == "PONG" ]]; do
echo "Waiting for Redis..."
sleep 2
done

# Set redis session store
echo -n '
session.save_handler = redis
session.save_path = "tcp://'${REDIS_HOST}':'${REDIS_PORT}'"
' > /usr/local/etc/php/conf.d/session_store.ini

# Check mysql_upgrade (master and slave)
CONTAINER_ID=
until [[ ! -z "${CONTAINER_ID}" ]] && [[ "${CONTAINER_ID}" =~ ^[[:alnum:]]*$ ]]; do
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ services:
- rspamd

php-fpm-mailcow:
image: mailcow/phpfpm:1.89
image: mailcow/phpfpm:1.90
command: "php-fpm -d date.timezone=${TZ} -d expose_php=0"
depends_on:
- redis-mailcow
Expand Down Expand Up @@ -553,7 +553,7 @@ services:
aliases:
- dockerapi


##### Will be removed soon #####
solr-mailcow:
image: mailcow/solr:1.8.3
Expand Down

0 comments on commit 462137e

Please sign in to comment.