From adc55035da0432c5c3e47d61cf683365c68bda40 Mon Sep 17 00:00:00 2001 From: Martynas Sklizmantas Date: Sun, 25 Feb 2024 09:59:13 +0100 Subject: [PATCH 1/4] changing hardcoded mail from to config var --- app/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/__init__.py b/app/__init__.py index f39b28de..37820676 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -97,7 +97,7 @@ def create_app(config_class=Config): secure = () mail_handler = SMTPHandler( mailhost=(app.config['MAIL_SERVER'], app.config['MAIL_PORT']), - fromaddr='errors@rimu.geek.nz', + fromaddr=(app.config['MAIL_FROM']), toaddrs=app.config['ADMINS'], subject='PieFed error', credentials=auth, secure=secure) mail_handler.setLevel(logging.ERROR) From 3e59a95f0f5d7e50ca5184185bf85d6838cf65c1 Mon Sep 17 00:00:00 2001 From: Martynas Sklizmantas Date: Sun, 25 Feb 2024 10:05:33 +0100 Subject: [PATCH 2/4] mail from population to the config object --- config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/config.py b/config.py index bb5de205..7ea1ef71 100644 --- a/config.py +++ b/config.py @@ -16,6 +16,7 @@ class Config(object): MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None MAIL_USERNAME = os.environ.get('MAIL_USERNAME') MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD') + MAIL_FROM = os.environ.get('MAIL_FROM') RECAPTCHA_PUBLIC_KEY = os.environ.get("RECAPTCHA_PUBLIC_KEY") RECAPTCHA_PRIVATE_KEY = os.environ.get("RECAPTCHA_PRIVATE_KEY") MODE = os.environ.get('MODE') or 'development' From d2030e41342aeb2cd3645d24a6c559d50b6856de Mon Sep 17 00:00:00 2001 From: Martynas Sklizmantas Date: Sun, 25 Feb 2024 10:11:25 +0100 Subject: [PATCH 3/4] fixing key error in app init --- config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/config.py b/config.py index 7ea1ef71..26b1a4ef 100644 --- a/config.py +++ b/config.py @@ -17,6 +17,7 @@ class Config(object): MAIL_USERNAME = os.environ.get('MAIL_USERNAME') MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD') MAIL_FROM = os.environ.get('MAIL_FROM') + ADMINS = os.environ.get('ADMINS') RECAPTCHA_PUBLIC_KEY = os.environ.get("RECAPTCHA_PUBLIC_KEY") RECAPTCHA_PRIVATE_KEY = os.environ.get("RECAPTCHA_PRIVATE_KEY") MODE = os.environ.get('MODE') or 'development' From 6e9fad7a93840a72b4380868f0c3fa43fedfd615 Mon Sep 17 00:00:00 2001 From: saint Date: Sun, 25 Feb 2024 15:51:10 +0100 Subject: [PATCH 4/4] added dependencies in Dockerfile and better handling of docker volumes to not lose data on recreated containers --- .gitignore | 4 ++++ Dockerfile | 2 +- compose.yaml | 5 ++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 602005a5..ec649c25 100644 --- a/.gitignore +++ b/.gitignore @@ -166,3 +166,7 @@ celery_worker.py # sensitive data .env.docker .gunicorn.conf.py + +# local volumes for docker +media/ +pgdata/ diff --git a/Dockerfile b/Dockerfile index 157ae805..b10e111b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM --platform=$BUILDPLATFORM python:3-alpine AS builder RUN apk update RUN apk add pkgconfig -RUN apk add --virtual build-deps gcc python3-dev musl-dev +RUN apk add --virtual build-deps gcc python3-dev musl-dev tesseract-ocr tesseract-ocr-data-eng WORKDIR /app COPY . /app diff --git a/compose.yaml b/compose.yaml index 2f66927a..e8c66574 100644 --- a/compose.yaml +++ b/compose.yaml @@ -5,7 +5,7 @@ services: env_file: - ./.env.docker volumes: - - pgdata:/var/lib/postgresql/data + - ./pgdata:/var/lib/postgresql/data redis: image: redis env_file: @@ -29,6 +29,7 @@ services: volumes: - ./.env:/app/.env - ./.gunicorn.conf.py:/app/gunicorn.conf.py + - ./media/:/app/app/static/media/ ports: - '8080:5000' adminer: @@ -36,7 +37,5 @@ services: restart: always ports: - 8888:8080 -volumes: - pgdata: