Selaa lähdekoodia

Added option to run Musare locally without Docker.

KrisVos130 8 vuotta sitten
vanhempi
commit
a15e8ee7c4
7 muutettua tiedostoa jossa 48 lisäystä ja 6 poistoa
  1. 4 0
      .gitignore
  2. 18 0
      README.md
  3. 7 0
      backend/config/template.json
  4. 15 3
      backend/index.js
  5. 1 0
      backend/package.json
  6. 0 1
      frontend/Dockerfile
  7. 3 2
      frontend/package.json

+ 4 - 0
.gitignore

@@ -4,6 +4,10 @@ Thumbs.db
 .idea/
 .vagrant/
 
+startRedis.cmd
+startMongo.cmd
+.database
+
 # Back End
 backend/node_modules/
 backend/config/default.json

+ 18 - 0
README.md

@@ -102,3 +102,21 @@ of the following commands to give Docker Toolbox access to those files.
 ### Fixing the "couldn't connect to docker daemon" error
 
 Some people have had issues while trying to execute the `docker-compose` command. To fix this, you will have to run `docker-machine env default`. This command will print various variables. At the bottom, it will say something similar to `@FOR /f "tokens=*" %i IN ('docker-machine env default') DO @%i`. Run this command in your shell. You will have to do this command for every shell you want to run `docker-compose` in, every session.
+
+### Running Musare locally
+
+For Windows, install Redis https://cloud.github.com/downloads/dmajkic/redis/redis-2.4.5-win32-win64.zip
+Extract it somewhere on your pc.
+In the Musare project directory, make a batch file called startRedis.cmd. In the batch file, write (in quotation marks "") the full path to the redis-server.exe
+
+For MongoDB, install MongoDB from https://www.mongodb.com/download-center#community
+Make a new batch file called startMongo with this time the full path to the mongod.exe file. For version 3.2, this is `"C:\Program Files\MongoDB\Server\3.2\bin\mongod.exe"`
+After that, on the same line, add `--dbpath "C:\Path\To\Project\.database"` which leads to your project and then a .database folder in your project. Make sure to make the .database folder in your project before running mongo.
+
+Install nodemon globally by doing `npm install nodemon -g`.
+Install webpack globally by doing `npm install webpack -g`.
+Install node-gyp globally (first check out https://github.com/nodejs/node-gyp#installation) by doing `npm install node-gyp -g`.
+In frontend and in backend, do `npm install`.
+
+To start it, start Mongo and Redis by starting the two start scripts.
+After they have started, in the frontend folder do `npm run development-watch` and in the backend folder run `npm run development-w`

+ 7 - 0
backend/config/template.json

@@ -1,6 +1,7 @@
 {
 	"secret": "",
 	"domain": "",
+  	"localSetup": false,
 	"apis": {
 		"youtube": {
 			"key": ""
@@ -23,5 +24,11 @@
 			"http://192.168.99.100:8080",
 			"http://dev.musare.com"
 		]
+	},
+  	"redis": {
+	  	"url": "redis://redis:6379/0"
+	},
+  	"mongo": {
+	  	"url": "mongodb://mongo:27017/musare"
 	}
 }

+ 15 - 3
backend/index.js

@@ -8,12 +8,13 @@ const db = require('./logic/db');
 const app = require('./logic/app');
 const io = require('./logic/io');
 const cache = require('./logic/cache');
+const config = require('config');
 
 async.waterfall([
 
 	// setup our Redis cache
 	(next) => {
-		cache.init('redis://redis:6379/0', () => {
+		cache.init(config.get('redis').url, () => {
 			// load some test stations into the cache
 			async.waterfall([
 				(next) => cache.hset('stations', '7dbf25fd-b10d-6863-2f48-637f6014b162', cache.schemas.station({
@@ -39,13 +40,24 @@ async.waterfall([
 	},
 
 	// setup our MongoDB database
-	(next) => db.init('mongodb://mongo:27017/musare', next),
+	(next) => db.init(config.get("mongo").url, next),
 
 	// setup the express server (not used right now, but may be used for OAuth stuff later, or for an API)
 	(next) => app.init(next),
 
 	// setup the socket.io server (all client / server communication is done over this)
-	(next) => io.init(next)
+	(next) => io.init(next),
+
+	// setup the frontend for local setups
+	(next) => {
+		if (config.get("localSetup")) {
+			const express = require('express');
+			const app = express();
+			const server = app.listen(8080);
+			app.use(express.static(__dirname + "/../frontend/build/"));
+		}
+		next();
+	}
 ], (err) => {
 	if (err && err !== true) {
 		console.error('An error occurred while initializing the backend server');

+ 1 - 0
backend/package.json

@@ -7,6 +7,7 @@
   "repository": "https://github.com/Musare/MusareNode",
   "scripts": {
     "development": "nodemon --inspect --debug -L /opt/app",
+    "development-w": "nodemon",
     "production": "node /opt/app"
   },
   "dependencies": {

+ 0 - 1
frontend/Dockerfile

@@ -12,7 +12,6 @@ RUN apk add make
 RUN apk add nginx
 
 RUN npm install -g webpack@"^1.13.2"
-RUN npm install -g node-sass@"^3.11.2"
 
 RUN mkdir -p /opt
 WORKDIR /opt

+ 3 - 2
frontend/package.json

@@ -31,8 +31,9 @@
     "webpack-dev-server": "^1.15.1"
   },
   "dependencies": {
+    "node-sass": "^3.13.0",
     "vue": "^1.0.26",
-    "vue-router": "^0.7.13",
-    "vue-roaster": "^1.0.7"
+    "vue-roaster": "^1.0.7",
+    "vue-router": "^0.7.13"
   }
 }