File size: 1,731 Bytes
34367da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# WidgeTDC Backend - Simple Dockerfile for HuggingFace Spaces
FROM node:20-alpine

# Install dependencies for native modules and Prisma
RUN apk add --no-cache python3 make g++ git openssl openssl-dev

WORKDIR /app

# Copy all package files
COPY package*.json ./
COPY packages/domain-types/package*.json ./packages/domain-types/
COPY packages/mcp-types/package*.json ./packages/mcp-types/

# Install dependencies
RUN npm install

# Copy source code
COPY packages/ ./packages/
COPY src/ ./src/
COPY prisma/ ./prisma/
COPY tsconfig.json ./

# Build shared packages
RUN cd packages/domain-types && npm run build
RUN cd packages/mcp-types && npm run build

# Generate Prisma client
RUN npx prisma generate || true

# Build backend with esbuild (bypasses TypeScript strict checking)
RUN npx esbuild src/index.ts --bundle --platform=node --target=node20 \
    --outfile=dist/index.js \
    --external:@prisma/client \
    --external:better-sqlite3 \
    --external:pg-native \
    --external:@xenova/transformers \
    --external:onnxruntime-node \
    --external:sharp \
    --external:canvas \
    --format=cjs \
    --log-level=warning

# Create data directories
RUN mkdir -p /app/data/dropzone /app/data/vidensarkiv /app/data/agents /app/data/harvested

# Set permissions for non-root user
RUN chown -R 1000:1000 /app


USER 1000

# Environment
ENV NODE_ENV=production
ENV PORT=7860
ENV DOCKER=true
ENV HF_SPACE=true

EXPOSE 7860

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
    CMD node -e "require('http').get('http://localhost:7860/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))"

CMD ["node", "dist/index.js"]