Skip to content

Commit

Permalink
Refolder project and prepare for vercel deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasvallejosdev committed Feb 13, 2024
1 parent 14d776e commit efe47b9
Show file tree
Hide file tree
Showing 58 changed files with 44 additions and 17 deletions.
File renamed without changes.
14 changes: 0 additions & 14 deletions app/build.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions app/todo_project/settings.py → todo_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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"

Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions app/todo_project/wsgi.py → todo_project/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "todo_project.settings")
application = get_wsgi_application()

app = application
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}

0 comments on commit efe47b9

Please sign in to comment.