Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
FROM --platform=linux/amd64 python:3.9
FROM python:3.12.0-slim-bookworm

ENV PYTHONUNBUFFERED=1

WORKDIR /api
COPY requirements.txt /api/
RUN pip install --upgrade pip==24.0
RUN pip install -r requirements.txt
39 changes: 4 additions & 35 deletions backend/api/apps.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import inspect
import logging
import pika
import pkgutil
import smtplib
import sys

from collections import namedtuple
from amqp import AMQPError
from django.apps import AppConfig
from django.db.models.signals import post_migrate

from db_comments.db_actions import create_db_comments, \
create_db_comments_from_models
from zeva.settings import RUNSERVER, AMQP_CONNECTION_PARAMETERS, KEYCLOAK, \
EMAIL, DEBUG

logger = logging.getLogger('zeva.apps')

Expand All @@ -30,32 +25,6 @@ def ready(self):
post_migrate.connect(post_migration_callback, sender=self)
sys.modules['api.models.account_balance'] = None

if RUNSERVER:
try:
check_external_services()
except RuntimeError as error:
logger.critical('Startup checks failed.', error)
if not DEBUG:
logger.critical(
'Aborting startup due to failed startup check.', error
)
exit(-1)


def check_external_services():
"""Called after initialization. Use it to validate settings"""

logger.info('Checking AMQP connection')

try:
parameters = AMQP_CONNECTION_PARAMETERS
connection = pika.BlockingConnection(parameters)
connection.channel()
connection.close()
except AMQPError as _error:
logger.error(_error)
raise RuntimeError('AMQP connection failed')


def post_migration_callback(sender, **kwargs):
"""
Expand Down Expand Up @@ -114,12 +83,13 @@ def get_all_model_classes():
# Has to be a local import. Must be loaded late.
import api.models

models_path = api.models.__path__
classes = set()

ModuleInfo = namedtuple('ModuleInfo', ['module_finder', 'name', 'ispkg'])

for (module_finder, name, ispkg) in pkgutil.walk_packages(
api.models.__path__,
models_path,
prefix='api.models.'
):

Expand All @@ -130,9 +100,8 @@ def get_all_model_classes():
mod = sys.modules[sub_module.name]
else:
# load the module
mod = sub_module.module_finder.find_module(
sub_module.name
).load_module()
spec = sub_module.module_finder.find_spec(sub_module.name, models_path)
mod = spec.loader.load_module(spec.name)

for name, obj in inspect.getmembers(mod):
if inspect.getmodule(obj) is not None and \
Expand Down
16 changes: 6 additions & 10 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
amqp==2.5.2
asgiref==3.3.2
astroid==2.3.3
billiard==3.6.1.0
celery==4.4.0
certifi==2022.12.7
cffi
chardet==3.0.4
configparser==5.0.0
coverage==5.0.3
cryptography==42.0.4
Django==3.2.25
django-celery-beat==1.5.0
django-cors-headers==3.2.1
django-enumfields==2.1.1
django-filter==2.4.0
Expand All @@ -26,26 +23,25 @@ lazy-object-proxy==1.4.3
Markdown==3.1.1
mccabe==0.6.1
minio==5.0.10
numpy==1.21.6
pandas==1.1.5
numpy==1.26.0
pandas==2.2.3
pika==1.1.0
psycopg2-binary==2.9.3
psycopg2-binary==2.9.9
pycodestyle==2.5.0
pycparser==2.19
pyjwt==2.1.0
pylint==2.4.4
pylint-django==2.0.13
pylint-plugin-utils==0.6
python-crontab==2.4.0
python-dateutil==2.8.1
python-dateutil==2.9.0
python-dotenv==0.10.5
python-magic==0.4.18
pytz==2022.2.1
requests==2.32.0
six==1.13.0
six==1.16.0
sqlparse==0.5.0
typed-ast
urllib3==1.25.11
urllib3==1.26.20
vine==1.3.0
virtualenv==16.0.0
wrapt==1.11.2
Expand Down
12 changes: 0 additions & 12 deletions backend/zeva/amqp.py

This file was deleted.

25 changes: 0 additions & 25 deletions backend/zeva/celery.py

This file was deleted.

19 changes: 1 addition & 18 deletions backend/zeva/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
import os
import sys

from pika import ConnectionParameters, PlainCredentials
from django.db.models import BigAutoField

from . import database, amqp, email, keycloak, minio
from . import database, email, keycloak, minio

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand Down Expand Up @@ -50,7 +47,6 @@
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django_celery_beat',
'rest_framework',
'zeva',
'corsheaders',
Expand Down Expand Up @@ -110,15 +106,6 @@

KEYCLOAK = keycloak.config()

AMQP = amqp.config()

AMQP_CONNECTION_PARAMETERS = ConnectionParameters(
host=AMQP['HOST'],
port=AMQP['PORT'],
virtual_host=AMQP['VHOST'],
credentials=PlainCredentials(AMQP['USER'], AMQP['PASSWORD'])
)

FILE_UPLOAD_HANDLERS = [
'django.core.files.uploadhandler.TemporaryFileUploadHandler'
]
Expand Down Expand Up @@ -195,10 +182,6 @@
'level': 'INFO',
'handlers': ['console'],
},
'celery': {
'level': 'WARNING',
'handlers': ['console'],
},
'zeva': {
'level': 'INFO',
'handlers': ['console'],
Expand Down
30 changes: 1 addition & 29 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,23 @@ services:
interval: 5s
timeout: 5s
retries: 5
volumes:
- postgres-data:/var/lib/postgresql/data
api:
build: ./backend
command: >
sh -c "python manage.py migrate &&
python manage.py load_ops_data --directory api/fixtures/operational/
python manage.py load_ops_data --directory api/fixtures/test/
python manage.py runserver 0.0.0.0:8000"
env_file:
- backend.env
- minio.env
- rabbitmq.env
volumes:
- ./backend:/api
ports:
- 8000:8000
depends_on:
db:
condition: service_healthy
mailslurper:
build: ./mailslurper
ports:
- 2500:2500
- 8081:8081
- 8085:8085
minio:
image: minio/minio
image: minio/minio:RELEASE.2024-10-13T13-34-11Z-cpuv1
hostname: "minio"
volumes:
- ./minio/minio_files:/minio_files
Expand All @@ -51,30 +40,13 @@ services:
ports:
- 9000:9000
- 9001:9001
rabbitmq:
image: rabbitmq:3.7-management
hostname: "rabbitmq"
environment:
- RABBITMQ_DEFAULT_USER=rabbitmq
- RABBITMQ_DEFAULT_PASS=rabbitmq
- RABBITMQ_DEFAULT_VHOST=/zeva
- RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=-rabbit log_levels [{connection,error}]
ports:
- 15672:15672
- 5672:5672
web:
build: ./frontend
command: npm start
env_file:
- frontend.env
- rabbitmq.env
volumes:
- ./frontend:/web
- /web/node_modules
depends_on:
- rabbitmq
ports:
- 3000:3000
- 8080:8080
volumes:
postgres-data:
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16.20.0
FROM node:20.18.0-bookworm-slim

WORKDIR /web

Expand Down
Loading