File size: 703 Bytes
1e480b5
 
8772ac2
1e480b5
8772ac2
 
1e480b5
 
8772ac2
1e480b5
 
 
 
8772ac2
 
1e480b5
 
 
 
 
 
8772ac2
1e480b5
 
 
8772ac2
1e480b5
 
8772ac2
1e480b5
 
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
# Use official Node.js 20 slim image as the base
FROM node:20-slim

# Create app directory
WORKDIR /app

# Copy package files first to leverage Docker layer caching
COPY package*.json ./

# Install only production dependencies
RUN npm ci --omit=dev

# Copy the rest of the application code
COPY src/ ./src/

# Change ownership of the app directory to the pre-configured 'node' user (UID 1000)
# Hugging Face Spaces requires running as UID 1000
RUN chown -R node:node /app

# Switch to non-root user 'node'
USER node

# Set default environment variables
ENV PORT=7860
ENV NODE_ENV=production

# Expose the standard Hugging Face Spaces port
EXPOSE 7860

# Run the node server
CMD ["node", "src/server.js"]