Nausad commited on
Commit
07b8c48
Β·
verified Β·
1 Parent(s): 0faddb0

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +46 -0
Dockerfile ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ─── Stage 1: Base Image ───────────────────────────────────────────────────
2
+ FROM python:3.10-slim
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # ─── Environment Variables ─────────────────────────────────────────────────
8
+ # Prevent Python from writing .pyc files
9
+ ENV PYTHONDONTWRITEBYTECODE=1
10
+ # Prevent Python from buffering stdout/stderr
11
+ ENV PYTHONUNBUFFERED=1
12
+ # HuggingFace Spaces runs on port 7860
13
+ ENV PORT=7860
14
+
15
+ # ─── Install System Dependencies ───────────────────────────────────────────
16
+ RUN apt-get update && apt-get install -y --no-install-recommends \
17
+ libglib2.0-0 \
18
+ libsm6 \
19
+ libxrender1 \
20
+ libxext6 \
21
+ && apt-get clean \
22
+ && rm -rf /var/lib/apt/lists/*
23
+
24
+ # ─── Install Python Dependencies ───────────────────────────────────────────
25
+ COPY requirements.txt .
26
+ RUN pip install --no-cache-dir -r requirements.txt
27
+
28
+ # ─── Copy Application Files ────────────────────────────────────────────────
29
+ COPY app.py .
30
+ COPY cifar10_model.pth .
31
+ COPY templates/ ./templates/
32
+
33
+ # ─── Create a non-root user (HuggingFace best practice) ────────────────────
34
+ RUN useradd -m -u 1000 appuser
35
+ USER appuser
36
+
37
+ # ─── Expose Port ───────────────────────────────────────────────────────────
38
+ EXPOSE 7860
39
+
40
+ # ─── Launch with Gunicorn (production WSGI server) ─────────────────────────
41
+ CMD ["gunicorn", \
42
+ "--bind", "0.0.0.0:7860", \
43
+ "--workers", "1", \
44
+ "--timeout", "120", \
45
+ "--log-level", "info", \
46
+ "app:app"]