Spaces:
Running
Running
File size: 1,444 Bytes
ece880f b2806e8 ece880f b2806e8 ece880f b2806e8 ece880f e51859a b2806e8 ece880f b2806e8 ece880f b2806e8 e51859a ece880f b2806e8 ece880f b2806e8 ece880f b2806e8 ece880f b2806e8 ece880f b2806e8 ece880f b2806e8 ece880f a7f07e8 ece880f b2806e8 |
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 |
# Backend-Only Dockerfile for Hugging Face Spaces
# Includes Redis for BullMQ job processing
FROM node:20-alpine
WORKDIR /app
# Install Redis and bash
RUN apk add --no-cache redis bash curl
# Copy backend package files
COPY backend/package*.json ./
# Install ALL dependencies (including dev dependencies needed for build)
RUN npm ci
# Copy backend source
COPY backend ./
# Build NestJS application
RUN npm run build
# Remove dev dependencies to reduce image size (optional but recommended)
RUN npm prune --omit=dev
# Environment variables for HF Spaces
ENV NODE_ENV=production
ENV PORT=7860
ENV REDIS_HOST=127.0.0.1
ENV REDIS_PORT=6379
# Expose HF Spaces default port
EXPOSE 7860
# Create startup script
RUN cat > /app/start.sh << 'EOF'
#!/bin/bash
set -e
echo "π Starting WagerKit Backend on Hugging Face Spaces..."
# Start Redis in background
echo "π¦ Starting Redis..."
redis-server --daemonize yes --bind 127.0.0.1 --port 6379 --loglevel warning --save ""
sleep 2
# Verify Redis is running
if redis-cli ping > /dev/null 2>&1; then
echo "β
Redis is ready"
else
echo "β Redis failed to start"
exit 1
fi
# Start NestJS backend on port 7860
echo "π§ Starting NestJS backend on port 7860..."
PORT=7860 node dist/main.js
EOF
RUN chmod +x /app/start.sh
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:7860/ || exit 1
CMD ["/app/start.sh"]
|