mirror of
https://github.com/lemeow125/DocManagerBackend.git
synced 2025-01-18 09:03:00 +08:00
Containerize backend api and add erd generator via django-extensions
This commit is contained in:
parent
cf981c3c08
commit
9b78fdd9ae
7 changed files with 72 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -164,4 +164,5 @@ cython_debug/
|
|||
|
||||
**/__pycache__/
|
||||
|
||||
.vscode/
|
||||
.vscode/
|
||||
schema.yml
|
19
Dockerfile
Normal file
19
Dockerfile
Normal file
|
@ -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" ]
|
30
docker-compose.dev.yml
Normal file
30
docker-compose.dev.yml
Normal file
|
@ -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:
|
|
@ -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"]}
|
||||
|
|
BIN
documentation/erd/app_models.png
Normal file
BIN
documentation/erd/app_models.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 132 KiB |
|
@ -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'
|
15
scripts/start.sh
Normal file
15
scripts/start.sh
Normal file
|
@ -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
|
Loading…
Reference in a new issue