| # Use Python 3.9 as base image | |
| FROM python:3.9-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| curl \ | |
| software-properties-common \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements file | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Create necessary directories with proper permissions | |
| RUN mkdir -p /app/uploads \ | |
| /app/saved_models/bert \ | |
| /app/predictions \ | |
| /app/tokenizer \ | |
| /app/cache \ | |
| && chmod -R 777 /app/uploads \ | |
| /app/saved_models \ | |
| /app/predictions \ | |
| /app/tokenizer \ | |
| /app/cache | |
| # Copy the application code and utilities | |
| COPY . /app/ | |
| COPY ../dataset_utils.py /app/ | |
| COPY ../train_utils.py /app/ | |
| COPY ../config.py /app/ | |
| COPY ../models/roberta_model.py /app/models/ | |
| COPY ../label_encoders.pkl /app/ | |
| # Set environment variables | |
| ENV PYTHONPATH=/app | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV PORT=7860 | |
| ENV TRANSFORMERS_CACHE=/app/cache | |
| # Expose the port the app runs on | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["python", "app.py"] |