From efe47b973b3e1097549eb74bba477b62cc9f4553 Mon Sep 17 00:00:00 2001 From: Matias Vallejos Date: Tue, 13 Feb 2024 18:28:51 -0300 Subject: [PATCH] Refolder project and prepare for vercel deployment --- app/.flake8 => .flake8 | 0 app/build.sh | 14 ---------- {app/auth_api => auth_api}/__init__.py | 0 {app/auth_api => auth_api}/admin.py | 0 {app/auth_api => auth_api}/apps.py | 0 {app/auth_api => auth_api}/models.py | 0 {app/auth_api => auth_api}/tests/__init__.py | 0 .../tests/test_auth_api.py | 0 {app/auth_api => auth_api}/urls.py | 0 {app/auth_api => auth_api}/views.py | 0 build.sh | 11 ++++++++ {app/core => core}/__init__.py | 0 {app/core => core}/admin.py | 0 {app/core => core}/apps.py | 0 .../management/commands/wait_for_db.py | 0 {app/core => core}/migrations/0001_initial.py | 0 {app/core => core}/migrations/__init__.py | 0 {app/core => core}/models.py | 0 {app/core => core}/serializers.py | 0 {app/core => core}/tests/__init__.py | 0 {app/core => core}/tests/test_admin.py | 0 {app/core => core}/tests/test_commands.py | 0 {app/core => core}/tests/test_models.py | 0 {app/core => core}/tests/test_utils.py | 0 {app/core => core}/utils.py | 0 {app/core => core}/views.py | 0 app/manage.py => manage.py | 0 ...quirements.dev.txt => requirements.dev.txt | 0 app/requirements.txt => requirements.txt | 0 {app/todo_api => todo_api}/__init__.py | 0 {app/todo_api => todo_api}/admin.py | 0 {app/todo_api => todo_api}/apps.py | 0 .../migrations/0001_initial.py | 0 .../migrations/__init__.py | 0 {app/todo_api => todo_api}/models.py | 0 {app/todo_api => todo_api}/serializers.py | 0 {app/todo_api => todo_api}/tests/__init__.py | 0 .../tests/test_models.py | 0 .../tests/test_task_api.py | 0 .../tests/test_task_list_api.py | 0 {app/todo_api => todo_api}/urls.py | 0 {app/todo_api => todo_api}/views.py | 0 .../todo_project => todo_project}/__init__.py | 0 {app/todo_project => todo_project}/asgi.py | 0 .../middleware.py | 0 .../todo_project => todo_project}/settings.py | 6 ++-- {app/todo_project => todo_project}/urls.py | 0 {app/todo_project => todo_project}/wsgi.py | 2 ++ {app/user_api => user_api}/__init__.py | 0 {app/user_api => user_api}/admin.py | 0 {app/user_api => user_api}/apps.py | 0 {app/user_api => user_api}/models.py | 0 {app/user_api => user_api}/permissions.py | 0 {app/user_api => user_api}/tests/__init__.py | 0 .../tests/test_user_api.py | 0 {app/user_api => user_api}/urls.py | 0 {app/user_api => user_api}/views.py | 0 vercel.json | 28 +++++++++++++++++++ 58 files changed, 44 insertions(+), 17 deletions(-) rename app/.flake8 => .flake8 (100%) delete mode 100644 app/build.sh rename {app/auth_api => auth_api}/__init__.py (100%) rename {app/auth_api => auth_api}/admin.py (100%) rename {app/auth_api => auth_api}/apps.py (100%) rename {app/auth_api => auth_api}/models.py (100%) rename {app/auth_api => auth_api}/tests/__init__.py (100%) rename {app/auth_api => auth_api}/tests/test_auth_api.py (100%) rename {app/auth_api => auth_api}/urls.py (100%) rename {app/auth_api => auth_api}/views.py (100%) create mode 100644 build.sh rename {app/core => core}/__init__.py (100%) rename {app/core => core}/admin.py (100%) rename {app/core => core}/apps.py (100%) rename {app/core => core}/management/commands/wait_for_db.py (100%) rename {app/core => core}/migrations/0001_initial.py (100%) rename {app/core => core}/migrations/__init__.py (100%) rename {app/core => core}/models.py (100%) rename {app/core => core}/serializers.py (100%) rename {app/core => core}/tests/__init__.py (100%) rename {app/core => core}/tests/test_admin.py (100%) rename {app/core => core}/tests/test_commands.py (100%) rename {app/core => core}/tests/test_models.py (100%) rename {app/core => core}/tests/test_utils.py (100%) rename {app/core => core}/utils.py (100%) rename {app/core => core}/views.py (100%) rename app/manage.py => manage.py (100%) rename app/requirements.dev.txt => requirements.dev.txt (100%) rename app/requirements.txt => requirements.txt (100%) rename {app/todo_api => todo_api}/__init__.py (100%) rename {app/todo_api => todo_api}/admin.py (100%) rename {app/todo_api => todo_api}/apps.py (100%) rename {app/todo_api => todo_api}/migrations/0001_initial.py (100%) rename {app/todo_api => todo_api}/migrations/__init__.py (100%) rename {app/todo_api => todo_api}/models.py (100%) rename {app/todo_api => todo_api}/serializers.py (100%) rename {app/todo_api => todo_api}/tests/__init__.py (100%) rename {app/todo_api => todo_api}/tests/test_models.py (100%) rename {app/todo_api => todo_api}/tests/test_task_api.py (100%) rename {app/todo_api => todo_api}/tests/test_task_list_api.py (100%) rename {app/todo_api => todo_api}/urls.py (100%) rename {app/todo_api => todo_api}/views.py (100%) rename {app/todo_project => todo_project}/__init__.py (100%) rename {app/todo_project => todo_project}/asgi.py (100%) rename {app/todo_project => todo_project}/middleware.py (100%) rename {app/todo_project => todo_project}/settings.py (97%) rename {app/todo_project => todo_project}/urls.py (100%) rename {app/todo_project => todo_project}/wsgi.py (95%) rename {app/user_api => user_api}/__init__.py (100%) rename {app/user_api => user_api}/admin.py (100%) rename {app/user_api => user_api}/apps.py (100%) rename {app/user_api => user_api}/models.py (100%) rename {app/user_api => user_api}/permissions.py (100%) rename {app/user_api => user_api}/tests/__init__.py (100%) rename {app/user_api => user_api}/tests/test_user_api.py (100%) rename {app/user_api => user_api}/urls.py (100%) rename {app/user_api => user_api}/views.py (100%) create mode 100644 vercel.json diff --git a/app/.flake8 b/.flake8 similarity index 100% rename from app/.flake8 rename to .flake8 diff --git a/app/build.sh b/app/build.sh deleted file mode 100644 index 5cfc0cf..0000000 --- a/app/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -# exit on error -set -o errexit - -pip install -r requirements.txt - -# How to automate createsuperuser on django -# python manage.py shell -c "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.filter(email='matiasvallejosdev@outlook.com').delete(); User.objects.create_superuser(email='matiasvallejosdev@outlook.com', password='19573')" - -python manage.py collectstatic --no-input -python manage.py migrate - -python manage.py drop_test_database --noinput -python manage.py test \ No newline at end of file diff --git a/app/auth_api/__init__.py b/auth_api/__init__.py similarity index 100% rename from app/auth_api/__init__.py rename to auth_api/__init__.py diff --git a/app/auth_api/admin.py b/auth_api/admin.py similarity index 100% rename from app/auth_api/admin.py rename to auth_api/admin.py diff --git a/app/auth_api/apps.py b/auth_api/apps.py similarity index 100% rename from app/auth_api/apps.py rename to auth_api/apps.py diff --git a/app/auth_api/models.py b/auth_api/models.py similarity index 100% rename from app/auth_api/models.py rename to auth_api/models.py diff --git a/app/auth_api/tests/__init__.py b/auth_api/tests/__init__.py similarity index 100% rename from app/auth_api/tests/__init__.py rename to auth_api/tests/__init__.py diff --git a/app/auth_api/tests/test_auth_api.py b/auth_api/tests/test_auth_api.py similarity index 100% rename from app/auth_api/tests/test_auth_api.py rename to auth_api/tests/test_auth_api.py diff --git a/app/auth_api/urls.py b/auth_api/urls.py similarity index 100% rename from app/auth_api/urls.py rename to auth_api/urls.py diff --git a/app/auth_api/views.py b/auth_api/views.py similarity index 100% rename from app/auth_api/views.py rename to auth_api/views.py diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..fcff1b3 --- /dev/null +++ b/build.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# exit on error +set -o errexit + +pip install -r requirements.txt + +python manage.py collectstatic --no-input +python manage.py migrate + +python manage.py drop_test_database --noinput +python manage.py test \ No newline at end of file diff --git a/app/core/__init__.py b/core/__init__.py similarity index 100% rename from app/core/__init__.py rename to core/__init__.py diff --git a/app/core/admin.py b/core/admin.py similarity index 100% rename from app/core/admin.py rename to core/admin.py diff --git a/app/core/apps.py b/core/apps.py similarity index 100% rename from app/core/apps.py rename to core/apps.py diff --git a/app/core/management/commands/wait_for_db.py b/core/management/commands/wait_for_db.py similarity index 100% rename from app/core/management/commands/wait_for_db.py rename to core/management/commands/wait_for_db.py diff --git a/app/core/migrations/0001_initial.py b/core/migrations/0001_initial.py similarity index 100% rename from app/core/migrations/0001_initial.py rename to core/migrations/0001_initial.py diff --git a/app/core/migrations/__init__.py b/core/migrations/__init__.py similarity index 100% rename from app/core/migrations/__init__.py rename to core/migrations/__init__.py diff --git a/app/core/models.py b/core/models.py similarity index 100% rename from app/core/models.py rename to core/models.py diff --git a/app/core/serializers.py b/core/serializers.py similarity index 100% rename from app/core/serializers.py rename to core/serializers.py diff --git a/app/core/tests/__init__.py b/core/tests/__init__.py similarity index 100% rename from app/core/tests/__init__.py rename to core/tests/__init__.py diff --git a/app/core/tests/test_admin.py b/core/tests/test_admin.py similarity index 100% rename from app/core/tests/test_admin.py rename to core/tests/test_admin.py diff --git a/app/core/tests/test_commands.py b/core/tests/test_commands.py similarity index 100% rename from app/core/tests/test_commands.py rename to core/tests/test_commands.py diff --git a/app/core/tests/test_models.py b/core/tests/test_models.py similarity index 100% rename from app/core/tests/test_models.py rename to core/tests/test_models.py diff --git a/app/core/tests/test_utils.py b/core/tests/test_utils.py similarity index 100% rename from app/core/tests/test_utils.py rename to core/tests/test_utils.py diff --git a/app/core/utils.py b/core/utils.py similarity index 100% rename from app/core/utils.py rename to core/utils.py diff --git a/app/core/views.py b/core/views.py similarity index 100% rename from app/core/views.py rename to core/views.py diff --git a/app/manage.py b/manage.py similarity index 100% rename from app/manage.py rename to manage.py diff --git a/app/requirements.dev.txt b/requirements.dev.txt similarity index 100% rename from app/requirements.dev.txt rename to requirements.dev.txt diff --git a/app/requirements.txt b/requirements.txt similarity index 100% rename from app/requirements.txt rename to requirements.txt diff --git a/app/todo_api/__init__.py b/todo_api/__init__.py similarity index 100% rename from app/todo_api/__init__.py rename to todo_api/__init__.py diff --git a/app/todo_api/admin.py b/todo_api/admin.py similarity index 100% rename from app/todo_api/admin.py rename to todo_api/admin.py diff --git a/app/todo_api/apps.py b/todo_api/apps.py similarity index 100% rename from app/todo_api/apps.py rename to todo_api/apps.py diff --git a/app/todo_api/migrations/0001_initial.py b/todo_api/migrations/0001_initial.py similarity index 100% rename from app/todo_api/migrations/0001_initial.py rename to todo_api/migrations/0001_initial.py diff --git a/app/todo_api/migrations/__init__.py b/todo_api/migrations/__init__.py similarity index 100% rename from app/todo_api/migrations/__init__.py rename to todo_api/migrations/__init__.py diff --git a/app/todo_api/models.py b/todo_api/models.py similarity index 100% rename from app/todo_api/models.py rename to todo_api/models.py diff --git a/app/todo_api/serializers.py b/todo_api/serializers.py similarity index 100% rename from app/todo_api/serializers.py rename to todo_api/serializers.py diff --git a/app/todo_api/tests/__init__.py b/todo_api/tests/__init__.py similarity index 100% rename from app/todo_api/tests/__init__.py rename to todo_api/tests/__init__.py diff --git a/app/todo_api/tests/test_models.py b/todo_api/tests/test_models.py similarity index 100% rename from app/todo_api/tests/test_models.py rename to todo_api/tests/test_models.py diff --git a/app/todo_api/tests/test_task_api.py b/todo_api/tests/test_task_api.py similarity index 100% rename from app/todo_api/tests/test_task_api.py rename to todo_api/tests/test_task_api.py diff --git a/app/todo_api/tests/test_task_list_api.py b/todo_api/tests/test_task_list_api.py similarity index 100% rename from app/todo_api/tests/test_task_list_api.py rename to todo_api/tests/test_task_list_api.py diff --git a/app/todo_api/urls.py b/todo_api/urls.py similarity index 100% rename from app/todo_api/urls.py rename to todo_api/urls.py diff --git a/app/todo_api/views.py b/todo_api/views.py similarity index 100% rename from app/todo_api/views.py rename to todo_api/views.py diff --git a/app/todo_project/__init__.py b/todo_project/__init__.py similarity index 100% rename from app/todo_project/__init__.py rename to todo_project/__init__.py diff --git a/app/todo_project/asgi.py b/todo_project/asgi.py similarity index 100% rename from app/todo_project/asgi.py rename to todo_project/asgi.py diff --git a/app/todo_project/middleware.py b/todo_project/middleware.py similarity index 100% rename from app/todo_project/middleware.py rename to todo_project/middleware.py diff --git a/app/todo_project/settings.py b/todo_project/settings.py similarity index 97% rename from app/todo_project/settings.py rename to todo_project/settings.py index 5d349ef..b50a74c 100644 --- a/app/todo_project/settings.py +++ b/todo_project/settings.py @@ -22,9 +22,9 @@ SECRET_KEY = os.environ.get("SECRET_KEY", "SgLSDnEtU4kkqXJMYTJbKCq861VpNd5s") # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = 'RENDER' not in os.environ +DEBUG = True -ALLOWED_HOSTS = ["*", "localhost", "127.0.0.1", ".vercel.app"] +ALLOWED_HOSTS = ["*", "localhost", "127.0.0.1", ".vercel.app", ".now.sh"] RENDER_EXTERNAL_HOSTNAME = os.environ.get("RENDER_EXTERNAL_HOSTNAME") @@ -158,7 +158,7 @@ STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")] if not DEBUG: # Tell Django to copy statics to the `staticfiles` directory - STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles/") + STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles_build", "static") MEDIA_ROOT = os.path.join(BASE_DIR, "staticfiles/images") STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" diff --git a/app/todo_project/urls.py b/todo_project/urls.py similarity index 100% rename from app/todo_project/urls.py rename to todo_project/urls.py diff --git a/app/todo_project/wsgi.py b/todo_project/wsgi.py similarity index 95% rename from app/todo_project/wsgi.py rename to todo_project/wsgi.py index 5593023..008edd4 100644 --- a/app/todo_project/wsgi.py +++ b/todo_project/wsgi.py @@ -11,3 +11,5 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "todo_project.settings") application = get_wsgi_application() + +app = application diff --git a/app/user_api/__init__.py b/user_api/__init__.py similarity index 100% rename from app/user_api/__init__.py rename to user_api/__init__.py diff --git a/app/user_api/admin.py b/user_api/admin.py similarity index 100% rename from app/user_api/admin.py rename to user_api/admin.py diff --git a/app/user_api/apps.py b/user_api/apps.py similarity index 100% rename from app/user_api/apps.py rename to user_api/apps.py diff --git a/app/user_api/models.py b/user_api/models.py similarity index 100% rename from app/user_api/models.py rename to user_api/models.py diff --git a/app/user_api/permissions.py b/user_api/permissions.py similarity index 100% rename from app/user_api/permissions.py rename to user_api/permissions.py diff --git a/app/user_api/tests/__init__.py b/user_api/tests/__init__.py similarity index 100% rename from app/user_api/tests/__init__.py rename to user_api/tests/__init__.py diff --git a/app/user_api/tests/test_user_api.py b/user_api/tests/test_user_api.py similarity index 100% rename from app/user_api/tests/test_user_api.py rename to user_api/tests/test_user_api.py diff --git a/app/user_api/urls.py b/user_api/urls.py similarity index 100% rename from app/user_api/urls.py rename to user_api/urls.py diff --git a/app/user_api/views.py b/user_api/views.py similarity index 100% rename from app/user_api/views.py rename to user_api/views.py diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..013b339 --- /dev/null +++ b/vercel.json @@ -0,0 +1,28 @@ + +{ + "version": 2, + "builds": [ + { + "src": "todo_project/wsgi.py", + "use": "@vercel/python", + "config": { "maxLambdaSize": "15mb", "runtime": "python3.9" } + }, + { + "src": "build.sh", + "use": "@vercel/static-build", + "config": { + "distDir": "staticfiles_build" + } + } + ], + "routes": [ + { + "src": "/static/(.*)", + "dest": "/static/$1" + }, + { + "src": "/(.*)", + "dest": "todo_project/wsgi.py" + } + ] + } \ No newline at end of file