diff --git a/.gitignore b/.gitignore index 65834fb..78836ef 100644 --- a/.gitignore +++ b/.gitignore @@ -164,4 +164,5 @@ cython_debug/ **/__pycache__/ -.vscode/ \ No newline at end of file +.vscode/ +schema.yml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..425210d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.13.0-bullseye + +ENV PYTHONBUFFERED=1 +ENV DEBIAN_FRONTEND=noninteractive + +WORKDIR /app +COPY . /app/ +ADD . /app/ +COPY scripts/ /app/scripts/ +RUN chmod +x /app/scripts/start.sh + +# Install packages +RUN apt update && apt install -y graphviz libgraphviz-dev graphviz-dev +RUN pip3 install --upgrade pip && pip3 install --no-cache-dir -r requirements.txt + +# Expose port 8000 for the web server +EXPOSE 8000 + +ENTRYPOINT [ "/app/scripts/start.sh" ] \ No newline at end of file diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..f4286ca --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,30 @@ +services: + django: + env_file: .env + build: + context: . + dockerfile: Dockerfile + image: git.06222001.xyz/keannu125/docmanager_backend:dev + ports: + - "${BACKEND_PORT}:8000" + environment: + - PYTHONBUFFERED=1 + volumes: + - .:/app + + # SMTP Server + inbucket: + image: inbucket/inbucket:latest + ports: + - "8025:8025" + environment: + - INBUCKET_LOGLEVEL=error + - INBUCKET_MAILBOXNAMING=domain + - INBUCKET_SMTP_ADDR=0.0.0.0:1025 + - INBUCKET_SMTP_MAXRECIPIENTS=1000 + - INBUCKET_WEB_ADDR=0.0.0.0:8025 + - INBUCKET_STORAGE_TYPE=memory + - INBUCKET_STORAGE_MAILBOXMSGCAP=2000 + +volumes: + db-data: diff --git a/docmanager_backend/config/settings.py b/docmanager_backend/config/settings.py index c3ce523..3f23ee9 100644 --- a/docmanager_backend/config/settings.py +++ b/docmanager_backend/config/settings.py @@ -82,6 +82,7 @@ INSTALLED_APPS = [ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "django_extensions", "rest_framework", "rest_framework_simplejwt", "djoser", @@ -260,3 +261,6 @@ DEFAULT_FROM_EMAIL = EMAIL_ADDRESS AUTH_USER_MODEL = "accounts.CustomUser" DATA_UPLOAD_MAX_NUMBER_FIELDS = 20480 + +GRAPH_MODELS = {"app_labels": [ + "accounts", "documents", "document_requests", "questionnaires"]} diff --git a/documentation/erd/app_models.png b/documentation/erd/app_models.png new file mode 100644 index 0000000..a83f08e Binary files /dev/null and b/documentation/erd/app_models.png differ diff --git a/requirements.txt b/requirements.txt index d86a6b3..680deb8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -44,3 +44,5 @@ tzdata==2024.2 uritemplate==4.1.1 urllib3==2.2.3 whitenoise==6.8.2 +django-extensions==3.2.3 +pygraphviz==1.14; platform_system == 'Linux' \ No newline at end of file diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100644 index 0000000..ee81d26 --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +cd docmanager_backend/ +python manage.py graph_models -o ../documentation/erd/app_models.png +python manage.py spectacular --color --file schema.yml +python manage.py migrate +if [ ! -d "static" ]; then + echo "Generating static files" + python manage.py collectstatic --noinput +fi +if [ "$DEBUG" = 'True' ]; then + python manage.py runserver "0.0.0.0:8000" +else + gunicorn --workers 8 --bind 0.0.0.0:8000 config.wsgi:application +fi