Skip to content

Commit

Permalink
feat: Add REDIS service
Browse files Browse the repository at this point in the history
  • Loading branch information
drorganvidez committed Jul 30, 2024
1 parent 7efa20f commit bad7470
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 20 deletions.
1 change: 1 addition & 0 deletions .env.docker.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FLASK_APP_NAME="UVLHUB.IO(dev)"
FLASK_ENV=development
FLASK_APP=app
DOMAIN=localhost
MARIADB_HOSTNAME=db
MARIADB_PORT=3306
Expand Down
1 change: 1 addition & 0 deletions .env.docker.production.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FLASK_APP_NAME="UVLHUB.IO"
FLASK_ENV=production
FLASK_APP=app
DOMAIN=<CHANGE_THIS>
MARIADB_HOSTNAME=db
MARIADB_PORT=3306
Expand Down
1 change: 1 addition & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FLASK_APP_NAME="UVLHUB.IO(dev)"
FLASK_ENV=development
FLASK_APP=app
DOMAIN=localhost
MARIADB_HOSTNAME=localhost
MARIADB_PORT=3306
Expand Down
1 change: 1 addition & 0 deletions .env.vagrant.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FLASK_APP_NAME="UVLHUB.IO(dev)"
FLASK_ENV=development
FLASK_APP=app
DOMAIN=localhost
MARIADB_HOSTNAME=localhost
MARIADB_PORT=3306
Expand Down
5 changes: 5 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from flask_sqlalchemy import SQLAlchemy
from dotenv import load_dotenv
from flask_migrate import Migrate
from flask_session import Session

from app.modules.mail.services import MailService
from core.configuration.configuration import get_app_version
Expand All @@ -20,6 +21,7 @@
db = SQLAlchemy()
migrate = Migrate()
mail_service = MailService()
sess = Session()


def create_app(config_name='development'):
Expand All @@ -33,6 +35,9 @@ def create_app(config_name='development'):
db.init_app(app)
migrate.init_app(app, db)

# Initialize session with the app
sess.init_app(app)

# Register modules
module_manager = ModuleManager(app)
module_manager.register_modules()
Expand Down
5 changes: 5 additions & 0 deletions core/managers/config_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import secrets
import redis


class ConfigManager:
Expand Down Expand Up @@ -33,6 +34,10 @@ class Config:
TIMEZONE = 'Europe/Madrid'
TEMPLATES_AUTO_RELOAD = True
UPLOAD_FOLDER = 'uploads'
SESSION_TYPE = 'redis'
SESSION_PERMANENT = False
SESSION_USE_SIGNER = True
SESSION_REDIS = redis.from_url('redis://redis:6379')


class DevelopmentConfig(Config):
Expand Down
13 changes: 11 additions & 2 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ services:
- "5000:5000"
depends_on:
- db
- redis
build:
context: ../
dockerfile: docker/images/Dockerfile.dev
volumes:
- ../:/app
- /var/run/docker.sock:/var/run/docker.sock
command: [ "sh", "-c", "sh /app/docker/entrypoints/development_entrypoint.sh" ]
command: [ "bash", "-c", "bash /app/docker/entrypoints/development_entrypoint.sh" ]
networks:
- uvlhub_network

Expand All @@ -28,7 +29,6 @@ services:
build:
context: ../
dockerfile: docker/images/Dockerfile.mariadb
restart: always
ports:
- "3306:3306"
volumes:
Expand All @@ -49,6 +49,15 @@ services:
networks:
- uvlhub_network

redis:
image: "redis:latest"
container_name: redis_container
restart: always
ports:
- "6379:6379"
networks:
- uvlhub_network

volumes:
db_data:

Expand Down
12 changes: 11 additions & 1 deletion docker/docker-compose.prod.ssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ services:
- "5000:5000"
depends_on:
- db
- redis
restart: always
volumes:
- ./entrypoints/production_entrypoint.sh:/app/entrypoint.sh
- ../scripts:/app/scripts
- ../migrations:/app/migrations
- ../uploads:/app/uploads
- ../.moduleignore:/app/.moduleignore
command: [ "sh", "-c", "sh /app/entrypoint.sh" ]
command: [ "bash", "-c", "bash /app/entrypoint.sh" ]
networks:
- uvlhub_network

Expand Down Expand Up @@ -53,6 +54,15 @@ services:
networks:
- uvlhub_network

redis:
image: "redis:latest"
container_name: redis_container
restart: always
ports:
- "6379:6379"
networks:
- uvlhub_network

