File size: 1,265 Bytes
1e9c60d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM node:20-alpine AS builder

WORKDIR /app

# Copy package files
COPY server/package.json server/tsconfig.json ./server/
COPY client/package.json client/tsconfig.json client/vite.config.ts client/tailwind.config.js client/postcss.config.js client/index.html ./client/
COPY client/tsconfig.node.json ./client/

# Install dependencies
RUN cd server && npm ci
RUN cd client && npm ci

# Copy source code
COPY server/src ./server/src
COPY client/src ./client/src
COPY client/public ./client/public

# Build server
RUN cd server && npm run build

# Build client
RUN cd client && npm run build

# Production stage
FROM node:20-alpine

WORKDIR /app

# Install only production dependencies for server
COPY server/package.json ./server/
RUN cd server && npm ci --omit=dev

# Copy built artifacts
COPY --from=builder /app/server/dist ./server/dist
COPY --from=builder /app/client/dist ./client/dist

# Configure port for Hugging Face Spaces (expects 7860)
ENV PORT=7860

# Create data directory for SQLite
RUN mkdir -p /app/data

# Expose port
EXPOSE 7860

# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD wget --no-verbose --tries=1 --spider http://localhost:7860/ || exit 1

# Start server
CMD ["node", "server/dist/index.js"]