Commit
·
1e6288e
1
Parent(s):
a94a0fe
preparing of deplyoment on higgingface
Browse files- .DS_Store +0 -0
- Dockerfile +28 -0
- backend/Dockerfile +20 -20
- docker-compose.yml +58 -58
- render.yaml +0 -66
- startup.sh +13 -0
.DS_Store
CHANGED
|
Binary files a/.DS_Store and b/.DS_Store differ
|
|
|
Dockerfile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This is the single Dockerfile for our entire backend on Hugging Face Spaces
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
+
|
| 4 |
+
# Set a single working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Install system dependencies
|
| 8 |
+
RUN apt-get update && apt-get install -y git redis-server
|
| 9 |
+
|
| 10 |
+
# Copy all requirements and model files first for better caching
|
| 11 |
+
COPY backend/requirements.txt .
|
| 12 |
+
COPY ml_models ./ml_models
|
| 13 |
+
|
| 14 |
+
# Install Python packages
|
| 15 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 16 |
+
|
| 17 |
+
# Copy the entire backend source code
|
| 18 |
+
COPY backend .
|
| 19 |
+
|
| 20 |
+
# Create a startup script
|
| 21 |
+
COPY startup.sh .
|
| 22 |
+
RUN chmod +x startup.sh
|
| 23 |
+
|
| 24 |
+
# Expose the port FastAPI will run on
|
| 25 |
+
EXPOSE 7860
|
| 26 |
+
|
| 27 |
+
# The command to run our startup script
|
| 28 |
+
CMD ["./startup.sh"]
|
backend/Dockerfile
CHANGED
|
@@ -1,15 +1,15 @@
|
|
| 1 |
-
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
|
| 10 |
-
|
| 11 |
|
| 12 |
-
|
| 13 |
|
| 14 |
|
| 15 |
|
|
@@ -35,22 +35,22 @@
|
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
-
FROM python:3.11-slim
|
| 39 |
|
| 40 |
-
WORKDIR /code
|
| 41 |
|
| 42 |
-
RUN apt-get update && apt-get install -y git
|
| 43 |
|
| 44 |
-
COPY ./backend/requirements.txt .
|
| 45 |
-
# Install Gunicorn for a production-ready server
|
| 46 |
-
RUN pip install gunicorn
|
| 47 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 48 |
|
| 49 |
-
COPY ./ml_models /code/sentiment_model
|
| 50 |
|
| 51 |
-
# Copy the application code last. All code will live in /code now.
|
| 52 |
-
COPY ./backend .
|
| 53 |
|
| 54 |
-
# The default command is to start the web server.
|
| 55 |
-
# Render's free web services require port 10000.
|
| 56 |
-
CMD ["gunicorn", "-w", "2", "-k", "uvicorn.workers.UvicornWorker", "main:app", "--bind", "0.0.0.0:10000"]
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
|
| 3 |
+
WORKDIR /code
|
| 4 |
|
| 5 |
+
RUN apt-get update && apt-get install -y git
|
| 6 |
|
| 7 |
+
COPY ./backend/requirements.txt .
|
| 8 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 9 |
|
| 10 |
+
COPY ./ml_models /code/sentiment_model
|
| 11 |
|
| 12 |
+
WORKDIR /code/app
|
| 13 |
|
| 14 |
|
| 15 |
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
+
# FROM python:3.11-slim
|
| 39 |
|
| 40 |
+
# WORKDIR /code
|
| 41 |
|
| 42 |
+
# RUN apt-get update && apt-get install -y git
|
| 43 |
|
| 44 |
+
# COPY ./backend/requirements.txt .
|
| 45 |
+
# # Install Gunicorn for a production-ready server
|
| 46 |
+
# RUN pip install gunicorn
|
| 47 |
+
# RUN pip install --no-cache-dir -r requirements.txt
|
| 48 |
|
| 49 |
+
# COPY ./ml_models /code/sentiment_model
|
| 50 |
|
| 51 |
+
# # Copy the application code last. All code will live in /code now.
|
| 52 |
+
# COPY ./backend .
|
| 53 |
|
| 54 |
+
# # The default command is to start the web server.
|
| 55 |
+
# # Render's free web services require port 10000.
|
| 56 |
+
# CMD ["gunicorn", "-w", "2", "-k", "uvicorn.workers.UvicornWorker", "main:app", "--bind", "0.0.0.0:10000"]
|
docker-compose.yml
CHANGED
|
@@ -1,61 +1,5 @@
|
|
| 1 |
-
# services:
|
| 2 |
-
# # --- Application Services ---
|
| 3 |
-
# redis:
|
| 4 |
-
# image: redis:7-alpine
|
| 5 |
-
# ports:
|
| 6 |
-
# - "6379:6379"
|
| 7 |
-
# restart: always
|
| 8 |
-
|
| 9 |
-
# backend:
|
| 10 |
-
# build:
|
| 11 |
-
# context: .
|
| 12 |
-
# dockerfile: ./backend/Dockerfile
|
| 13 |
-
# ports:
|
| 14 |
-
# - "8000:8000"
|
| 15 |
-
# volumes:
|
| 16 |
-
# - ./backend:/code/app
|
| 17 |
-
# env_file:
|
| 18 |
-
# - .env
|
| 19 |
-
# command: python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload
|
| 20 |
-
# restart: always
|
| 21 |
-
# depends_on:
|
| 22 |
-
# - redis
|
| 23 |
-
|
| 24 |
-
# worker:
|
| 25 |
-
# build:
|
| 26 |
-
# context: .
|
| 27 |
-
# dockerfile: ./backend/Dockerfile
|
| 28 |
-
# volumes:
|
| 29 |
-
# - ./backend:/code/app
|
| 30 |
-
# env_file:
|
| 31 |
-
# - .env
|
| 32 |
-
# command: python -m celery -A celery_worker.celery worker --loglevel=info
|
| 33 |
-
# restart: always
|
| 34 |
-
# depends_on:
|
| 35 |
-
# - redis
|
| 36 |
-
# - backend
|
| 37 |
-
|
| 38 |
-
# frontend:
|
| 39 |
-
# build:
|
| 40 |
-
# context: .
|
| 41 |
-
# dockerfile: ./frontend/Dockerfile
|
| 42 |
-
# ports:
|
| 43 |
-
# - "5173:5173"
|
| 44 |
-
# volumes:
|
| 45 |
-
# - ./frontend:/app
|
| 46 |
-
# - /app/node_modules
|
| 47 |
-
# restart: always
|
| 48 |
-
# depends_on:
|
| 49 |
-
# - backend
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
services:
|
|
|
|
| 59 |
redis:
|
| 60 |
image: redis:7-alpine
|
| 61 |
ports:
|
|
@@ -102,4 +46,60 @@ services:
|
|
| 102 |
- /app/node_modules
|
| 103 |
restart: always
|
| 104 |
depends_on:
|
| 105 |
-
- backend
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
services:
|
| 2 |
+
# --- Application Services ---
|
| 3 |
redis:
|
| 4 |
image: redis:7-alpine
|
| 5 |
ports:
|
|
|
|
| 46 |
- /app/node_modules
|
| 47 |
restart: always
|
| 48 |
depends_on:
|
| 49 |
+
- backend
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
# services:
|
| 59 |
+
# redis:
|
| 60 |
+
# image: redis:7-alpine
|
| 61 |
+
# ports:
|
| 62 |
+
# - "6379:6379"
|
| 63 |
+
# restart: always
|
| 64 |
+
|
| 65 |
+
# backend:
|
| 66 |
+
# build:
|
| 67 |
+
# context: .
|
| 68 |
+
# dockerfile: ./backend/Dockerfile
|
| 69 |
+
# ports:
|
| 70 |
+
# - "8000:8000"
|
| 71 |
+
# volumes:
|
| 72 |
+
# - ./backend:/code/app
|
| 73 |
+
# env_file:
|
| 74 |
+
# - .env
|
| 75 |
+
# command: python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload
|
| 76 |
+
# restart: always
|
| 77 |
+
# depends_on:
|
| 78 |
+
# - redis
|
| 79 |
+
|
| 80 |
+
# worker:
|
| 81 |
+
# build:
|
| 82 |
+
# context: .
|
| 83 |
+
# dockerfile: ./backend/Dockerfile
|
| 84 |
+
# volumes:
|
| 85 |
+
# - ./backend:/code/app
|
| 86 |
+
# env_file:
|
| 87 |
+
# - .env
|
| 88 |
+
# command: python -m celery -A celery_worker.celery worker --loglevel=info
|
| 89 |
+
# restart: always
|
| 90 |
+
# depends_on:
|
| 91 |
+
# - redis
|
| 92 |
+
# - backend
|
| 93 |
+
|
| 94 |
+
# frontend:
|
| 95 |
+
# build:
|
| 96 |
+
# context: .
|
| 97 |
+
# dockerfile: ./frontend/Dockerfile
|
| 98 |
+
# ports:
|
| 99 |
+
# - "5173:5173"
|
| 100 |
+
# volumes:
|
| 101 |
+
# - ./frontend:/app
|
| 102 |
+
# - /app/node_modules
|
| 103 |
+
# restart: always
|
| 104 |
+
# depends_on:
|
| 105 |
+
# - backend
|
render.yaml
DELETED
|
@@ -1,66 +0,0 @@
|
|
| 1 |
-
# This is the instruction manual for deploying on Render.
|
| 2 |
-
services:
|
| 3 |
-
# Service 1: The Redis instance for Celery
|
| 4 |
-
- type: redis
|
| 5 |
-
name: redis-cache
|
| 6 |
-
plan: free
|
| 7 |
-
# This is required for security on Render's free plan
|
| 8 |
-
ipAllowList: [] # Allows internal connections, blocks public
|
| 9 |
-
|
| 10 |
-
# Service 2: The Backend FastAPI Web Server
|
| 11 |
-
- type: web
|
| 12 |
-
name: backend-api
|
| 13 |
-
plan: free
|
| 14 |
-
env: docker
|
| 15 |
-
# Tell Render where to find the Dockerfile and the build context
|
| 16 |
-
dockerfilePath: ./backend/Dockerfile
|
| 17 |
-
dockerContext: .
|
| 18 |
-
# Render's free web services need a health check on port 10000
|
| 19 |
-
healthCheckPath: /
|
| 20 |
-
# We need to explicitly tell Render which port our service is on
|
| 21 |
-
envVars:
|
| 22 |
-
- key: PORT
|
| 23 |
-
value: 10000
|
| 24 |
-
- key: DATABASE_URL
|
| 25 |
-
fromDatabase:
|
| 26 |
-
name: neon-database # We will create this name in the Render UI
|
| 27 |
-
property: connectionString
|
| 28 |
-
- key: CELERY_BROKER_URL
|
| 29 |
-
fromService:
|
| 30 |
-
type: redis
|
| 31 |
-
name: redis-cache
|
| 32 |
-
property: connectionString
|
| 33 |
-
- key: CELERY_RESULT_BACKEND
|
| 34 |
-
fromService:
|
| 35 |
-
type: redis
|
| 36 |
-
name: redis-cache
|
| 37 |
-
property: connectionString
|
| 38 |
-
- key: GOOGLE_API_KEY
|
| 39 |
-
sync: false # Set this secret manually in the Render UI
|
| 40 |
-
|
| 41 |
-
# Service 3: The Celery Background Worker
|
| 42 |
-
- type: worker
|
| 43 |
-
name: celery-worker
|
| 44 |
-
plan: free
|
| 45 |
-
env: docker
|
| 46 |
-
dockerfilePath: ./backend/Dockerfile
|
| 47 |
-
dockerContext: .
|
| 48 |
-
# This command overrides the CMD in the Dockerfile to start the worker instead
|
| 49 |
-
dockerCommand: "python -m celery -A celery_worker.celery worker --loglevel=info"
|
| 50 |
-
envVars:
|
| 51 |
-
- key: DATABASE_URL
|
| 52 |
-
fromDatabase:
|
| 53 |
-
name: neon-database # Must match the name below
|
| 54 |
-
property: connectionString
|
| 55 |
-
- key: CELERY_BROKER_URL
|
| 56 |
-
fromService:
|
| 57 |
-
type: redis
|
| 58 |
-
name: redis-cache
|
| 59 |
-
property: connectionString
|
| 60 |
-
- key: CELERY_RESULT_BACKEND
|
| 61 |
-
fromService:
|
| 62 |
-
type: redis
|
| 63 |
-
name: redis-cache
|
| 64 |
-
property: connectionString
|
| 65 |
-
- key: GOOGLE_API_KEY
|
| 66 |
-
sync: false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startup.sh
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Start the Redis server in the background
|
| 4 |
+
redis-server --daemonize yes
|
| 5 |
+
|
| 6 |
+
# Start the Celery worker in the background
|
| 7 |
+
# We point it to the app folder where the code lives
|
| 8 |
+
celery -A celery_worker.celery worker --loglevel=info &
|
| 9 |
+
|
| 10 |
+
# Start the FastAPI server in the foreground
|
| 11 |
+
# This is the main process that keeps the container alive
|
| 12 |
+
# It must listen on 0.0.0.0 and port 7860 for Hugging Face Spaces
|
| 13 |
+
uvicorn main:app --host 0.0.0.0 --port 7860
|