File size: 1,560 Bytes
f75bff1 8ecab61 f75bff1 7b2b891 13c85a8 7b2b891 8ecab61 f75bff1 8ecab61 f75bff1 8ecab61 f75bff1 5422df1 8ecab61 f75bff1 8ecab61 | 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 | # Stage 1: Build React frontend
FROM node:22-alpine AS frontend-builder
WORKDIR /frontend
# Copy frontend package files
COPY frontend/package*.json ./
# Install dependencies
RUN npm ci
# Copy frontend source
COPY frontend/ ./
# Build React app
RUN npm run build
# Stage 2: Final image with nginx and Python
FROM nginx:alpine
# Cache buster to force rebuild on HuggingFace (increment when needed)
ARG CACHEBUST=2
# Install Python, pip, supervisor, and curl for healthcheck
RUN apk add --no-cache \
python3 \
py3-pip \
supervisor \
curl \
gcc \
python3-dev \
musl-dev \
linux-headers
# Install Python dependencies system-wide
RUN pip3 install --no-cache-dir --break-system-packages \
Django==5.2.7 \
djangorestframework==3.16.0 \
django-filter==24.3 \
pydantic==2.10.6 \
gunicorn==23.0.0 \
loguru==0.7.3
# Copy React build from frontend stage
COPY --from=frontend-builder /frontend/dist /usr/share/nginx/html
# Copy application code
COPY . /app
# Copy configuration files
COPY nginx.conf /etc/nginx/nginx.conf
COPY supervisord.conf /etc/supervisor/supervisord.conf
# Make startup script executable
RUN chmod +x /app/start-django.sh
# Create /app marker for container detection
RUN mkdir -p /app && touch /app/.container
WORKDIR /app
EXPOSE 7860
# Healthcheck to verify services are running
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:7860/api/ || exit 1
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
|