Gankit12 commited on
Commit
816212a
·
verified ·
1 Parent(s): 7b70a15

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +42 -70
Dockerfile CHANGED
@@ -1,70 +1,42 @@
1
- # ScamShield AI - Docker Image
2
- # Multi-stage build for optimized production image
3
-
4
- # =====================================================
5
- # Stage 1: Builder
6
- # =====================================================
7
- FROM python:3.11-slim AS builder
8
-
9
- WORKDIR /app
10
-
11
- # Install build dependencies
12
- RUN apt-get update && apt-get install -y \
13
- build-essential \
14
- curl \
15
- && rm -rf /var/lib/apt/lists/*
16
-
17
- # Copy requirements first for caching
18
- COPY requirements.txt .
19
-
20
- # Install Python dependencies
21
- RUN pip install --no-cache-dir --user -r requirements.txt
22
-
23
- # Download spaCy model
24
- RUN python -m spacy download en_core_web_sm
25
-
26
- # =====================================================
27
- # Stage 2: Production
28
- # =====================================================
29
- FROM python:3.11-slim AS production
30
-
31
- WORKDIR /app
32
-
33
- # Install runtime dependencies
34
- RUN apt-get update && apt-get install -y \
35
- libpq5 \
36
- && rm -rf /var/lib/apt/lists/*
37
-
38
- # Copy Python packages from builder
39
- COPY --from=builder /root/.local /root/.local
40
-
41
- # Ensure scripts are in PATH
42
- ENV PATH=/root/.local/bin:$PATH
43
-
44
- # Copy spaCy model data
45
- COPY --from=builder /root/.local/lib/python3.11/site-packages/en_core_web_sm /root/.local/lib/python3.11/site-packages/en_core_web_sm
46
-
47
- # Copy application code
48
- COPY app/ ./app/
49
- COPY scripts/ ./scripts/
50
-
51
- # Create non-root user for security
52
- RUN useradd --create-home --shell /bin/bash appuser
53
- RUN chown -R appuser:appuser /app
54
- USER appuser
55
-
56
- # Set environment variables
57
- ENV PYTHONPATH=/app
58
- ENV PYTHONDONTWRITEBYTECODE=1
59
- ENV PYTHONUNBUFFERED=1
60
- ENV ENVIRONMENT=production
61
-
62
- # Expose API port
63
- EXPOSE 8000
64
-
65
- # Health check
66
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
67
- CMD curl -f http://localhost:8000/api/v1/health || exit 1
68
-
69
- # Run the application
70
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
+ # ScamShield AI - Hugging Face Spaces Docker Image
2
+ # Optimized for Hugging Face deployment
3
+
4
+ FROM python:3.11-slim
5
+
6
+ WORKDIR /app
7
+
8
+ # Install system dependencies
9
+ RUN apt-get update && apt-get install -y \
10
+ build-essential \
11
+ curl \
12
+ libpq5 \
13
+ && rm -rf /var/lib/apt/lists/*
14
+
15
+ # Copy requirements first for caching
16
+ COPY requirements.txt .
17
+
18
+ # Install Python dependencies
19
+ RUN pip install --no-cache-dir -r requirements.txt
20
+
21
+ # Download spaCy model
22
+ RUN python -m spacy download en_core_web_sm
23
+
24
+ # Copy application code
25
+ COPY app/ ./app/
26
+ COPY scripts/ ./scripts/
27
+
28
+ # Set environment variables
29
+ ENV PYTHONPATH=/app
30
+ ENV PYTHONDONTWRITEBYTECODE=1
31
+ ENV PYTHONUNBUFFERED=1
32
+ ENV ENVIRONMENT=production
33
+
34
+ # Hugging Face Spaces requires port 7860
35
+ EXPOSE 7860
36
+
37
+ # Health check (using port 7860)
38
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
39
+ CMD curl -f http://localhost:7860/api/v1/health || exit 1
40
+
41
+ # Run the application on port 7860 (required by Hugging Face Spaces)
42
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]