Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c65a654
Update router.py
tonlls Sep 24, 2025
77126bb
fix
tonlls Sep 24, 2025
a00a0e9
fixc
tonlls Sep 24, 2025
f633c5c
Merge pull request #34 from LleidaHack/test-uv
tonlls Sep 24, 2025
3644f7a
Automated autoyapf fixes
invalid-email-address Sep 24, 2025
8fa4690
Update gunicorn_conf.py
tonlls Sep 24, 2025
5e2e048
Update Dockerfile
tonlls Sep 24, 2025
6034571
test
tonlls Sep 24, 2025
992a317
Merge branch 'integration' into test-uv
tonlls Sep 24, 2025
68a3a82
Merge pull request #35 from LleidaHack/test-uv
tonlls Sep 24, 2025
b1eeb26
test
tonlls Sep 24, 2025
bc04f90
test
tonlls Sep 24, 2025
2180210
test
tonlls Sep 24, 2025
eece4d2
Debugging
Big-Lolo Sep 25, 2025
014bba8
deb
Big-Lolo Sep 25, 2025
2cf9191
debb
Big-Lolo Sep 25, 2025
9415dd5
Update modules
Big-Lolo Sep 25, 2025
a75d90c
Update Dockerfile
Big-Lolo Sep 25, 2025
4bb95fd
Create .env.main
Big-Lolo Sep 25, 2025
aaa5e3b
Refactor
Big-Lolo Sep 25, 2025
c2b8cb8
Update Settings.py
tonlls Sep 25, 2025
3574479
Update Settings.py
tonlls Sep 25, 2025
e1350ee
Update Settings.py
tonlls Sep 25, 2025
5763475
Update Settings.py
tonlls Sep 25, 2025
44fa976
Update Settings.py
tonlls Sep 25, 2025
d570455
Update Settings.py
tonlls Sep 25, 2025
f629ccf
Update Settings.py
tonlls Sep 25, 2025
96eaba0
Update Settings.py
tonlls Sep 25, 2025
2503cb8
Update .env
tonlls Sep 25, 2025
0d9bcc4
Update Settings.py
tonlls Sep 25, 2025
6416204
Update Settings.py
tonlls Sep 25, 2025
4c85eb1
Add module
Big-Lolo Sep 25, 2025
8fe873b
Add more modules
Big-Lolo Sep 25, 2025
098f77f
.
Big-Lolo Sep 25, 2025
032a9fd
Update service.py
Big-Lolo Sep 25, 2025
f9090a3
Update Settings.py
tonlls Sep 25, 2025
20ac28f
Update main.py
Big-Lolo Sep 25, 2025
2f661fc
Update Settings.py
tonlls Sep 25, 2025
b030cb7
Update gunicorn_conf.py
tonlls Sep 25, 2025
9974e7f
fix nanu
tonlls Sep 25, 2025
4e60a8f
mail template update
elver5041 Sep 25, 2025
03a6417
Automated autoyapf fixes
invalid-email-address Sep 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@


INTEGRATION_MAIL_POSTGRES_PASSWORD=${INTEGRATION_MAIL_POSTGRES_PASSWORD}
BACKEND_SERVICE_TOKEN=${BACKEND_SERVICE_TOKEN}
SMTP_USER=${SMTP_USER}
SMTP_PASSWORD=${SMTP_PASSWORD}
SMTP_HOST=${SMTP_HOST}
SMTP_PORT=${SMTP_PORT}
FROM_EMAIL=${FROM_EMAIL}
FROM_NAME=${FROM_NAME}
CONTACT_EMAIL=${CONTACT_EMAIL}
FRONT_URL=${FRONT_URL}
BACK_URL=${BACK_URL}
STATIC_FOLDER=${STATIC_FOLDER}
CONTACT_MAIL=${CONTACT_MAIL}
INITIAL_TEMPLATES_PATH=${INITIAL_TEMPLATES_PATH}
CLIENT__URL=${CLIENT__URL}
CLIENT__SERVICE_TOKEN=${CLIENT__SERVICE_TOKEN}
DATABASE__URL=${DATABASE__URL}
MAIL__USERNAME=${MAIL__USERNAME}
MAIL__PASSWORD=${MAIL__PASSWORD}
MAIL__FROM_MAIL=${MAIL__FROM_MAIL}
MAIL__PORT=${MAIL__PORT}
MAIL__SERVER=${MAIL__SERVER}
MAIL__FROM_NAME=${MAIL__FROM_NAME}
MAIL__SEND_MAILS=${MAIL__SEND_MAILS}
PORT=${PORT}
CLIENTS__MAIL_CLIENT__URL=${CLIENTS__MAIL_CLIENT__URL}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ celerybeat.pid
*.sage.py

