HF-Shapes / Dockerfile
AntDX316
updated
0a25a37
raw
history blame
1.06 kB
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"]