watchtower:
container_name: watchtower_container
image: containrrr/watchtower
Expand Down
12 changes: 11 additions & 1 deletion docker/docker-compose.prod.webhook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
- "5000:5000"
depends_on:
- db
- redis
build:
context: ../
dockerfile: docker/images/Dockerfile.webhook
Expand All @@ -22,7 +23,7 @@ services:
- ../uploads:/app/uploads
- ../:/app
- /var/run/docker.sock:/var/run/docker.sock
command: [ "sh", "-c", "sh /app/entrypoint.sh" ]
command: [ "bash", "-c", "bash /app/entrypoint.sh" ]
networks:
- uvlhub_network

Expand Down Expand Up @@ -54,6 +55,15 @@ services:
networks:
- uvlhub_network

redis:
image: "redis:latest"
container_name: redis_container
restart: always
ports:
- "6379:6379"
networks:
- uvlhub_network

volumes:
db_data:

Expand Down
12 changes: 11 additions & 1 deletion docker/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ services:
- "5000:5000"
depends_on:
- db
- redis
restart: always
volumes:
- ./entrypoints/production_entrypoint.sh:/app/entrypoint.sh
- ../scripts:/app/scripts
- ../migrations:/app/migrations
- ../uploads:/app/uploads
- ../.moduleignore:/app/.moduleignore
command: [ "sh", "-c", "sh /app/entrypoint.sh" ]
command: [ "bash", "-c", "bash /app/entrypoint.sh" ]
networks:
- uvlhub_network

Expand Down Expand Up @@ -50,6 +51,15 @@ services:
networks:
- uvlhub_network

redis:
image: "redis:latest"
container_name: redis_container
restart: always
ports:
- "6379:6379"
networks:
- uvlhub_network

watchtower:
container_name: watchtower_container
image: containrrr/watchtower
Expand Down
2 changes: 1 addition & 1 deletion docker/entrypoints/production_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ fi

# Start the application using Gunicorn, binding it to port 5000
# Set the logging level to info and the timeout to 3600 seconds
exec gunicorn --bind 0.0.0.0:5000 app:app --log-level info --timeout 3600
exec gunicorn --workers 3 --bind 0.0.0.0:5000 app:app --log-level info --timeout 3600
32 changes: 18 additions & 14 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,33 @@ beautifulsoup4==4.12.3
blinker==1.8.2
Brotli==1.1.0
bs4==0.0.2
cachelib==0.13.0
captcha==0.6.0
certifi==2024.7.4
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
ConfigArgParse==1.7
coverage==7.6.0
cryptography==43.0.0
dd==0.5.7
cryptography==42.0.8
dd==0.6.0
dnspython==2.6.1
docker==7.1.0
email_validator==2.2.0
Faker==26.0.0
flake8==7.1.0
flamapy==2.0.0
flamapy-bdd==2.0.0
flamapy-fm==2.0.0
flamapy-fw==2.0.0
flamapy-sat==2.0.0
flamapy==2.0.0.dev1
flamapy-bdd==2.0.0.dev1
flamapy-fm==2.0.0.dev1
flamapy-fw==2.0.0.dev1
flamapy-sat==2.0.0.dev1
Flask==3.0.3
Flask-Cors==4.0.1
Flask-Login==0.6.3
Flask-Mail==0.10.0
Flask-Migrate==4.0.7
Flask-RESTful==0.3.10
Flask-Session==0.8.0
Flask-SQLAlchemy==3.1.1
Flask-WTF==1.2.1
gevent==24.2.1
Expand All @@ -55,6 +57,7 @@ Mako==1.3.5
MarkupSafe==2.1.5
mccabe==0.7.0
msgpack==1.0.8
msgspec==0.18.6
networkx==3.3
outcome==1.3.0.post0
packaging==24.1
Expand All @@ -68,20 +71,21 @@ pycparser==2.22
pydot==3.0.1
pyflakes==3.2.0
PyMySQL==1.1.1
pyOpenSSL==24.2.1
pyOpenSSL==24.1.0
pyparsing==3.1.2
PySocks==1.7.1
pytest==8.3.2
pytest==8.2.2
pytest-cov==5.0.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-sat==0.1.8.dev17
python-sat==1.8.dev13
pytz==2024.1
pyzmq==26.0.3
redis==5.0.7
requests==2.32.3
selenium==4.23.1
selenium==4.22.0
selenium-wire==5.1.0
setuptools==72.1.0
setuptools==70.3.0
six==1.16.0
sniffio==1.3.1
sortedcontainers==2.4.0
Expand All @@ -94,12 +98,12 @@ typing_extensions==4.12.2
Unidecode==1.3.8
urllib3==2.2.2
uvlparser==2.0.1
webdriver-manager==4.0.2
webdriver-manager==4.0.1
websocket-client==1.8.0
Werkzeug==3.0.3
wheel==0.43.0
wsproto==1.2.0
WTForms==3.1.2
zope.event==5.0
zope.interface==6.4.post2
zstandard==0.22.0
zstandard==0.22.0

0 comments on commit bad7470

Please sign in to comment.