simple-java-app / Dockerfile
GitHub Actions
deploy: deploy application container to Hugging Face
d7f1ba4
Raw History Blame Contribute Delete
1.22 kB
# --- 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"]