matsuap commited on
Commit
48fee7d
·
1 Parent(s): 0e412ae

refactor(docker): switch to python:3.11-slim base, install neo4j via APT

Browse files
Files changed (3) hide show
  1. Dockerfile +22 -18
  2. start.sh +2 -2
  3. supervisord.conf +2 -1
Dockerfile CHANGED
@@ -1,11 +1,19 @@
1
- FROM neo4j:5.18-community
2
 
3
- USER root
4
 
5
  # System deps
6
  RUN apt-get update && apt-get install -y \
7
- python3 python3-pip python3-venv \
8
- curl ca-certificates supervisor git \
 
 
 
 
 
 
 
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
  # Node.js 20
@@ -17,15 +25,15 @@ WORKDIR /app
17
 
18
  # Python deps
19
  COPY requirements.txt /app/requirements.txt
20
- RUN pip3 install --no-cache-dir --upgrade pip && \
21
- pip3 install --no-cache-dir -r /app/requirements.txt
22
 
23
  # Frontend build
24
  COPY frontend /app/frontend
25
  WORKDIR /app/frontend
26
  RUN npm install && npm run build
27
 
28
- # Backend
29
  WORKDIR /app
30
  COPY backend /app/backend
31
  COPY data /app/data
@@ -33,12 +41,8 @@ COPY supervisord.conf /etc/supervisor/conf.d/ccrag.conf
33
  COPY start.sh /app/start.sh
34
  RUN chmod +x /app/start.sh
35
 
36
- # Write neo4j.conf directly — bypasses entrypoint /data permission check entirely.
37
- # Directories point to /tmp/neo4j which any user can write.
38
- RUN mkdir -p /var/lib/neo4j/conf /tmp/neo4j/data /tmp/neo4j/logs \
39
- /tmp/neo4j/import /tmp/neo4j/plugins \
40
- && chmod -R 777 /tmp/neo4j \
41
- && printf '%s\n' \
42
  'dbms.security.auth_enabled=false' \
43
  'server.bolt.listen_address=127.0.0.1:7687' \
44
  'server.http.listen_address=127.0.0.1:7474' \
@@ -49,13 +53,13 @@ RUN mkdir -p /var/lib/neo4j/conf /tmp/neo4j/data /tmp/neo4j/logs \
49
  'server.memory.heap.initial_size=256m' \
50
  'server.memory.heap.max_size=512m' \
51
  'server.memory.pagecache.size=256m' \
52
- > /var/lib/neo4j/conf/neo4j.conf \
53
- && chmod 666 /var/lib/neo4j/conf/neo4j.conf
54
 
55
- # Override parent ENTRYPOINT — prevents /data writability check on container start
56
- ENTRYPOINT []
 
 
57
 
58
- # App config
59
  ENV OPENAI_MODEL=gpt-4o-mini
60
  ENV NEO4J_URI=bolt://localhost:7687
61
  ENV NEO4J_USER=neo4j
 
1
+ FROM python:3.11-slim
2
 
3
+ ENV DEBIAN_FRONTEND=noninteractive
4
 
5
  # System deps
6
  RUN apt-get update && apt-get install -y \
7
+ curl ca-certificates gnupg supervisor git wget \
8
+ && rm -rf /var/lib/apt/lists/*
9
+
10
+ # Neo4j 5 from official APT repo
11
+ RUN curl -fsSL https://debian.neo4j.com/neotechnology.gpg.key \
12
+ | gpg --dearmor -o /usr/share/keyrings/neo4j.gpg \
13
+ && echo "deb [signed-by=/usr/share/keyrings/neo4j.gpg] https://debian.neo4j.com stable 5" \
14
+ > /etc/apt/sources.list.d/neo4j.list \
15
+ && apt-get update \
16
+ && apt-get install -y neo4j \
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
  # Node.js 20
 
25
 
26
  # Python deps
27
  COPY requirements.txt /app/requirements.txt
28
+ RUN pip install --no-cache-dir --upgrade pip \
29
+ && pip install --no-cache-dir -r /app/requirements.txt
30
 
31
  # Frontend build
32
  COPY frontend /app/frontend
33
  WORKDIR /app/frontend
34
  RUN npm install && npm run build
35
 
36
+ # Backend + data
37
  WORKDIR /app
38
  COPY backend /app/backend
39
  COPY data /app/data
 
41
  COPY start.sh /app/start.sh
42
  RUN chmod +x /app/start.sh
43
 
44
+ # Write neo4j.conf — point all dirs to /tmp, disable auth
45
+ RUN printf '%s\n' \
 
 
 
 
46
  'dbms.security.auth_enabled=false' \
47
  'server.bolt.listen_address=127.0.0.1:7687' \
48
  'server.http.listen_address=127.0.0.1:7474' \
 
53
  'server.memory.heap.initial_size=256m' \
54
  'server.memory.heap.max_size=512m' \
55
  'server.memory.pagecache.size=256m' \
56
+ > /etc/neo4j/neo4j.conf
 
57
 
58
+ # Pre-create Neo4j data dirs owned by neo4j user
59
+ RUN mkdir -p /tmp/neo4j/data /tmp/neo4j/logs /tmp/neo4j/import /tmp/neo4j/plugins \
60
+ && chown -R neo4j:neo4j /tmp/neo4j \
61
+ && chmod -R 755 /tmp/neo4j
62
 
 
63
  ENV OPENAI_MODEL=gpt-4o-mini
64
  ENV NEO4J_URI=bolt://localhost:7687
65
  ENV NEO4J_USER=neo4j
start.sh CHANGED
@@ -1,8 +1,8 @@
1
  #!/usr/bin/env bash
2
  set -e
3
 
4
- # Recreate Neo4j tmp dirs in case they were cleared at runtime
5
  mkdir -p /tmp/neo4j/data /tmp/neo4j/logs /tmp/neo4j/import /tmp/neo4j/plugins
6
- chmod -R 777 /tmp/neo4j
7
 
8
  exec /usr/bin/supervisord -c /etc/supervisor/conf.d/ccrag.conf
 
1
  #!/usr/bin/env bash
2
  set -e
3
 
4
+ # Recreate Neo4j data dirs and ensure neo4j user can write
5
  mkdir -p /tmp/neo4j/data /tmp/neo4j/logs /tmp/neo4j/import /tmp/neo4j/plugins
6
+ chown -R neo4j:neo4j /tmp/neo4j 2>/dev/null || chmod -R 777 /tmp/neo4j
7
 
8
  exec /usr/bin/supervisord -c /etc/supervisor/conf.d/ccrag.conf
supervisord.conf CHANGED
@@ -1,12 +1,13 @@
1
  [supervisord]
2
  nodaemon=true
 
3
  pidfile=/tmp/supervisord.pid
4
  logfile=/tmp/supervisord.log
5
  logfile_maxbytes=10MB
6
  loglevel=info
7
 
8
  [program:neo4j]
9
- command=/var/lib/neo4j/bin/neo4j console
10
  autostart=true
11
  autorestart=true
12
  stdout_logfile=/tmp/neo4j.log
 
1
  [supervisord]
2
  nodaemon=true
3
+ user=root
4
  pidfile=/tmp/supervisord.pid
5
  logfile=/tmp/supervisord.log
6
  logfile_maxbytes=10MB
7
  loglevel=info
8
 
9
  [program:neo4j]
10
+ command=/usr/bin/neo4j console
11
  autostart=true
12
  autorestart=true
13
  stdout_logfile=/tmp/neo4j.log