Skip to content

Commit

Permalink
store sessions in redis
Browse files Browse the repository at this point in the history
  • Loading branch information
msalakhov-smartorange committed Mar 22, 2022
1 parent 500f28e commit da2f83f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
3 changes: 3 additions & 0 deletions app/.env
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ DATABASE_URL="postgresql://db_user:[email protected]:5432/db_name?serverVers
# postgresql+advisory://db_user:db_password@localhost/db_name
LOCK_DSN=semaphore
###< symfony/lock ###

REDIS_HOST=redis
REDIS_PORT=6379
2 changes: 1 addition & 1 deletion app/config/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ framework:
# Enables session support. Note that the session will ONLY be started if you read or write from it.
# Remove or comment this section to explicitly disable session support.
session:
handler_id: null
handler_id: Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler
cookie_secure: auto
cookie_samesite: lax
storage_factory_id: session.storage.factory.native
Expand Down
10 changes: 10 additions & 0 deletions app/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,13 @@ services:

# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
Redis:
class: Redis
calls:
- connect:
- '%env(REDIS_HOST)%'
- '%env(int:REDIS_PORT)%'

Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler:
arguments:
- '@Redis'
9 changes: 6 additions & 3 deletions containers/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM php:8.0-fpm

RUN apt update \
RUN echo 'deb [trusted=yes] https://repo.symfony.com/apt/ /' | tee /etc/apt/sources.list.d/symfony-cli.list \
&& apt update \
&& apt install -y \
zlib1g-dev \
g++ \
Expand All @@ -10,15 +11,17 @@ RUN apt update \
libzip-dev \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev\
libfreetype6-dev \
symfony-cli \
&& docker-php-ext-install intl opcache pdo pdo_mysql \
&& pecl install apcu \
&& docker-php-ext-enable apcu \
&& docker-php-ext-configure zip \
&& docker-php-ext-install zip \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd \
&& docker-php-ext-install intl
&& docker-php-ext-install intl \
&& pecl install redis

WORKDIR /var/www/lux

Expand Down
2 changes: 2 additions & 0 deletions containers/php/conf/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1945,3 +1945,5 @@ opcache.enable=1
; List of headers files to preload, wildcard patterns allowed.
;ffi.preload=

[redis]
extension=redis.so
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ services:
depends_on:
- php
- database
redis:
container_name: redis
image: redis:5-alpine
ports: [6379]

0 comments on commit da2f83f

Please sign in to comment.