Refactoring: No uploads/ vol,access neo4j directly

Digital Ocean does not support shared directories. So we have to uploads
the images in `/uploads` via `kubectl cp` or something similar.
Likewise, it is not possible to share the exported mongodb .json files
with neo4j container. Therefore let's install `cypher-shell`, included
in `neo4j` package, to directly open a neo4j connection and bulk import
the data.
This commit is contained in:
Robert Schäfer 2019-02-04 14:31:40 +01:00
parent 20908cd062
commit 5492b282bc
14 changed files with 15 additions and 12 deletions

View File

@ -1,8 +1,13 @@
FROM neo4j:3.5.0 as neo4j
FROM mongo:4
RUN apt-get update \
&& apt-get -y install --no-install-recommends openssh-client rsync \
RUN apt-get update
RUN apt-get -y install --no-install-recommends wget apt-transport-https
RUN wget -O - https://debian.neo4j.org/neotechnology.gpg.key | apt-key add -
RUN echo 'deb https://debian.neo4j.org/repo stable/' | tee /etc/apt/sources.list.d/neo4j.list
RUN apt-get update
RUN apt-get -y install --no-install-recommends openjdk-8-jre openssh-client neo4j rsync \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY import.sh .
COPY neo4j/ mongo/ ./
COPY migrate.sh /usr/local/bin/migrate

View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
/mongo/import.sh && /neo4j/import.sh

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -e
for var in "SSH_USERNAME" "SSH_HOST" "MONGODB_USERNAME" "MONGODB_PASSWORD" "MONGODB_DATABASE" "MONGODB_AUTH_DB" "UPLOADS_DIRECTORY"
do
@ -25,8 +26,6 @@ mongodump --host localhost -d ${MONGODB_DATABASE} --port 27018 --username ${MONG
ssh -S my-ctrl-socket -O check -l ${SSH_USERNAME} ${SSH_HOST}
ssh -S my-ctrl-socket -O exit -l ${SSH_USERNAME} ${SSH_HOST}
rsync --archive --update --verbose ${SSH_USERNAME}@${SSH_HOST}:${UPLOADS_DIRECTORY}/* /uploads/
for collection in "categories" "badges" "users" "contributions" "comments" "follows" "shouts"
do
mongoexport --db ${MONGODB_DATABASE} --collection $collection --out "/mongo-export/$collection.json"

View File

@ -1,4 +1,6 @@
#!/usr/bin/env bash
set -e
SCRIPT_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo "MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r;" | cypher-shell
for collection in "badges" "categories" "users" "follows" "contributions" "shouts" "comments"

View File

@ -9,7 +9,6 @@ services:
volumes:
- .:/nitro-backend
- /nitro-backend/node_modules
- uploads:/nitro-backend/public/uploads
command: yarn run dev
neo4j:
volumes:
@ -25,11 +24,11 @@ services:
context: db-migration-worker
volumes:
- mongo-export:/mongo-export
- uploads:/uploads
- ./db-migration-worker/.ssh/:/root/.ssh/
networks:
- hc-network
environment:
- NEO4J_URI=bolt://neo4j:7687
- "SSH_USERNAME=${SSH_USERNAME}"
- "SSH_HOST=${SSH_HOST}"
- "MONGODB_USERNAME=${MONGODB_USERNAME}"
@ -41,4 +40,3 @@ services:
volumes:
mongo-export:
uploads:

View File

@ -1,3 +1,2 @@
FROM neo4j:3.5.0
RUN wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.5.0.1/apoc-3.5.0.1-all.jar -P plugins/
COPY import ./import

View File

@ -1,2 +0,0 @@