NitinBot002 commited on
Commit
e50c0d4
·
verified ·
1 Parent(s): e92f817

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -25
Dockerfile CHANGED
@@ -1,6 +1,4 @@
1
- # Multi-stage Dockerfile for Coral Server deployment on Render
2
-
3
- # Stage 1: Build stage
4
  FROM gradle:8.5-jdk17 AS build
5
 
6
  # Set working directory
@@ -9,18 +7,16 @@ WORKDIR /app
9
  # Clone the Coral Server repository
10
  RUN git clone https://github.com/Coral-Protocol/coral-server.git .
11
 
12
- # Copy any custom configuration if needed
13
- # COPY application.yaml src/main/resources/
14
-
15
  # Build the application
16
  RUN gradle build --no-daemon -x test
17
 
18
- # Stage 2: Runtime stage
19
- FROM openjdk:17-jdk-slim AS runtime
20
 
21
  # Install required packages
22
  RUN apt-get update && apt-get install -y \
23
  curl \
 
24
  && rm -rf /var/lib/apt/lists/*
25
 
26
  # Set working directory
@@ -28,27 +24,24 @@ WORKDIR /app
28
 
29
  # Copy built application from build stage
30
  COPY --from=build /app/build/libs/*.jar app.jar
 
31
 
32
- # Create config directory and copy resources
33
- RUN mkdir -p /config
34
- COPY --from=build /app/src/main/resources/* /config/
35
 
36
- # Set environment variables
37
- ENV JAVA_OPTS="-Xmx512m -Xms256m"
38
- ENV SERVER_PORT=${PORT:-5555}
 
 
39
 
40
- # Expose the port (Render will provide PORT environment variable)
41
- EXPOSE ${PORT:-5555}
42
 
43
  # Health check
44
  HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
45
- CMD curl -f http://localhost:${PORT:-5555}/health || exit 1
46
-
47
- # Create a non-root user for security
48
- RUN useradd -r -s /bin/false coral && \
49
- chown -R coral:coral /app /config
50
-
51
- USER coral
52
 
53
- # Start the application with SSE server mode
54
- CMD java $JAVA_OPTS -jar app.jar --sse-server-ktor ${PORT:-5555}
 
1
+ # Dockerfile for Hugging Face Spaces deployment of Coral Server
 
 
2
  FROM gradle:8.5-jdk17 AS build
3
 
4
  # Set working directory
 
7
  # Clone the Coral Server repository
8
  RUN git clone https://github.com/Coral-Protocol/coral-server.git .
9
 
 
 
 
10
  # Build the application
11
  RUN gradle build --no-daemon -x test
12
 
13
+ # Runtime stage
14
+ FROM openjdk:17-jdk-slim
15
 
16
  # Install required packages
17
  RUN apt-get update && apt-get install -y \
18
  curl \
19
+ git \
20
  && rm -rf /var/lib/apt/lists/*
21
 
22
  # Set working directory
 
24
 
25
  # Copy built application from build stage
26
  COPY --from=build /app/build/libs/*.jar app.jar
27
+ COPY --from=build /app/src/main/resources /app/resources
28
 
29
+ # Create non-root user (required by HF Spaces)
30
+ RUN useradd -m -u 1000 user
31
+ USER user
32
 
33
+ # Set environment variables for HF Spaces
34
+ ENV HOME=/home/user \
35
+ PATH=/home/user/.local/bin:$PATH \
36
+ GRADIO_SERVER_NAME=0.0.0.0 \
37
+ GRADIO_SERVER_PORT=7860
38
 
39
+ # HF Spaces expects port 7860
40
+ EXPOSE 7860
41
 
42
  # Health check
43
  HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
44
+ CMD curl -f http://localhost:7860/health || exit 1
 
 
 
 
 
 
45
 
46
+ # Start the server on port 7860 (HF Spaces default)
47
+ CMD ["java", "-Xmx1g", "-Xms512m", "-jar", "app.jar", "--sse-server-ktor", "7860"]