Domify-Academy-Bot / Dockerfile
Domify's picture
Update Dockerfile
f091876 verified
# Domify Academy Super Bot - Hugging Face Spaces Dockerfile
# Multi-stage build for optimized production image
# Stage 1: Build stage
FROM node:20-slim AS builder
WORKDIR /app
# Copy package files
COPY package*.json pnpm-lock.yaml* ./
# Install dependencies
RUN npm install -g pnpm && pnpm install --no-frozen-lockfile
# Copy source code
COPY . .
# Build the application
RUN pnpm run build
# Stage 2: Production stage
FROM node:20-slim
WORKDIR /app
# Install production dependencies only
RUN npm install -g pnpm
COPY package*.json pnpm-lock.yaml* ./
RUN pnpm install --prod --no-frozen-lockfile
# Copy built application from builder
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/client/dist ./client/dist
COPY --from=builder /app/drizzle ./drizzle
# Create non-root user for security
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
USER appuser
# Expose port 7860 (Hugging Face Spaces default)
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:7860/api/health', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"
# Set environment variables
ENV NODE_ENV=production
ENV PORT=7860
# Start the application
CMD ["node", "dist/index.js"]