Skip to content

Commit

Permalink
Merge pull request #15 from SmartReports/VercelDeployTest
Browse files Browse the repository at this point in the history
Vercel deploy test
  • Loading branch information
PaulMagos authored Nov 10, 2023
2 parents bb91f80 + 8c132de commit 990c491
Show file tree
Hide file tree
Showing 7 changed files with 1,834 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# node_modules
node_modules
4 changes: 4 additions & 0 deletions build_static.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
echo "BUILD START"
python3 -m pip install -r requirements.txt
python3 manage.py collectstatic --noinput --clear
echo "BUILD END"
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"vercel": "^32.5.3"
}
}
2 changes: 1 addition & 1 deletion server_run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pip3 install -r requirements.txt
./build_static.sh
pip3 freeze > requirements.txt
python3 manage.py makemigrations
python3 manage.py migrate --fake
Expand Down
41 changes: 20 additions & 21 deletions smartreport/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"smartreport_app.apps.SmartreportAppConfig",
"smartreport_app",
"corsheaders",
'django_filters',
]
Expand Down Expand Up @@ -80,7 +80,7 @@
},
]

WSGI_APPLICATION = "smartreport.wsgi.app"
WSGI_APPLICATION = "smartreport.wsgi.application"

CORS_ALLOWED_ORIGINS = [
"http://127.0.0.1:3000",
Expand All @@ -100,22 +100,25 @@
}
}
else:
DATABASES = {
# If no environ variables exists ->
if not os.environ.get("POSTGRES_DATABASE"):
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
else :
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
"ENGINE": "django.db.backends.postgresql",
"NAME": os.environ.get("POSTGRES_DATABASE"), # database name
"USER": os.environ.get("POSTGRES_USER"),
"PASSWORD": os.environ.get("POSTGRES_PASSWORD"),
"HOST": os.environ.get("POSTGRES_HOST"),
"PORT": os.environ.get("POSTGRES_PORT"),
}
}
# DATABASES = {
# "default": {
# "ENGINE": "django.db.backends.postgresql",
# "NAME": "verceldb", # database name
# "USER": "default",
# "PASSWORD": "FaDflmKI2P3W",
# "HOST": "ep-tiny-butterfly-10712856-pooler.eu-central-1.postgres.vercel-storage.com",
# "PORT": "5432",
# }
# }

# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
Expand Down Expand Up @@ -158,12 +161,8 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATIC_URL = "static/"
STATIC_ROOT = './smartreport/static'

STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles_build', 'static')
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

Expand Down
17 changes: 15 additions & 2 deletions vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@
"builds": [{
"src": "smartreport/wsgi.py",
"use": "@vercel/python",
"config": { "maxLambdaSize": "25mb" }
}],
"config": { "maxLambdaSize": "15mb", "runtime": "python3.9" }
}
,
{
"src": "build_files.sh",
"use": "@vercel/static-build",
"config": {
"distDir": "staticfiles_build"
}
}
],
"routes": [
{
"src": "/static/(.*)",
"dest": "/static/$1"
},
{
"src": "/(.*)",
"dest": "smartreport/wsgi.py"
Expand Down
Loading

0 comments on commit 990c491

Please sign in to comment.