File size: 1,538 Bytes
c13f797 | 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 70 71 | # ============================================================
# صانع (San'e) — Dockerfile
# ============================================================
# Multi-stage build for optimized production image
# Stage 1: Build
FROM node:22-alpine AS builder
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm
# Copy package files
COPY package.json pnpm-lock.yaml* package-lock.json* ./
# Install dependencies
RUN pnpm install --frozen-lockfile || npm install
# Copy source
COPY tsconfig.json ./
COPY src/ ./src/
COPY skills/ ./skills/
# Build TypeScript
RUN pnpm build || npm run build
# Stage 2: Production
FROM node:22-alpine AS production
WORKDIR /app
# Install curl for healthcheck
RUN apk add --no-cache curl tzdata
# Set timezone
ENV TZ=Asia/Kuwait
# Install pnpm
RUN npm install -g pnpm
# Copy package files
COPY package.json pnpm-lock.yaml* package-lock.json* ./
# Install production dependencies only
RUN pnpm install --prod --frozen-lockfile || npm install --production
# Copy built files
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/skills ./skills
# Create data directory for WhatsApp auth
RUN mkdir -p .sane/whatsapp-auth
# Create non-root user for security
RUN addgroup -g 1001 -S sane && \
adduser -S sane -u 1001 && \
chown -R sane:sane /app
USER sane
# Expose gateway port
EXPOSE 18789
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost:18789/health || exit 1
# Start San'e
CMD ["node", "dist/index.js"]
|