Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Vu Minh Chien
				
			
		Fix file permissions issue in Docker container - add fallback to in-memory storage
		d0e91b6
		
		| # Use the official Node.js runtime as base image | |
| FROM node:18-alpine | |
| # Set the working directory | |
| WORKDIR /app | |
| # Copy package.json and package-lock.json | |
| COPY package*.json ./ | |
| # Install dependencies | |
| RUN npm ci --only=production | |
| # Copy the rest of the application code | |
| COPY . . | |
| # Create a non-root user | |
| RUN addgroup -g 1001 -S nodejs | |
| RUN adduser -S nodejs -u 1001 | |
| # Ensure devices.json exists and has proper permissions | |
| RUN touch /app/devices.json && \ | |
| chmod 664 /app/devices.json | |
| # Change ownership of the app directory to the nodejs user | |
| RUN chown -R nodejs:nodejs /app | |
| # Switch to the non-root user | |
| USER nodejs | |
| # Expose the port that the app runs on | |
| # Hugging Face Spaces expects the app to run on port 7860 | |
| EXPOSE 7860 | |
| # Set environment variables | |
| ENV NODE_ENV=production | |
| ENV PORT=7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ | |
| CMD node -e "require('http').get('http://localhost:7860', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })" | |
| # Start the application | |
| CMD ["node", "server.js"] |