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

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +54 -0
Dockerfile ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
7
+ WORKDIR /app
8
+
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
27
+ 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}