# Environments
.env

.venv
env/
venv/
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

ARG GIT_BRANCH

WORKDIR /app

#Install git
RUN apt-get update && apt-get install -y git

RUN git clone https://github.com/LleidaHack/MailBackend.git . && \
git checkout ${GIT_BRANCH}

# Install dependencies
RUN uv sync --frozen

# Create required directories
RUN mkdir -p logs generated_src

EXPOSE 8001

# Default command (can be overridden in docker-compose.yml)
CMD sh -c 'uv run alembic upgrade head && uv run gunicorn main:app -c gunicorn_conf.py'
Empty file added README.md
Empty file.
5 changes: 3 additions & 2 deletions alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

from alembic import context
from src import imports
from src.configuration.Configuration import Configuration

from src.configuration.Settings import settings
from src.utils.Base.BaseModel import BaseModel

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

config.set_main_option('sqlalchemy.url', Configuration.database.url)
config.set_main_option('sqlalchemy.url', settings.database.url)

# Interpret the config file for Python logging.
# This line sets up loggers basically.
Expand Down
5 changes: 3 additions & 2 deletions alembic/versions/2024-05-07_00-31__1dc175d9dfdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import sqlalchemy as sa

from alembic import op
from src.configuration.Configuration import Configuration

from src.configuration.Settings import settings
from src.utils.internal_templates.InternalTemplates import InternalTemplates

# revision identifiers, used by Alembic.
Expand All @@ -22,7 +23,7 @@

def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
path = join(*Configuration.initial_templates_path.split(','))
path = join(*settings.initial_templates_path.split(','))
for _ in InternalTemplates:
template_file_path = join(path, f"{_.value}.html")
with open(template_file_path, 'r', encoding='utf-8') as file:
Expand Down
9 changes: 5 additions & 4 deletions gunicorn_conf.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from multiprocessing import cpu_count

from src.configuration.Configuration import Configuration
from src.configuration.Settings import settings

#socket path
bind = f"localhost:{Configuration.port}"
bind = f"0.0.0.0:{settings.port}"

#worker options
workers = cpu_count() + 1
worker_class = 'uvicorn.workers.UvicornWorker'

#Logging options
loglevel = 'debug'
accesslog = './logs/gunicorn_access.log'
errorlog = './logs/gunicorn_error.log'
accesslog = '-'
errorlog = '-'
capture_output = True
27 changes: 15 additions & 12 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from fastapi_sqlalchemy import DBSessionMiddleware
from fastapi_utils.tasks import repeat_every

from src.configuration.Configuration import Configuration
from src.configuration.Settings import settings
from src.impl.Mail.service import MailService
from src.versions.v1 import router as v1_router

Expand All @@ -22,7 +22,7 @@
openapi_tags=tags_metadata,
debug=True)

app.add_middleware(DBSessionMiddleware, db_url=Configuration.database.url)
app.add_middleware(DBSessionMiddleware, db_url=settings.database.url)
app.include_router(v1_router)

for route in app.routes:
Expand All @@ -31,13 +31,16 @@
route.tags) > 0 else ''
route.operation_id += '_' + route.name


@app.on_event("startup")
@repeat_every(seconds=60 * 60 * 24)
def send_pending_mails():
while True:
try:
mail_service.send_next()
sleep(60)
except Exception:
break
# logger.warning("PRINT DE PRUEBA: Esto es un print para gestionar funcionamiento de los logs :)")
# @app.on_event("startup")
# @repeat_every(seconds=60 * 60 * 24)
# def send_pending_mails():
# logger.warning("send_pending_mails: Entrada en función.")
# while True:
# try:
# logger.warning("send_pending_mails: INTENTO DE ENVIO")
# mail_service.send_next()
# sleep(60)
# except Exception:
# logger.warning("send_pending_mails: ERROR EN EL INTENTO")
# break
Loading