File size: 1,575 Bytes
9d86daf
 
 
84df427
 
 
9d86daf
 
 
 
 
 
 
 
 
 
 
 
 
ba25c98
9d86daf
84df427
6e70688
 
 
 
 
 
 
 
 
 
 
84df427
6e70688
 
 
 
 
 
9d86daf
6e70688
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
39
40
41
42
43
# Use an official Node.js LTS version that uses glibc
FROM node:18-bullseye-slim

# Install sysctl (procps package)
RUN apt-get update && apt-get install -y procps && rm -rf /var/lib/apt/lists/*

# 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

# Create an entrypoint script to set sysctl 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 || true" >> /entrypoint.sh && \
    echo "exec \"\$@\"" >> /entrypoint.sh && \
    chmod +x /entrypoint.sh

# Use the entrypoint script
ENTRYPOINT ["/entrypoint.sh"]

# Run the application
CMD ["npm", "start"]