File size: 1,219 Bytes
d7f1ba4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# --- Stage 1: Build the Application ---
FROM eclipse-temurin:21-jdk-alpine AS build
RUN apk add --no-cache git
WORKDIR /app

# Copy the gradle configuration files first to cache dependencies
COPY gradlew .
COPY gradle gradle
COPY build.gradle .
COPY settings.gradle .

# Dynamically clone the public omni-context submodule repo in the build container
RUN git clone https://github.com/amritnray/omni-context.git omni-context && \
    cd omni-context && \
    git checkout develop

# Ensure gradle execution permissions and download dependencies
RUN chmod +x gradlew

# Note: If 'com.example:spring-boot-mcp-starter:1.0.0' is only available in your local Maven repository,
# the cloud build will fail to resolve it. If this happens, see Option B in the instructions.
RUN ./gradlew dependencies --no-daemon || true

# Copy source code and build
COPY src src
RUN ./gradlew build --no-daemon -x test

# --- Stage 2: Create the Lightweight Runner ---
FROM eclipse-temurin:21-jre-alpine
EXPOSE 8080
COPY --from=build /app/build/libs/*-SNAPSHOT.jar app.jar

# JVM Tuning: Crucial for free tiers to prevent memory limits from killing the app
ENTRYPOINT ["java", "-XX:MaxRAMPercentage=75.0", "-XX:+UseG1GC", "-jar", "/app.jar"]