TheQuantEd commited on
Commit
9c55c11
Β·
1 Parent(s): 50a3cfd

Fix: install Neo4j+cypher-shell via official Debian apt repo (no tar.gz/APOC download)

Browse files
Files changed (3) hide show
  1. Dockerfile +13 -23
  2. docker/entrypoint.sh +13 -11
  3. docker/supervisord.conf +2 -2
Dockerfile CHANGED
@@ -27,14 +27,8 @@ ENV LANG=C.UTF-8
27
 
28
  # ── System dependencies ────────────────────────────────────────────────────────
29
  RUN apt-get update && apt-get install -y --no-install-recommends \
30
- # Java for Neo4j 2026.x (requires Java 21+)
31
- openjdk-21-jre-headless \
32
- # Python
33
  python3.11 python3-pip python3.11-venv \
34
- # Web / infra
35
- nginx \
36
- supervisor \
37
- # Utilities
38
  curl wget ca-certificates gnupg \
39
  && rm -rf /var/lib/apt/lists/*
40
 
@@ -43,26 +37,22 @@ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
43
  && apt-get install -y --no-install-recommends nodejs \
44
  && rm -rf /var/lib/apt/lists/*
45
 
46
- # ── Neo4j Community 5.24.0 + APOC 5.24.0 ─────────────────────────────────────
47
- ENV NEO4J_HOME=/opt/neo4j
48
- ENV PATH="${NEO4J_HOME}/bin:${PATH}"
 
 
 
 
 
49
 
50
- RUN wget -q "https://dist.neo4j.org/neo4j-community-5.24.0-unix.tar.gz" \
51
- && tar -xzf "neo4j-community-5.24.0-unix.tar.gz" -C /opt \
52
- && mv "/opt/neo4j-community-5.24.0" /opt/neo4j \
53
- && rm "neo4j-community-5.24.0-unix.tar.gz" \
54
- && rm -rf /opt/neo4j/data \
55
- && wget -q "https://github.com/neo4j-labs/apoc/releases/download/5.24.0/apoc-5.24.0-core.jar" \
56
- -O /opt/neo4j/plugins/apoc-5.24.0-core.jar
57
 
58
- # Neo4j configuration β€” listen on all interfaces, use /data for persistence
59
  RUN { \
60
  echo "server.bolt.listen_address=0.0.0.0:7687"; \
61
  echo "server.http.listen_address=0.0.0.0:7474"; \
62
- echo "server.directories.data=/data/neo4j/data"; \
63
- echo "server.directories.logs=/data/neo4j/logs"; \
64
- echo "server.directories.plugins=/opt/neo4j/plugins"; \
65
- echo "dbms.security.auth_enabled=true"; \
66
  echo "server.memory.heap.initial_size=512m"; \
67
  echo "server.memory.heap.max_size=1g"; \
68
  echo "server.memory.pagecache.size=256m"; \
@@ -70,7 +60,7 @@ RUN { \
70
  echo "dbms.logs.query.enabled=OFF"; \
71
  echo "dbms.security.procedures.unrestricted=apoc.*"; \
72
  echo "dbms.security.procedures.allowlist=apoc.*"; \
73
- } >> /opt/neo4j/conf/neo4j.conf
74
 
75
  # ── Python backend ────────────────────────────────────────────────────────────
76
  WORKDIR /app/backend
 
27
 
28
  # ── System dependencies ────────────────────────────────────────────────────────
29
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
 
 
30
  python3.11 python3-pip python3.11-venv \
31
+ nginx supervisor \
 
 
 
32
  curl wget ca-certificates gnupg \
33
  && rm -rf /var/lib/apt/lists/*
34
 
 
37
  && apt-get install -y --no-install-recommends nodejs \
38
  && rm -rf /var/lib/apt/lists/*
39
 
40
+ # ── Neo4j 5.x Community + cypher-shell (official Debian repo) ─────────────────
41
+ RUN curl -fsSL https://debian.neo4j.com/neotechnology.gpg.key \
42
+ | gpg --dearmor -o /usr/share/keyrings/neo4j.gpg \
43
+ && echo "deb [signed-by=/usr/share/keyrings/neo4j.gpg] https://debian.neo4j.com stable 5" \
44
+ > /etc/apt/sources.list.d/neo4j.list \
45
+ && apt-get update \
46
+ && apt-get install -y neo4j cypher-shell \
47
+ && rm -rf /var/lib/apt/lists/*
48
 
49
+ ENV NEO4J_HOME=/var/lib/neo4j
50
+ ENV PATH="/usr/bin:${PATH}"
 
 
 
 
 
51
 
52
+ # ── Neo4j configuration ────────────────────────────────────────────────────────
53
  RUN { \
54
  echo "server.bolt.listen_address=0.0.0.0:7687"; \
55
  echo "server.http.listen_address=0.0.0.0:7474"; \
 
 
 
 
56
  echo "server.memory.heap.initial_size=512m"; \
57
  echo "server.memory.heap.max_size=1g"; \
58
  echo "server.memory.pagecache.size=256m"; \
 
60
  echo "dbms.logs.query.enabled=OFF"; \
61
  echo "dbms.security.procedures.unrestricted=apoc.*"; \
62
  echo "dbms.security.procedures.allowlist=apoc.*"; \
63
+ } >> /etc/neo4j/neo4j.conf
64
 
65
  # ── Python backend ────────────────────────────────────────────────────────────
66
  WORKDIR /app/backend
docker/entrypoint.sh CHANGED
@@ -3,21 +3,23 @@ set -e
3
 
4
  log() { echo "[entrypoint] $*"; }
5
 
6
- # ── Persistent data dirs (HF Spaces mounts /data) ─────────────────────────────
7
- mkdir -p /data/neo4j/data /data/neo4j/logs /data/neo4j/transactions
 
8
 
9
- # Point Neo4j config at the persistent volume paths (already set in neo4j.conf,
10
- # but the data dir must exist before Neo4j starts or it refuses to launch)
11
- mkdir -p /data/neo4j/data/databases /data/neo4j/data/dbms
 
 
 
 
 
 
12
 
13
  # ── First-boot: set initial password ──────────────────────────────────────────
14
  NEO4J_PASS="${NEO4J_PASSWORD:-clinicalmatch2024}"
15
-
16
- # Always attempt set-initial-password β€” safe to run every boot:
17
- # - Before first Neo4j start: sets the password correctly
18
- # - After first start: command fails (db already has auth), || true absorbs the error
19
- log "Setting Neo4j initial password (safe to re-run)..."
20
- NEO4J_CONF=/opt/neo4j/conf \
21
  neo4j-admin dbms set-initial-password "$NEO4J_PASS" 2>&1 || \
22
  log "set-initial-password: already initialized, skipping."
23
 
 
3
 
4
  log() { echo "[entrypoint] $*"; }
5
 
6
+ # ── Persistent data dirs ───────────────────────────────────────────────────────
7
+ mkdir -p /data/neo4j/data /data/neo4j/logs
8
+ chown -R neo4j:neo4j /data/neo4j 2>/dev/null || true
9
 
10
+ # Symlink Neo4j data/logs to persistent volume
11
+ if [ ! -L /var/lib/neo4j/data ]; then
12
+ rm -rf /var/lib/neo4j/data
13
+ ln -sf /data/neo4j/data /var/lib/neo4j/data
14
+ fi
15
+ if [ ! -L /var/log/neo4j ]; then
16
+ rm -rf /var/log/neo4j
17
+ ln -sf /data/neo4j/logs /var/log/neo4j
18
+ fi
19
 
20
  # ── First-boot: set initial password ──────────────────────────────────────────
21
  NEO4J_PASS="${NEO4J_PASSWORD:-clinicalmatch2024}"
22
+ log "Setting Neo4j initial password..."
 
 
 
 
 
23
  neo4j-admin dbms set-initial-password "$NEO4J_PASS" 2>&1 || \
24
  log "set-initial-password: already initialized, skipping."
25
 
docker/supervisord.conf CHANGED
@@ -15,8 +15,8 @@ serverurl=unix:///tmp/supervisor.sock
15
 
16
  # ── Neo4j Community ────────────────────────────────────────────────────────────
17
  [program:neo4j]
18
- command=/opt/neo4j/bin/neo4j console
19
- environment=NEO4J_HOME=/opt/neo4j,JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64,NEO4J_CONF=/opt/neo4j/conf
20
  autostart=true
21
  autorestart=true
22
  startsecs=45
 
15
 
16
  # ── Neo4j Community ────────────────────────────────────────────────────────────
17
  [program:neo4j]
18
+ command=su -s /bin/bash neo4j -c "neo4j console >> /data/neo4j/logs/console.log 2>&1"
19
+ environment=NEO4J_HOME=/var/lib/neo4j,NEO4J_CONF=/etc/neo4j
20
  autostart=true
21
  autorestart=true
22
  startsecs=45