mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
remove previous code, dont share mongo data folders on runtype (rs and docker)
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -47,5 +47,5 @@ webpack.webstorm.config
|
|||||||
|
|
||||||
# mongodb replica set for local dev
|
# mongodb replica set for local dev
|
||||||
mongodb-*.tgz
|
mongodb-*.tgz
|
||||||
/mongodb-data*
|
/mongodb-*
|
||||||
/.nyc_output
|
/.nyc_output
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
# big thanks to https://pakisan.github.io/posts/docker-compose-mongodb-single-node-replica-set/ <3
|
# big thanks to https://pakisan.github.io/posts/docker-compose-mongodb-single-node-replica-set/ <3
|
||||||
|
|
||||||
version: "3.9"
|
|
||||||
networks:
|
networks:
|
||||||
mongodb-network:
|
mongodb-network:
|
||||||
name: "mongodb-network"
|
name: "mongodb-network"
|
||||||
@@ -16,7 +15,7 @@ services:
|
|||||||
- "27017:27017"
|
- "27017:27017"
|
||||||
restart: "unless-stopped"
|
restart: "unless-stopped"
|
||||||
volumes:
|
volumes:
|
||||||
- "./mongodb-data:/data/db"
|
- "./mongodb-docker-data:/data/db"
|
||||||
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs" ]
|
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs" ]
|
||||||
mongoinit:
|
mongoinit:
|
||||||
image: "mongo:7.0"
|
image: "mongo:7.0"
|
||||||
@@ -28,10 +27,9 @@ services:
|
|||||||
- mongodb-network
|
- mongodb-network
|
||||||
|
|
||||||
command: >
|
command: >
|
||||||
mongosh --host mongodb:27017 --eval "rs.initiate({
|
bash -c "
|
||||||
_id: \"rs\",
|
until mongosh --host mongodb:27017 --eval 'db.adminCommand({ping:1})' >/dev/null 2>&1; do
|
||||||
members: [
|
sleep 1
|
||||||
{_id: 0, host: \"mongodb\"}
|
done
|
||||||
]
|
mongosh --host mongodb:27017 --eval 'try { rs.initiate({_id: \"rs\", members:[{_id:0, host: \"mongodb:27017\"}]}); } catch(e) { print(\"rs.initiate skipped or failed: \" + e); }'
|
||||||
})"
|
"
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import path from 'path';
|
|||||||
import babel from 'gulp-babel';
|
import babel from 'gulp-babel';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
/* import spawn from 'cross-spawn'; // eslint-disable-line import/no-extraneous-dependencies
|
import spawn from 'cross-spawn';
|
||||||
import clean from 'rimraf'; */
|
import clean from 'rimraf';
|
||||||
|
|
||||||
gulp.task('build:babel:server', () => gulp.src('website/server/**/*.js')
|
gulp.task('build:babel:server', () => gulp.src('website/server/**/*.js')
|
||||||
.pipe(babel())
|
.pipe(babel())
|
||||||
@@ -35,7 +35,7 @@ gulp.task('build:prod', gulp.series(
|
|||||||
// When used on windows `run-rs` must first be run without the `--keep` option
|
// When used on windows `run-rs` must first be run without the `--keep` option
|
||||||
// in order to be setup correctly, afterwards it can be used.
|
// in order to be setup correctly, afterwards it can be used.
|
||||||
|
|
||||||
const MONGO_PATH = path.join(__dirname, '/../mongodb-data/');
|
const MONGO_PATH = path.join(__dirname, '/../mongodb-data-rs/');
|
||||||
|
|
||||||
gulp.task('build:prepare-mongo', async () => {
|
gulp.task('build:prepare-mongo', async () => {
|
||||||
if (fs.existsSync(MONGO_PATH)) {
|
if (fs.existsSync(MONGO_PATH)) {
|
||||||
@@ -51,7 +51,7 @@ gulp.task('build:prepare-mongo', async () => {
|
|||||||
console.log('MongoDB data folder is missing, setting up.'); // eslint-disable-line no-console
|
console.log('MongoDB data folder is missing, setting up.'); // eslint-disable-line no-console
|
||||||
|
|
||||||
// use run-rs without --keep, kill it as soon as the replica set starts
|
// use run-rs without --keep, kill it as soon as the replica set starts
|
||||||
/* const runRsProcess = spawn('node', ['../scripts/start-local-mongo.mjs --build-db']);
|
const runRsProcess = spawn('npm', ['run', 'mongo:dev:rs']);
|
||||||
|
|
||||||
for await (const chunk of runRsProcess.stdout) {
|
for await (const chunk of runRsProcess.stdout) {
|
||||||
const stringChunk = chunk.toString();
|
const stringChunk = chunk.toString();
|
||||||
@@ -79,8 +79,6 @@ gulp.task('build:prepare-mongo', async () => {
|
|||||||
|
|
||||||
throw new Error(`Error running run-rs: ${error}`);
|
throw new Error(`Error running run-rs: ${error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build:dev', gulp.series(
|
gulp.task('build:dev', gulp.series(
|
||||||
|
|||||||
887
package-lock.json
generated
887
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -105,11 +105,9 @@
|
|||||||
"start": "node --watch ./website/server/index.js",
|
"start": "node --watch ./website/server/index.js",
|
||||||
"start:simple": "node ./website/server/index.js",
|
"start:simple": "node ./website/server/index.js",
|
||||||
"debug": "node --watch --inspect ./website/server/index.js",
|
"debug": "node --watch --inspect ./website/server/index.js",
|
||||||
"mongo:dev_old": "run-rs -v 7.0.23 -l ubuntu2214 --keep --dbpath mongodb-data --number 1 --quiet",
|
"mongo:dev:rs": "run-rs -v 7.0.23 -l ubuntu2214 --keep --dbpath mongodb-data-rs --number 1 --quiet",
|
||||||
"mongo:test_old": "run-rs -v 7.0.23 -l ubuntu2214 --keep --dbpath mongodb-data-testing --number 1 --quiet",
|
"mongo:test:rs": "run-rs -v 7.0.23 -l ubuntu2214 --keep --dbpath mongodb-data-rs-testing --number 1 --quiet",
|
||||||
"mongo:dev_": "node scripts/start-local-mongo.mjs",
|
"mongo:dev:docker": "docker compose -f docker-compose.mongo-local.yml up",
|
||||||
"mongo:dev": "docker compose -f docker-compose.mongo-local.yml up",
|
|
||||||
"mongo:dev:down": "docker compose -f docker-compose.mongo-local.yml down",
|
|
||||||
"mongo:test": "node scripts/start-local-mongo.mjs --test-db",
|
"mongo:test": "node scripts/start-local-mongo.mjs --test-db",
|
||||||
"postinstall": "git config --global url.\"https://\".insteadOf git:// && gulp build && cd website/client && npm install",
|
"postinstall": "git config --global url.\"https://\".insteadOf git:// && gulp build && cd website/client && npm install",
|
||||||
"apidoc": "gulp apidoc",
|
"apidoc": "gulp apidoc",
|
||||||
@@ -123,10 +121,10 @@
|
|||||||
"chalk": "^5.3.0",
|
"chalk": "^5.3.0",
|
||||||
"cross-spawn": "^7.0.5",
|
"cross-spawn": "^7.0.5",
|
||||||
"mocha": "^5.1.1",
|
"mocha": "^5.1.1",
|
||||||
"mongodb-memory-server": "^10.1.2",
|
|
||||||
"monk": "^7.3.4",
|
"monk": "^7.3.4",
|
||||||
"nyc": "^15.1.0",
|
"nyc": "^15.1.0",
|
||||||
"require-again": "^2.0.0",
|
"require-again": "^2.0.0",
|
||||||
|
"run-rs": "^0.7.7",
|
||||||
"sinon-chai": "^3.7.0",
|
"sinon-chai": "^3.7.0",
|
||||||
"sinon-stub-promise": "^4.0.0"
|
"sinon-stub-promise": "^4.0.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
/* eslint-disable-file */
|
|
||||||
import { MongoMemoryReplSet } from 'mongodb-memory-server';
|
|
||||||
|
|
||||||
import { dirname } from 'node:path';
|
|
||||||
import { existsSync, mkdirSync } from 'node:fs';
|
|
||||||
import { fileURLToPath } from 'node:url';
|
|
||||||
|
|
||||||
const TEST_MODE = process.argv.includes('--test-db');
|
|
||||||
const BUILD_MODE = process.argv.includes('--build-db');
|
|
||||||
|
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
||||||
|
|
||||||
const pathSuffix = TEST_MODE ? '-test' : BUILD_MODE ? '-build' : '';
|
|
||||||
|
|
||||||
const mongoDbPath = `${__dirname}/../mongodb-data`+pathSuffix;
|
|
||||||
|
|
||||||
if (!existsSync(mongoDbPath)) {
|
|
||||||
mkdirSync(mongoDbPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
// async code in where
|
|
||||||
|
|
||||||
// This will create an new instance of "MongoMemoryServer" and automatically start it
|
|
||||||
const mongod = await MongoMemoryReplSet.create({
|
|
||||||
replSet: {
|
|
||||||
count: 3,
|
|
||||||
dbName: TEST_MODE ? 'habitica-test' : 'habitica-dev',
|
|
||||||
dbPath: mongoDbPath,
|
|
||||||
name: 'rs',
|
|
||||||
},
|
|
||||||
instanceOpts: [
|
|
||||||
{
|
|
||||||
port: 27017,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
port: 27018,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
port: 27019,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
dispose: {
|
|
||||||
cleanup: !BUILD_MODE && !TEST_MODE,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const uri = mongod.getUri();
|
|
||||||
|
|
||||||
console.log(`MongoDB running at ${uri}`, mongod.state);
|
|
||||||
|
|
||||||
// Keep the Node.js process running
|
|
||||||
setInterval(() => {}, 1000);
|
|
||||||
})();
|
|
||||||
7671
website/client/package-lock.json
generated
7671
website/client/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user