da-autodelete-dev / Dockerfile
TejasDalab's picture
Fix Dockerfile: Update Docker images and file permissions for HF Spaces deployment - No code logic changes
f2109f5
# 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"]