Skip to content

Commit da2b98e

Browse files
committed
dockerfile modified
1 parent ff49cbc commit da2b98e

File tree

2 files changed

+31
-36
lines changed

2 files changed

+31
-36
lines changed
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
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 \
1110
&& rm -rf /var/lib/apt/lists/*
1211

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
1515

1616
# Set the working directory
1717
WORKDIR /app
1818

19-
# Set environment variables for Hugging Face
19+
# Hugging Face cache locations
2020
ENV HF_HOME=/tmp/huggingface
2121
ENV TRANSFORMERS_CACHE=/tmp/huggingface/transformers
2222

23-
24-
# Copy requirement files and install dependencies
23+
# Copy requirements first for layer caching
2524
COPY requirements.txt .
2625

27-
RUN pip install --no-cache-dir -r requirements.txt
26+
# Install Python dependencies
27+
RUN pip install -r requirements.txt
2828

29-
# Copy the rest of your application
29+
# Copy application code
3030
COPY . .
3131

32-
# Set PYTHONPATH to ensure 'app' is recognized
32+
# Ensure imports work
3333
ENV PYTHONPATH=/app
3434

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"]
Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
# Use a lightweight Python image
2-
FROM python:3.11-slim
1+
# Use bookworm-based image (Podman CI safe)
2+
FROM python:3.11-slim-bookworm
33

44
# Set the working directory
55
WORKDIR /app
66

7-
# Install build dependencies
8-
RUN apt-get update && apt-get install -y \
9-
gcc \
10-
python3-dev \
11-
build-essential \
12-
&& apt-get clean \
13-
&& apt-get install -y wget \
7+
# Install system build dependencies (single layer)
8+
RUN apt-get update && \
9+
apt-get install -y \
10+
gcc \
11+
python3-dev \
12+
build-essential \
13+
wget \
1414
&& rm -rf /var/lib/apt/lists/*
1515

1616
# Copy requirement files and install dependencies
1717
COPY requirements.txt .
18-
RUN pip install --no-cache-dir -r requirements.txt
18+
RUN pip install -r requirements.txt
1919

2020
# Copy the rest of your application
2121
COPY . .
2222

23-
# RUN mkdir -p log && chmod 777 log
24-
25-
# Set PYTHONPATH to ensure 'app' is recognized
26-
# ENV PYTHONPATH=/app
27-
28-
# Command to run the app
23+
# Run FastAPI app
2924
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8001"]

0 commit comments

Comments
 (0)