Spaces:
Sleeping
Sleeping
File size: 1,455 Bytes
1061354 07338e1 1061354 07338e1 1061354 07338e1 1061354 07338e1 1061354 07338e1 1061354 07338e1 1061354 07338e1 1061354 |
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# backend/Dockerfile.pip
# === BUILD STAGE ===
FROM python:3.10-slim AS build
ENV PIP_NO_CACHE_DIR=1 \
PYTHONUNBUFFERED=1 \
PATH="/home/user/.local/bin:$PATH"
# Install system dependencies for building
RUN apt-get update && apt-get install -y \
build-essential \
libjpeg-dev \
zlib1g-dev \
libpng-dev \
libffi-dev \
&& rm -rf /var/lib/apt/lists/*
# Create user
RUN useradd -m -u 1000 user
USER user
WORKDIR /app
# Copy requirements file
COPY --chown=user requirements.txt ./
# Install dependencies using PIP
RUN pip install --no-cache-dir --user -r requirements.txt
# === FINAL STAGE ===
FROM python:3.10-slim
# Install runtime dependencies only
RUN apt-get update && apt-get install -y \
libjpeg-dev \
zlib1g-dev \
libpng-dev \
libffi-dev \
curl \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Create user
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
WORKDIR /app
# Copy installed packages from builder
COPY --from=build /home/user/.local /home/user/.local
# Copy application code
COPY --chown=user . .
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/healthcheck || exit 1
# Production command
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "7860"]
|