|
1 | | -# Use a lightweight Python image |
2 | | -FROM python:3.11-slim |
3 | | - |
4 | | - |
5 | | -# Install build dependencies |
6 | | -RUN apt-get update && apt-get install -y curl \ |
7 | | - gcc \ |
8 | | - python3-dev \ |
9 | | - build-essential \ |
10 | | - && apt-get clean \ |
| 1 | +# ✅ Podman + OpenShift safe base image |
| 2 | +FROM python:3.11-slim-bookworm |
| 3 | + |
| 4 | +# Install build dependencies (single layer) |
| 5 | +RUN apt-get update && apt-get install -y \ |
| 6 | + curl \ |
| 7 | + gcc \ |
| 8 | + python3-dev \ |
| 9 | + build-essential \ |
11 | 10 | && rm -rf /var/lib/apt/lists/* |
12 | 11 |
|
13 | | -# Create a non-root user (OpenShift runs containers as random UID by default) |
14 | | -RUN mkdir -p /app /tmp/huggingface /mnt/hf_cache && chmod -R 777 /app /tmp/huggingface /mnt/hf_cache |
| 12 | +# OpenShift-compatible writable directories |
| 13 | +RUN mkdir -p /app /tmp/huggingface /mnt/hf_cache \ |
| 14 | + && chmod -R 777 /app /tmp/huggingface /mnt/hf_cache |
15 | 15 |
|
16 | 16 | # Set the working directory |
17 | 17 | WORKDIR /app |
18 | 18 |
|
19 | | -# Set environment variables for Hugging Face |
| 19 | +# Hugging Face cache locations |
20 | 20 | ENV HF_HOME=/tmp/huggingface |
21 | 21 | ENV TRANSFORMERS_CACHE=/tmp/huggingface/transformers |
22 | 22 |
|
23 | | - |
24 | | -# Copy requirement files and install dependencies |
| 23 | +# Copy requirements first for layer caching |
25 | 24 | COPY requirements.txt . |
26 | 25 |
|
27 | | -RUN pip install --no-cache-dir -r requirements.txt |
| 26 | +# Install Python dependencies |
| 27 | +RUN pip install -r requirements.txt |
28 | 28 |
|
29 | | -# Copy the rest of your application |
| 29 | +# Copy application code |
30 | 30 | COPY . . |
31 | 31 |
|
32 | | -# Set PYTHONPATH to ensure 'app' is recognized |
| 32 | +# Ensure imports work |
33 | 33 | ENV PYTHONPATH=/app |
34 | 34 |
|
35 | | -# Command to run the app |
36 | | -CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8002" , "--log-level", "debug", "--access-log" ] |
| 35 | +# Run FastAPI |
| 36 | +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8002", "--log-level", "debug", "--access-log"] |
0 commit comments