ABAO77 commited on
Commit
8257fba
·
verified ·
1 Parent(s): 3c537af

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -14
Dockerfile CHANGED
@@ -21,26 +21,38 @@ RUN apt-get update && \
21
  ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
22
  ENV PATH="$JAVA_HOME/bin:$PATH"
23
 
24
- # Configure JVM to work better in containers with minimal memory
25
- # These settings help prevent metaspace and code cache allocation issues
26
- # Note: We intentionally don't use JAVA_TOOL_OPTIONS to avoid conflicts
27
- # ENV JAVA_TOOL_OPTIONS="-XX:+UseContainerSupport"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  # Verify installations
30
  RUN python3 --version && \
31
  gcc --version && \
32
  g++ --version && \
33
  java -version && \
34
- javac -version && \
35
- # Test Java with minimal memory settings
36
- java -XX:+PrintFlagsFinal -version 2>&1 | grep -E "(UseContainerSupport|MaxRAMPercentage)"
37
-
38
- # Create app directory first
39
- WORKDIR /app
40
-
41
- # Create non-root user
42
- RUN useradd -m -u 1000 user && \
43
- chown -R user:user /app
44
 
45
  # Switch to non-root user
46
  USER user
@@ -67,4 +79,5 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
67
  CMD curl -f http://localhost:7860/health || exit 1
68
 
69
  # Start command with explicit memory settings for uvicorn
 
70
  CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
21
  ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
22
  ENV PATH="$JAVA_HOME/bin:$PATH"
23
 
24
+ # Create app directory first
25
+ WORKDIR /app
26
+
27
+ # Create non-root user with proper ulimits
28
+ RUN useradd -m -u 1000 user && \
29
+ chown -R user:user /app && \
30
+ # Set ulimits for the user to prevent Java memory allocation issues
31
+ echo "user soft nofile 65536" >> /etc/security/limits.conf && \
32
+ echo "user hard nofile 65536" >> /etc/security/limits.conf && \
33
+ echo "user soft nproc 32768" >> /etc/security/limits.conf && \
34
+ echo "user hard nproc 32768" >> /etc/security/limits.conf && \
35
+ echo "user soft memlock unlimited" >> /etc/security/limits.conf && \
36
+ echo "user hard memlock unlimited" >> /etc/security/limits.conf && \
37
+ echo "user soft stack 8192" >> /etc/security/limits.conf && \
38
+ echo "user hard stack 8192" >> /etc/security/limits.conf
39
+
40
+ # Create a startup script to set ulimits
41
+ RUN echo '#!/bin/bash\n\
42
+ ulimit -n 65536\n\
43
+ ulimit -u 32768\n\
44
+ ulimit -m unlimited\n\
45
+ ulimit -s 8192\n\
46
+ ulimit -v unlimited\n\
47
+ exec "$@"' > /entrypoint.sh && \
48
+ chmod +x /entrypoint.sh
49
 
50
  # Verify installations
51
  RUN python3 --version && \
52
  gcc --version && \
53
  g++ --version && \
54
  java -version && \
55
+ javac -version
 
 
 
 
 
 
 
 
 
56
 
57
  # Switch to non-root user
58
  USER user
 
79
  CMD curl -f http://localhost:7860/health || exit 1
80
 
81
  # Start command with explicit memory settings for uvicorn
82
+ ENTRYPOINT ["/entrypoint.sh"]
83
  CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]