Spaces:
Sleeping
Sleeping
| FROM node:20-slim | |
| # Install curl for health checks | |
| RUN apt-get update && apt-get install -y \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* \ | |
| && apt-get clean | |
| WORKDIR /app | |
| # Copy package files | |
| COPY package*.json ./ | |
| # Install Node dependencies (using install instead of ci for flexibility) | |
| RUN npm install --omit=dev && npm cache clean --force | |
| # Copy source | |
| COPY cpu.js . | |
| # No need to create the user/group, they exist in the base image. | |
| # Just set the permissions and switch. | |
| RUN chown -R node:node /app | |
| USER node | |
| EXPOSE 7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \ | |
| CMD node -e "require('http').get('http://localhost:7860/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) }).on('error', () => process.exit(1))" | |
| CMD ["node", "cpu.js"] |