File size: 2,703 Bytes
77e57ab
591e325
cbf25e9
77e57ab
 
 
 
 
 
 
cbf25e9
77e57ab
 
 
 
 
 
 
 
 
 
 
cbf25e9
77e57ab
 
 
 
cbf25e9
 
77e57ab
 
 
cbf25e9
77e57ab
cbf25e9
 
77e57ab
4b64773
cbf25e9
77e57ab
 
 
cbf25e9
 
77e57ab
 
 
 
4b64773
77e57ab
 
4b64773
77e57ab
43b73de
 
 
 
 
cbf25e9
591e325
77e57ab
 
591e325
 
77e57ab
 
ebaf261
cbf25e9
591e325
77e57ab
cbf25e9
c7c4a3e
 
 
cbf25e9
591e325
 
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Start from a stable Python base image
FROM python:3.13-slim-bookworm

# Use ARG for versions to easily update them
ARG NEO4J_VERSION=5.15.0

# Set Environment Variables
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 \
    NEO4J_HOME=/neo4j \
    PATH="$PATH:/neo4j/bin"

# Install system dependencies as root
# Using --no-install-recommends to keep the image smaller
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    git \
    curl \
    openjdk-17-jre-headless \
    nginx \
    netcat-traditional \
    unzip \
    && rm -rf /var/lib/apt/lists/*

# Download and install Neo4j Community Edition as root
RUN curl -fsSL "https://dist.neo4j.org/neo4j-community-${NEO4J_VERSION}-unix.tar.gz" -o neo4j.tar.gz && \
    tar -xzf neo4j.tar.gz -C / && \
    mv "/neo4j-community-${NEO4J_VERSION}" "${NEO4J_HOME}" && \
    rm neo4j.tar.gz

# Create plugins directory and download the APOC plugin
RUN mkdir -p ${NEO4J_HOME}/plugins
RUN curl -fsSL "https://github.com/neo4j/apoc/releases/download/${NEO4J_VERSION}/apoc-${NEO4J_VERSION}-core.jar" -o "${NEO4J_HOME}/plugins/apoc.jar"

# Set the working directory
WORKDIR /app

# Clone the project repository.
RUN git clone https://github.com/bhuvanmdev/graph-rag-agent.git /app

# Install Python dependencies before creating the non-root user
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# === Correct Neo4j Configuration ===
# Create directories first, then configure Neo4j to use them.
RUN mkdir -p /app/neo4j_data /app/neo4j_logs
RUN sed -i 's/#server.default_listen_address=127.0.0.1/server.default_listen_address=0.0.0.0/' ${NEO4J_HOME}/conf/neo4j.conf && \
    echo 'dbms.security.procedures.unrestricted=apoc.*' >> ${NEO4J_HOME}/conf/neo4j.conf

# === Correctly Prepare and Place Data ===
# The neo4j_data.zip file should be in the same directory as your Dockerfile
COPY neo4j_data.zip /app/neo4j_data.zip
# Unzip the data into a temporary directory first to inspect its structure
RUN mkdir -p /app/temp_unzip && unzip /app/neo4j_data.zip -d /app/temp_unzip
# Move the contents to the OFFICIAL Neo4j data and logs directories
RUN mv /app/temp_unzip/neo4j_data/* ${NEO4J_HOME}/data/ && \
    mv /app/temp_unzip/neo4j_logs/* ${NEO4J_HOME}/logs/ && \
    rm -rf /app/temp_unzip /app/neo4j_data.zip

# Create a non-root user
RUN useradd -m -u 1000 user

# Set Final Permissions for Neo4j and the app directory
RUN chown -R user:user /app ${NEO4J_HOME}

# Make the startup script executable
RUN chmod +x /app/scripts/run_hf.sh

# Switch to the non-root user
USER user

# Expose the Gradio port
EXPOSE 7860


# Entrypoint to start services
ENTRYPOINT ["/app/scripts/run_hf.sh"]