ChatbotBridge / Dockerfile
Eng-Musa's picture
chatbot logic setup
b16713a
# ====== Stage 1: Build the application ======
FROM maven:3.9.9-eclipse-temurin-21 AS build
# Set working directory
WORKDIR /app
# Copy pom.xml and download dependencies first (to leverage Docker cache)
COPY pom.xml .
RUN mvn dependency:go-offline
# Copy source code
COPY src ./src
# Package the application
RUN mvn clean package -DskipTests
# ====== Stage 2: Run the application ======
FROM eclipse-temurin:21-jdk-jammy
# Create user with ID 1000 as required by Hugging Face
RUN useradd -m -u 1000 user
# Switch to the user
USER user
# Set home directory and update PATH for the user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Set working directory to user's home
WORKDIR $HOME/app
# Copy jar from build stage with proper ownership
COPY --from=build --chown=user /app/target/chatbot-bridge-service-0.0.1-SNAPSHOT.jar app.jar
# Expose port 7860 (Hugging Face default)
EXPOSE 7860
# Run the application on port 7860
ENTRYPOINT ["java", "-jar", "app.jar", "--server.port=7860"]