# Use an official Node.js LTS version that uses glibc FROM node:18-bullseye-slim # Set the working directory in the container WORKDIR /app # Copy the package.json and package-lock.json (if available) COPY package*.json ./ # Install dependencies RUN npm install # Copy the rest of the application code COPY . . # Expose the port the app runs on EXPOSE 7860 # Define environment variable ENV PORT=7860 # Create an entrypoint script to set sysctl and ulimit settings RUN echo "#!/bin/sh" > /entrypoint.sh && \ echo "sysctl -w net.ipv4.ip_local_port_range='1024 65535'" >> /entrypoint.sh && \ echo "sysctl -w net.ipv4.tcp_mem='131072 262144 524288'" >> /entrypoint.sh && \ echo "sysctl -w net.ipv4.tcp_rmem='8760 256960 4088000'" >> /entrypoint.sh && \ echo "sysctl -w net.ipv4.tcp_wmem='8760 256960 4088000'" >> /entrypoint.sh && \ echo "sysctl -w net.core.rmem_max=16384" >> /entrypoint.sh && \ echo "sysctl -w net.core.wmem_max=16384" >> /entrypoint.sh && \ echo "sysctl -w net.core.somaxconn=2048" >> /entrypoint.sh && \ echo "sysctl -w net.ipv4.tcp_max_syn_backlog=2048" >> /entrypoint.sh && \ echo "sysctl -w net.core.netdev_max_backlog=2048" >> /entrypoint.sh && \ echo "sysctl -w net.ipv4.tcp_tw_reuse=1" >> /entrypoint.sh && \ echo "ulimit -n 2000500" >> /entrypoint.sh && \ echo "exec \"\$@\"" >> /entrypoint.sh && \ chmod +x /entrypoint.sh # Use the entrypoint script ENTRYPOINT ["/entrypoint.sh"] # Run the application CMD ["npm", "start"]