Kumar commited on
Commit ·
ddde0db
1
Parent(s): 9582e8b
Refactor: Achieve Perfect Deployment by standardizing on port 7860 and hardening security
Browse files- Dockerfile +1 -1
- README.md +1 -1
- backend/expense_tracker/settings.py +3 -1
- backend/gunicorn_config.py +1 -1
- backend/start.sh +1 -1
Dockerfile
CHANGED
|
@@ -48,7 +48,7 @@ RUN mkdir -p /app/staticfiles
|
|
| 48 |
RUN SECRET_KEY="build-time-dummy-key" python manage.py collectstatic --noinput
|
| 49 |
|
| 50 |
# Expose port
|
| 51 |
-
EXPOSE
|
| 52 |
|
| 53 |
# Prepare start script
|
| 54 |
RUN sed -i 's/\r$//' /app/start.sh
|
|
|
|
| 48 |
RUN SECRET_KEY="build-time-dummy-key" python manage.py collectstatic --noinput
|
| 49 |
|
| 50 |
# Expose port
|
| 51 |
+
EXPOSE 7860
|
| 52 |
|
| 53 |
# Prepare start script
|
| 54 |
RUN sed -i 's/\r$//' /app/start.sh
|
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 😻
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: pink
|
| 6 |
sdk: docker
|
| 7 |
-
app_port:
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
|
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: pink
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
backend/expense_tracker/settings.py
CHANGED
|
@@ -43,6 +43,7 @@ DEBUG = os.getenv('DEBUG', 'False') == 'True'
|
|
| 43 |
# Combine the default hosts into a single string string
|
| 44 |
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', 'localhost,127.0.0.1,0.0.0.0,finmk.koyeb.app,finmk.onrender.com').split(',')
|
| 45 |
ALLOWED_HOSTS.append('.hf.space')
|
|
|
|
| 46 |
RENDER_EXTERNAL_HOSTNAME = os.environ.get('RENDER_EXTERNAL_HOSTNAME')
|
| 47 |
|
| 48 |
if RENDER_EXTERNAL_HOSTNAME:
|
|
@@ -60,7 +61,8 @@ if ENVIRONMENT == 'production' or RENDER_EXTERNAL_HOSTNAME:
|
|
| 60 |
CSRF_TRUSTED_ORIGINS = [
|
| 61 |
'https://finmk.koyeb.app',
|
| 62 |
'https://finmk.onrender.com',
|
| 63 |
-
'https://*.hf.space'
|
|
|
|
| 64 |
]
|
| 65 |
if RENDER_EXTERNAL_HOSTNAME:
|
| 66 |
CSRF_TRUSTED_ORIGINS.append(f'https://{RENDER_EXTERNAL_HOSTNAME}')
|
|
|
|
| 43 |
# Combine the default hosts into a single string string
|
| 44 |
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', 'localhost,127.0.0.1,0.0.0.0,finmk.koyeb.app,finmk.onrender.com').split(',')
|
| 45 |
ALLOWED_HOSTS.append('.hf.space')
|
| 46 |
+
ALLOWED_HOSTS.append('kumar715-finmk.hf.space')
|
| 47 |
RENDER_EXTERNAL_HOSTNAME = os.environ.get('RENDER_EXTERNAL_HOSTNAME')
|
| 48 |
|
| 49 |
if RENDER_EXTERNAL_HOSTNAME:
|
|
|
|
| 61 |
CSRF_TRUSTED_ORIGINS = [
|
| 62 |
'https://finmk.koyeb.app',
|
| 63 |
'https://finmk.onrender.com',
|
| 64 |
+
'https://*.hf.space',
|
| 65 |
+
'https://kumar715-finmk.hf.space'
|
| 66 |
]
|
| 67 |
if RENDER_EXTERNAL_HOSTNAME:
|
| 68 |
CSRF_TRUSTED_ORIGINS.append(f'https://{RENDER_EXTERNAL_HOSTNAME}')
|
backend/gunicorn_config.py
CHANGED
|
@@ -3,7 +3,7 @@ import os
|
|
| 3 |
# Gunicorn Configuration
|
| 4 |
|
| 5 |
# Bind address
|
| 6 |
-
bind = "0.0.0.0:" + os.getenv("PORT", "
|
| 7 |
|
| 8 |
# Workers
|
| 9 |
workers = 2
|
|
|
|
| 3 |
# Gunicorn Configuration
|
| 4 |
|
| 5 |
# Bind address
|
| 6 |
+
bind = "0.0.0.0:" + os.getenv("PORT", "7860")
|
| 7 |
|
| 8 |
# Workers
|
| 9 |
workers = 2
|
backend/start.sh
CHANGED
|
@@ -14,7 +14,7 @@ python manage.py migrate --noinput
|
|
| 14 |
# python manage.py collectstatic --noinput
|
| 15 |
|
| 16 |
# Set default port if not set
|
| 17 |
-
export PORT="${PORT:-
|
| 18 |
|
| 19 |
# Start Gunicorn
|
| 20 |
echo "Starting Gunicorn on port $PORT..."
|
|
|
|
| 14 |
# python manage.py collectstatic --noinput
|
| 15 |
|
| 16 |
# Set default port if not set
|
| 17 |
+
export PORT="${PORT:-7860}"
|
| 18 |
|
| 19 |
# Start Gunicorn
|
| 20 |
echo "Starting Gunicorn on port $PORT..."
|