CoolFace
Apppublic

Anmolkhurana88/Sign-Language-Translator

sourceHugging Faceunknownupdated 1mo agoView on Hugging Face
0likes
Dockerfile55 linesDownload Raw Back to root
1# Build stage
2
3# get base image
4FROM python:3.11-slim as builder
5
6# Set environment variables to optimize Python behavior in Docker
7ENV PIP_NO_CACHE_DIR=1
8ENV PIP_DISABLE_PIP_VERSION_CHECK=1
9
10# Set working directory
11WORKDIR /app
12
13# Copy only requirements to cache dependencies
14COPY requirements.txt .
15
16# Install system dependencies
17RUN apt-get update && apt-get install -y \
18    build-essential \
19    && rm -rf /var/lib/apt/lists/*
20
21# Install Python dependencies
22RUN pip install --no-cache-dir -r requirements.txt
23
24# Production stage
25FROM python:3.11-slim
26
27# Set environment variables to optimize Python behavior in Docker
28ENV PYTHONUNBUFFERED=1
29ENV PYTHONDONTWRITEBYTECODE=1
30
31# Set working directory
32WORKDIR /app
33
34# Install runtime dependencies
35RUN apt-get update && apt-get install -y \
36    libglib2.0-0 \
37    ffmpeg \
38    libsm6 \
39    libxext6 \
40    libxrender-dev \
41    libgomp1 \
42    libgl1 \
43    && rm -rf /var/lib/apt/lists/*
44
45# Copy installed Python packages from the builder stage
46COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
47
48# Copy the rest of the application code
49COPY . .
50
51# Expose the port the app runs on, (7860 for huggingface spaces)
52EXPOSE 7860
53
54# Start the application
55CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]