File size: 1,242 Bytes
5c85958
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8700c6
 
5c85958
 
 
 
 
 
 
 
 
 
 
 
e8700c6
 
 
5c85958
e8700c6
 
5c85958
 
e8700c6
5c85958
 
e8700c6
 
 
 
5c85958
 
 
 
 
 
 
e8700c6
 
 
 
5c85958
e8700c6
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
# Build stage
FROM node:20-slim AS builder

WORKDIR /app

# Copy package files
COPY package.json yarn.lock ./

# Install dependencies
RUN yarn install --frozen-lockfile

# Copy source code
COPY . .

# Build the app
RUN yarn build

# Production stage - Node.js server with caching
FROM node:20-slim

# Install required packages for HF Spaces Dev Mode
RUN apt-get update && \
    apt-get install -y \
      bash \
      git git-lfs \
      wget curl procps \
      htop vim nano && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy package files and install production dependencies only
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --production

# Copy server code
COPY server ./server

# Copy built files from builder stage
COPY --from=builder /app/dist ./dist

# Copy source for Dev Mode (so you can edit and rebuild)
COPY --from=builder /app/src ./src
COPY --from=builder /app/public ./public
COPY --from=builder /app/vite.config.js ./
COPY --from=builder /app/index.html ./

# Make /app owned by user 1000 for Dev Mode
RUN chown -R 1000:1000 /app

# Expose port
EXPOSE 7860

# Set environment
ENV NODE_ENV=production
ENV PORT=7860

# Use CMD (required by Dev Mode, not ENTRYPOINT)
CMD ["node", "server/index.js"]