GeoQuery / Dockerfile
GerardCB's picture
Fix: Propagate Dockerfile update to remove download script
372e870
# ==========================================
# Stage 1: Build Frontend (Next.js)
# ==========================================
FROM node:20-alpine AS frontend
WORKDIR /app
# Install dependencies
COPY frontend/package*.json ./
RUN npm ci
# Copy source code
COPY frontend/ ./
# Configure for static export
ENV NEXT_PUBLIC_API_URL=/api/v1
# Run build (creates /app/out)
RUN npm run build
# ==========================================
# Stage 2: Runtime (Python + FastAPI)
# ==========================================
FROM python:3.11-slim
# Create a non-root user (Recommended for HF Spaces)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /app
# Install system dependencies (as root before switching user)
USER root
RUN apt-get update && apt-get install -y \
build-essential \
libgeos-dev \
&& rm -rf /var/lib/apt/lists/*
USER user
# Install Python dependencies
COPY --chown=user backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy Backend Code
COPY --chown=user backend/ backend/
# Copy Built Frontend to Backend Static Directory
# ensure strict permissions
COPY --from=frontend --chown=user /app/out /app/backend/static
# Expose port 7860 (Standard for HF Spaces)
EXPOSE 7860
# Run Application
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]