File size: 1,428 Bytes
da48210 866dfb3 3919b37 866dfb3 3919b37 da48210 866dfb3 3919b37 866dfb3 3919b37 da48210 3919b37 999d28d 3919b37 da48210 3919b37 | 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 | # Kiro Gateway - Docker Image for Hugging Face Spaces
# Multi-stage build with dashboard
# Stage 1: Build dashboard
FROM node:20-alpine AS dashboard-builder
WORKDIR /dashboard
# Copy dashboard files
COPY dashboard/package*.json ./
RUN npm ci
COPY dashboard/ ./
RUN npm run build
# Stage 2: Main application
FROM python:3.10-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
SERVER_PORT=7860 \
SERVER_HOST=0.0.0.0
# Create non-root user for security
RUN groupadd -r kiro && useradd -r -g kiro kiro
# Set working directory
WORKDIR /app
# Install dependencies first (better layer caching)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY --chown=kiro:kiro . .
# Copy built dashboard from builder stage
COPY --from=dashboard-builder --chown=kiro:kiro /dashboard/out ./dashboard/out
# Create directory for debug logs with proper permissions
RUN mkdir -p debug_logs && chown -R kiro:kiro debug_logs
# Switch to non-root user
USER kiro
# Expose HF Spaces port
EXPOSE 7860
# Health check
# Using httpx (our main HTTP library) instead of requests
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import httpx; httpx.get('http://localhost:7860/health', timeout=5)"
# Run the application
CMD ["python", "main.py"]
|