mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
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:
parent
20908cd062
commit
5492b282bc
@ -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
|
||||
|
||||
2
db-migration-worker/migrate.sh
Normal file
2
db-migration-worker/migrate.sh
Normal file
@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
/mongo/import.sh && /neo4j/import.sh
|
||||
@ -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"
|
||||
@ -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"
|
||||
@ -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:
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user