Spaces:
Runtime error
Runtime error
File size: 1,388 Bytes
6a6be6d f2109f5 6a6be6d f2109f5 6a6be6d f2109f5 6a6be6d 3ef35a6 72a4f5d f2109f5 6a6be6d 3ef35a6 72a4f5d 3ef35a6 6a6be6d |
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# Multi-stage build for da-autodelete microservice
# Build stage
FROM openjdk:21-jdk-slim AS build
# Set working directory
WORKDIR /app
# Copy gradle files first for better caching
COPY gradlew .
COPY gradle gradle
COPY build.gradle.kts .
COPY settings.gradle.kts .
COPY gradle.properties .
# Fix file permissions for Linux container (Windows files lose permissions)
RUN chmod +x gradlew && \
chmod +x gradle/wrapper/gradle-wrapper.jar && \
chmod +x gradle/wrapper/gradle-wrapper.properties
# Download dependencies
RUN ./gradlew dependencies --no-daemon
# Copy source code
COPY src src
# Build the application
RUN ./gradlew build -x test --no-daemon
# Runtime stage
FROM openjdk:21-slim
# Install curl for health checks
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy the built JAR from build stage
COPY --from=build /app/build/libs/*.jar app.jar
# HF Spaces requires running as user with UID 1000
RUN useradd -m -u 1000 -s /bin/bash appuser && \
chown -R appuser:appuser /app
USER appuser
# Expose the service port (HF Spaces will map this to the configured app_port)
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8080/actuator/health || exit 1
# Run the application
CMD ["java", "-jar", "app.jar"]
|