Skip to content

Commit

Permalink
📝: Redis session handling
Browse files Browse the repository at this point in the history
  • Loading branch information
21r8390 committed Dec 17, 2022
1 parent c9942c9 commit eb1875a
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 8 deletions.
7 changes: 5 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
STACK_VERSION=8.5.0

# Port to expose PHP to the host
PHP_PORT=9438
PHP_PORT=11898

# Redis password
REDIS_PASSWORD=redisPassword123!

# Informs PHP if logging is enabled
IS_LOGGING=true
Expand Down Expand Up @@ -30,7 +33,7 @@ DB_USER=mkdocs_user
DB_PASSWORD=mkdocs_password

# Adminer port
ADMINER_PORT=9321
ADMINER_PORT=9421

# Sendgrid API key
SENDGRID_API_KEY=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
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
logstash/logs/**

# MariaDB
mariadb/sysdata/**
mariadb/sysdata/**

# Redis
redis/data/**
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,17 @@ Trotzdem ist das Projekt noch nicht `100%` fertig. Es fehlt noch, dass das UI au
- [x] Datei Viewer
- [x] Download

## 4. Abgabe 📦

- [ ] End to End Tests
- [x] Sessions
- [x] Redis
- [x] Redirects

## TODO:

- Tests
- VPS Hosting

## Nice to have:

- Zip in Mail
- Redis fĂźr Sessions
- Mehr Testdaten
4 changes: 4 additions & 0 deletions app/app/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@
// SendGrid
define('SENDGRID_API_KEY', getenv('SENDGRID_API_KEY'));
define('EMAIL_FROM', getenv('EMAIL_FROM'));

// Session
ini_set('session.save_handler', 'redis');
ini_set('session.save_path', getenv('REDIS_URL'));
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
restart: unless-stopped
depends_on:
- logstash
- redis
- mariadb
networks:
- public
Expand All @@ -36,13 +37,30 @@ services:
- DB_PASSWD=${DB_PASSWORD}
- SENDGRID_API_KEY=${SENDGRID_API_KEY}
- EMAIL_FROM=${EMAIL_FROM}
- REDIS_URL=tcp://redis?auth=${REDIS_PASSWORD}
healthcheck:
test: curl --fail -s http://localhost:80 || exit 1
interval: 60s
retries: 5
start_period: 30s
timeout: 10s

redis:
image: redis:latest
restart: unless-stopped
networks:
- database
volumes:
- ./redis/data:/data
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD}
command: --requirepass ${REDIS_PASSWORD}
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
interval: 30s
timeout: 10s
retries: 5

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
restart: unless-stopped
Expand Down
2 changes: 1 addition & 1 deletion mariadb/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Maria DB

MariaDB ist ein von der Gemeinschaft entwickelter Fork des relationalen Datenbankmanagementsystems **MySQL**, der unter der GNU GPL frei bleiben soll. MariaDB wird von Webanwendungen als Datenbankserver verwendet und wird auch von vielen großen Websites, darunter Facebook, Google und Wikipedia, als Datenbankserver genutzt. Der Vorteil von MariaDB ist, dass es eine vollständige Abwärtskompatibilität zu MySQL bietet, aber auch einige neue Funktionen und Verbesserungen enthält. Zudem ist es **Open Source** und unter der GNU GPL lizenziert, was bedeutet, dass es **kostenlos** und frei verfügbar ist.
MariaDB ist ein von der Gemeinschaft entwickelter Fork des relationalen Datenbankmanagementsystems **MySQL**, der unter der GNU GPL frei bleiben soll. MariaDB wird von Webanwendungen als Datenbankserver verwendet und wird auch von vielen grossen Websites, darunter Facebook, Google und Wikipedia, als Datenbankserver genutzt. Der Vorteil von MariaDB ist, dass es eine vollständige Abwärtskompatibilität zu MySQL bietet, aber auch einige neue Funktionen und Verbesserungen enthält. Zudem ist es **Open Source** und unter der GNU GPL lizenziert, was bedeutet, dass es **kostenlos** und frei verfßgbar ist.

## Adminer

Expand Down
7 changes: 6 additions & 1 deletion php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ RUN buildDeps=" \
&& rm -r /var/lib/apt/lists/* \
&& a2enmod rewrite

# Install Composer.
## Install Redis
### https://gitlab.univ-lorraine.fr/canals5/docker-php/-/blob/master/php/8.1/Dockerfile
RUN pecl install redis \
&& docker-php-ext-enable redis

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& ln -s $(composer config --global home) /root/composer
ENV PATH=$PATH:/root/composer/vendor/bin COMPOSER_ALLOW_SUPERUSER=1
Expand Down

0 comments on commit eb1875a

Please sign in to comment.