From ff04ecd768bb13f4472348252f3b5ac067c05803 Mon Sep 17 00:00:00 2001 From: antarcticrainforest Date: Sat, 17 Aug 2024 08:30:49 +0200 Subject: [PATCH 1/3] Integrade sendgrid API. --- .github/workflows/build_job.yml | 4 +++- Dockerfile | 4 +++- django_evaluation/settings/local.py | 16 +++++----------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build_job.yml b/.github/workflows/build_job.yml index ba50d9e9..25fe0b62 100644 --- a/.github/workflows/build_job.yml +++ b/.github/workflows/build_job.yml @@ -52,7 +52,9 @@ jobs: with: context: . platforms: linux/amd64 - build-args: VERSION=${{steps.repository.outputs.tag}} + build-args: | + VERSION=${{steps.repository.outputs.tag}} + EMAIL_HOST_PASSWORD=${{secrets.EMAIL_HOST_PASSWORD}} push: true tags: | ghcr.io/${{ steps.repository.outputs.repo }}:${{ steps.repository.outputs.tag }} diff --git a/Dockerfile b/Dockerfile index 66e96e0a..b1e04b32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ ARG CONDA_ENV_DIR=/opt/condaenv ARG FREVA_WEB_DIR=/opt/freva_web +ARG EMAIL_HOST_PASSWORD="" ARG VERSION FROM condaforge/mambaforge @@ -14,7 +15,8 @@ RUN set -e && \ WORKDIR ${FREVA_WEB_DIR} COPY . . ENV PATH=$CONDA_ENV_DIR/bin:$PATH\ - DJANGO_SUPERUSER_EMAIL=freva@dkrz.de + DJANGO_SUPERUSER_EMAIL=freva@dkrz.de\ + EMAIL_HOST_PASSWORD=$EMAIL_HOST_PASSWORD RUN set -e && \ mamba env create -y -p ${CONDA_ENV_DIR} -f conda-env.yml &&\ mamba clean -afy &&\ diff --git a/django_evaluation/settings/local.py b/django_evaluation/settings/local.py index 6ec61bb9..b3e92500 100755 --- a/django_evaluation/settings/local.py +++ b/django_evaluation/settings/local.py @@ -241,17 +241,11 @@ def _set_favicon(html_color: str, project_root: Path) -> None: SERVER_EMAIL = os.environ.get("SERVER_EMAIL", "freva@dkrz.de") DEFAULT_FROM_EMAIL = SERVER_EMAIL -EMAIL_HOST = os.environ.get("EMAIL_HOST", "mailhost.dkrz.de") - -EMAIL_PORT = int(os.environ.get("EMAIL_PORT", "25")) -if EMAIL_PORT == 25: - EMAIL_HOST_USER = "" - EMAIL_HOST_PASSWORD = "" -else: - email_secrets = _read_secret() - EMAIL_HOST_USER = email_secrets.get("username") - EMAIL_HOST_PASSWORD = email_secrets.get("password") - +EMAIL_HOST = "smtp.sendgrid.net" +EMAIL_PORT = "587" +EMAIL_USE_TLS = True +EMAIL_HOST_USER = "apikey" +EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD") HOME_DIRS_AVAILABLE = False From da6ad11de0a773dce9adba3da4aa1ba7370513c5 Mon Sep 17 00:00:00 2001 From: antarcticrainforest Date: Mon, 19 Aug 2024 08:39:22 +0200 Subject: [PATCH 2/3] Remove _read_secrets method --- django_evaluation/settings/local.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/django_evaluation/settings/local.py b/django_evaluation/settings/local.py index b3e92500..43da8eda 100755 --- a/django_evaluation/settings/local.py +++ b/django_evaluation/settings/local.py @@ -79,17 +79,6 @@ def _get_logo(logo_file, project_root): return f"/static/img/{logo_file.name}" -def _read_secret(port: int = 5002, key: str = "email") -> dict[str, str]: - """Read the key-value pair secrets from vault server.""" - sha = config._get_public_key(config.get("project_name")) - uri = f"http://{config.get('db.host')}:{port}/vault/{key}/{sha}" - try: - req = requests.get(uri).json() - except requests.exceptions.ConnectionError: - req = {} - return req - - def _set_favicon(html_color: str, project_root: Path) -> None: img_folder = Path(project_root) / "static" / "img" tmpl_folder = Path(project_root) / "static_root" / "img" From bfd1e2981313f52cc57393f7b3d71db7219e7268 Mon Sep 17 00:00:00 2001 From: antarcticrainforest Date: Mon, 19 Aug 2024 10:36:55 +0200 Subject: [PATCH 3/3] Bump version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 651ebc90..acb476d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "evaluation_system_web", - "version": "2405.0.0", + "version": "2408.0.0", "description": "React-bits of the freva-web interface. The react-parts of the web interface include the plugin-selection, the data-browser and the result-browser", "main": "index.js", "engines": {