| # Build stage | |
| FROM node:20-alpine AS builder | |
| # Install build tools | |
| RUN apk update && apk add --no-cache git bash openssl ffmpeg tzdata dos2unix | |
| WORKDIR /evolution | |
| # Copy project files | |
| COPY package*.json ./ | |
| COPY tsconfig.json ./ | |
| COPY tsup.config.ts ./ | |
| RUN npm ci --silent | |
| # Copy source files | |
| COPY src ./src | |
| COPY prisma ./prisma | |
| COPY manager ./manager | |
| COPY .env.example ./.env | |
| COPY runWithProvider.js ./runWithProvider.js | |
| # Generate Prisma client | |
| RUN npx prisma generate | |
| # Build project | |
| RUN npm run build | |
| # Final stage | |
| FROM node:20-alpine AS final | |
| RUN apk update && apk add --no-cache tzdata ffmpeg bash openssl | |
| WORKDIR /evolution | |
| # Copy artifacts from builder | |
| COPY --from=builder /evolution/package.json ./package.json | |
| COPY --from=builder /evolution/package-lock.json ./package-lock.json | |
| COPY --from=builder /evolution/node_modules ./node_modules | |
| COPY --from=builder /evolution/dist ./dist | |
| COPY --from=builder /evolution/prisma ./prisma | |
| COPY --from=builder /evolution/manager ./manager | |
| COPY --from=builder /evolution/.env ./.env | |
| COPY --from=builder /evolution/runWithProvider.js ./runWithProvider.js | |
| COPY --from=builder /evolution/tsup.config.ts ./tsup.config.ts | |
| # Hugging Face Spaces requires binding to $PORT | |
| ENV HOST=0.0.0.0 | |
| ENV PORT=7860 | |
| ENV TZ=Africa/Cairo | |
| ENV DOCKER_ENV=true | |
| EXPOSE 7860 | |
| # Start API with SQLite (no Redis/Postgres) | |
| ENTRYPOINT ["npm", "run", "start:prod"] | |