CineDev commited on
Commit
03b5abf
·
1 Parent(s): 4f6690f

Configure frontend for Vercel deployment and backend for Hugging Face Spaces Docker

Browse files
Files changed (4) hide show
  1. Dockerfile +39 -0
  2. aureon_backend/settings.py +9 -3
  3. requirements.txt +51 -3
  4. start.sh +17 -0
Dockerfile ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use python 3.11 slim image
2
+ FROM python:3.11-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+ ENV PYTHONUNBUFFERED=1
7
+ ENV PORT=7860
8
+
9
+ # Install system dependencies
10
+ RUN apt-get update && apt-get install -y --no-install-recommends \
11
+ build-essential \
12
+ libpq-dev \
13
+ curl \
14
+ && rm -rf /var/lib/apt/lists/*
15
+
16
+ # Create user with UID 1000 to match Hugging Face Spaces expectation
17
+ RUN useradd -m -u 1000 user
18
+ USER user
19
+ ENV HOME=/home/user
20
+ ENV PATH=/home/user/.local/bin:$PATH
21
+
22
+ # Set working directory inside user's home
23
+ WORKDIR $HOME/app
24
+
25
+ # Copy requirements.txt and install dependencies
26
+ COPY --chown=user requirements.txt .
27
+ RUN pip install --no-cache-dir --user -r requirements.txt
28
+
29
+ # Copy application files
30
+ COPY --chown=user . .
31
+
32
+ # Ensure start.sh has execute permissions
33
+ RUN chmod +x start.sh
34
+
35
+ # Expose port 7860
36
+ EXPOSE 7860
37
+
38
+ # Run start.sh to run migrations and launch gunicorn
39
+ CMD ["./start.sh"]
aureon_backend/settings.py CHANGED
@@ -122,9 +122,15 @@ CORS_ALLOW_METHODS = [
122
  ]
123
 
124
  # CSRF Settings
125
- CSRF_TRUSTED_ORIGINS = ['http://localhost:5173', 'http://127.0.0.1:5173']
126
- CSRF_COOKIE_SECURE = False
127
- CSRF_COOKIE_HTTPONLY = False
 
 
 
 
 
 
128
 
129
  # Cache Configuration (required for JWKS key caching)
130
  CACHES = {
 
122
  ]
123
 
124
  # CSRF Settings
125
+ CSRF_TRUSTED_ORIGINS = [
126
+ origin.strip() for origin in os.getenv(
127
+ 'CSRF_TRUSTED_ORIGINS',
128
+ 'http://localhost:5173,http://127.0.0.1:5173'
129
+ ).split(',')
130
+ if origin.strip()
131
+ ]
132
+ CSRF_COOKIE_SECURE = not DEBUG
133
+ CSRF_COOKIE_HTTPONLY = True
134
 
135
  # Cache Configuration (required for JWKS key caching)
136
  CACHES = {
requirements.txt CHANGED
@@ -1,3 +1,51 @@
1
- PyJWT[crypto]>=2.8.0
2
- requests>=2.31.0
3
- cryptography>=41.0.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiohappyeyeballs==2.6.1
2
+ aiohttp==3.13.3
3
+ aiohttp-retry==2.9.1
4
+ aiosignal==1.4.0
5
+ annotated-types==0.7.0
6
+ anyio==4.12.1
7
+ asgiref==3.11.1
8
+ attrs==25.4.0
9
+ certifi==2026.1.4
10
+ cffi==2.0.0
11
+ charset-normalizer==3.4.4
12
+ cryptography==46.0.5
13
+ dataclasses==0.6
14
+ dj-database-url==3.1.0
15
+ Django==6.0.2
16
+ django-cors-headers==4.9.0
17
+ django-sendgrid-v5==1.3.1
18
+ djangorestframework==3.16.1
19
+ djongo==1.2.31
20
+ dnspython==2.8.0
21
+ frozenlist==1.8.0
22
+ gotrue==2.12.4
23
+ h11==0.16.0
24
+ h2==4.3.0
25
+ hpack==4.1.0
26
+ httpcore==1.0.9
27
+ httpx==0.28.1
28
+ hyperframe==6.1.0
29
+ idna==3.11
30
+ MarkupSafe==3.0.3
31
+ multidict==6.7.1
32
+ propcache==0.4.1
33
+ psycopg2-binary==2.9.11
34
+ pycparser==3.0
35
+ pydantic==2.12.5
36
+ pydantic_core==2.41.5
37
+ PyJWT==2.11.0
38
+ pymongo==4.16.0
39
+ pypdf==6.11.0
40
+ python-dotenv==1.2.1
41
+ python-http-client==3.3.7
42
+ requests==2.32.5
43
+ sendgrid==6.12.5
44
+ sqlparse==0.5.5
45
+ twilio==9.10.1
46
+ typing-inspection==0.4.2
47
+ typing_extensions==4.15.0
48
+ urllib3==2.6.3
49
+ Werkzeug==3.1.5
50
+ yarl==1.22.0
51
+ gunicorn==21.2.0
start.sh ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Exit on error except for migrations
3
+ set -e
4
+
5
+ echo "Starting backend setup..."
6
+
7
+ # Run database migrations
8
+ if [ -n "$DATABASE_URL" ]; then
9
+ echo "DATABASE_URL is set, running migrations..."
10
+ python manage.py migrate --noinput || echo "Migration command failed, starting server anyway..."
11
+ else
12
+ echo "DATABASE_URL is not set, skipping migrations..."
13
+ fi
14
+
15
+ # Start Gunicorn
16
+ echo "Starting Gunicorn..."
17
+ exec gunicorn --bind 0.0.0.0:7860 --workers 4 --timeout 120 aureon_backend.wsgi:application