File size: 1,011 Bytes
528f18a
 
 
 
 
 
 
33cc276
 
 
 
528f18a
 
 
33cc276
528f18a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Use the official Python base image
FROM python:3.9-slim

# Set environment variables for predictable container behavior
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Create and set permissions for a custom cache directory
RUN mkdir -p /cache/huggingface && chmod -R 777 /cache
ENV TRANSFORMERS_CACHE=/cache/huggingface

# Set a working directory in the container
WORKDIR /app

# Install system dependencies for SentencePiece
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    cmake \
    libprotobuf-dev \
    protobuf-compiler \
    libsentencepiece-dev \
    libsentencepiece0 \
    && rm -rf /var/lib/apt/lists/*

# Copy the requirements file
COPY requirements.txt /app/

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the app source code into the container
COPY app.py /app/

# Expose the port the app runs on
EXPOSE 7860

# Run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]