kir / Dockerfile
Shinway Deploy
feat: Add enhanced dashboard with HF Spaces support
866dfb3
Raw
History Blame Contribute Delete
1.43 kB
# 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"]