mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Simplify migration script
This commit is contained in:
parent
542c37a32b
commit
af4f391e28
@ -1,18 +1,17 @@
|
||||
FROM humanconnection/neo4j:latest as base
|
||||
|
||||
RUN apk upgrade --update
|
||||
RUN apk add mongodb mongodb-tools openssh nodejs yarn
|
||||
|
||||
COPY migration ./migration
|
||||
COPY migrate.sh /usr/local/bin/migrate
|
||||
COPY sync_uploads.sh /usr/local/bin/sync_uploads
|
||||
|
||||
|
||||
ENV NODE_ENV=maintenance
|
||||
FROM humanconnection/nitro-backend:latest as backend
|
||||
FROM base
|
||||
COPY --from=backend /nitro-backend /nitro-backend
|
||||
EXPOSE 7687 7474
|
||||
VOLUME /mongo-export /uploads /data
|
||||
|
||||
RUN apk upgrade --update
|
||||
RUN apk add --no-cache mongodb-tools openssh nodejs yarn
|
||||
|
||||
FROM humanconnection/nitro-backend:latest as backend
|
||||
|
||||
FROM base
|
||||
|
||||
COPY --from=backend /nitro-backend /nitro-backend
|
||||
COPY seeding/package.json .
|
||||
# Install graphql-request manually, it's required for seeding and not included
|
||||
# in backend's preinstalled node_modules/
|
||||
@ -22,3 +21,7 @@ RUN yarn install && \
|
||||
mv package.json /nitro-backend/package.json
|
||||
# We have to do this odd copying to prevent cleaning `node_modules` folder which
|
||||
# would happen if we `yarn install|add` in the target directory
|
||||
|
||||
COPY migration ./migration
|
||||
COPY ./binaries/migrate.sh /usr/local/bin/migrate
|
||||
COPY ./binaries/sync_uploads.sh /usr/local/bin/sync_uploads
|
||||
|
||||
@ -9,16 +9,14 @@ echo "MONGODB_DATABASE ${MONGODB_DATABASE}"
|
||||
echo "MONGODB_AUTH_DB ${MONGODB_AUTH_DB}"
|
||||
echo "-------------------------------------------------"
|
||||
|
||||
mongo ${MONGODB_DATABASE} --eval "db.dropDatabase();"
|
||||
rm -rf /mongo-export/*
|
||||
|
||||
ssh -4 -M -S my-ctrl-socket -fnNT -L 27018:localhost:27017 -l ${SSH_USERNAME} ${SSH_HOST}
|
||||
mongodump --host localhost -d ${MONGODB_DATABASE} --port 27018 --username ${MONGODB_USERNAME} --password ${MONGODB_PASSWORD} --authenticationDatabase ${MONGODB_AUTH_DB} --gzip --archive=/tmp/mongodump.archive
|
||||
mongorestore --gzip --archive=/tmp/mongodump.archive
|
||||
ssh -S my-ctrl-socket -O check -l ${SSH_USERNAME} ${SSH_HOST}
|
||||
ssh -S my-ctrl-socket -O exit -l ${SSH_USERNAME} ${SSH_HOST}
|
||||
|
||||
for collection in "categories" "badges" "users" "contributions" "comments" "follows" "shouts"
|
||||
do
|
||||
mongoexport --db ${MONGODB_DATABASE} --collection $collection --out "/mongo-export/$collection.json"
|
||||
mongoexport --host localhost -d ${MONGODB_DATABASE} --port 27018 --username ${MONGODB_USERNAME} --password ${MONGODB_PASSWORD} --authenticationDatabase ${MONGODB_AUTH_DB} --db ${MONGODB_DATABASE} --collection $collection --out "/mongo-export/$collection.json"
|
||||
done
|
||||
|
||||
ssh -S my-ctrl-socket -O check -l ${SSH_USERNAME} ${SSH_HOST}
|
||||
ssh -S my-ctrl-socket -O exit -l ${SSH_USERNAME} ${SSH_HOST}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user