File size: 795 Bytes
1f423ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM node:18-alpine

WORKDIR /app

# Set up a new user named "user" with user ID 1000
RUN deluser --remove-home node \
    && addgroup -S user -g 1000 \
    && adduser -S -G user -u 1000 user \
    && chown -R user:user /app

# Copy package files
COPY package*.json ./

# Install dependencies with legacy peer deps flag
RUN chown -R user:user /app && \
    npm install --legacy-peer-deps

# Switch to user after npm install
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Copy rest of the application with correct ownership
COPY --chown=user . .

# Build the Next.js application
RUN npm run build

# Expose the port the app runs on (Hugging Face Spaces requires port 7860)
EXPOSE 7860

# Start the application on port 7860
CMD ["npm", "run", "start", "--", "-p", "7860"]