File size: 1,057 Bytes
fb2f715
7bb1512
 
 
2892299
7bb1512
2892299
 
 
 
 
 
 
 
 
 
 
7bb1512
 
0a25a37
 
7bb1512
0a25a37
 
 
 
 
fb2f715
7bb1512
0a25a37
 
 
 
 
 
 
 
 
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
FROM node:18-alpine

WORKDIR /app

# Copy all files directly
COPY . .

# Configure npm to use alternative registry or retry options
RUN npm config set registry https://registry.npmjs.org/
RUN npm config set fetch-retry-maxtimeout 60000
RUN npm config set fetch-retry-mintimeout 10000
RUN npm config set fetch-retries 5

# Install dependencies with fallback options
RUN npm install || npm install --legacy-peer-deps || npm install --no-fund --no-audit

# Build the application
RUN npm run build

# Install a simple HTTP server to serve static content and curl for healthcheck
RUN npm install -g serve && apk add --no-cache curl

# Make port configurable via environment variable with 7860 as default (common for HF Spaces)
ENV PORT=7860

# Expose both common ports
EXPOSE 7860
EXPOSE 3000

# Add health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
  CMD curl -f http://localhost:${PORT}/ || exit 1

# Make startup script executable
RUN chmod +x start.sh

# Run the app using our startup script
CMD ["/bin/sh", "./start.sh"]