Spaces:
Running

ioc-core / Dockerfile
hellium1999's picture
refactor: change application port from 8000 to 7860
32e1505
Raw History Blame
1.24 kB
# Multi-stage build for IOC Core API with Redis
FROM python:3.11-slim-bookworm AS builder
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
# Set working directory
WORKDIR /app
# Copy dependency files
COPY pyproject.toml uv.lock ./
# Install dependencies
RUN uv sync --frozen --no-dev
# Production stage
FROM python:3.11-slim-bookworm
# Install Redis server and Oracle dependencies
RUN apt-get update && apt-get install -y redis-server libaio1 && rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy uv from builder
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
# Copy virtual environment from builder
COPY --from=builder /app/.venv /app/.venv
# Copy application code
COPY src/ ./src/
COPY main.py ./
COPY start.sh ./
# Make startup script executable
RUN chmod +x start.sh
# Set environment variables
ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Expose ports
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/')" || exit 1
# Run the startup script (Redis + FastAPI)
CMD ["./start.sh"]