Browse Source

Updated README, added Redis to services

Cameron Kline 8 years ago
parent
commit
ce8312b847
3 changed files with 93 additions and 12 deletions
  1. 6 5
      .editorconfig
  2. 84 7
      README.md
  3. 3 0
      docker-compose.yml

+ 6 - 5
.editorconfig

@@ -3,17 +3,18 @@ root = true
 [*]
 charset = utf-8
 indent_style = tab
-indent_size = 4
-end_of_line = lf
-insert_final_newline = true
-trim_trailing_whitespace = true
 
 [frontend/nginx.conf]
 charset = utf-8
 indent_style = space
 indent_size = 4
+
+[docker-compose.yml]
+charset = utf-8
+indent_style = space
+indent_size = 2
+
 end_of_line = lf
 insert_final_newline = true
 trim_trailing_whitespace = true
-
 continuation_indent_size = 4

+ 84 - 7
README.md

@@ -1,5 +1,27 @@
 # MusareNode
-Musare in NodeJS, Express, SocketIO and VueJS.
+This is a rewrite of the original [Musare](https://github.com/Musare/Musare)
+in NodeJS, Express, SocketIO and VueJS. Everything is ran in it's own docker container.
+
+### Our Stack
+
+   * NodeJS
+   * MongoDB
+   * Redis
+   * Nginx
+   * VueJS
+
+### Frontend
+The frontend is a [vue-cli](https://github.com/vuejs/vue-cli) generated,
+[vue-loader](https://github.com/vuejs/vue-loader) single page app, that's
+served over Nginx. The Nginx server not only serves the frontend, but
+also serves as a load balancer for requests going to the backend.
+
+### Backend
+The backend is a scalable NodeJS / Redis / MongoDB app. Each backend
+server handles a group of SocketIO connections. User sessions are stored
+in a central Redis server. All data is stored in a central MongoDB server.
+The Redis and MongoDB servers are replicated to several secondary nodes,
+which can become the primary node if the current primary node goes down.
 
 ## Requirements
  * [Docker](https://www.docker.com/)
@@ -8,16 +30,71 @@ Musare in NodeJS, Express, SocketIO and VueJS.
 Once you've installed the required tools:
 
 1. `git clone https://github.com/MusareNode/MusareNode.git`
+
 2. `cd MusareNode`
+
 3. `cp backend/config/template.json backend/config/default.json`
 
-  > The `secret` key can be whatever. It's used by express's session module. The `apis.youtube.key` value can be obtained by setting up a [YouTube API Key](https://developers.google.com/youtube/v3/getting-started).
+   > The `secret` key can be whatever. It's used by express's session module.
+   The `apis.youtube.key` value can be obtained by setting up a
+   [YouTube API Key](https://developers.google.com/youtube/v3/getting-started).
+  
+4. Build the backend and frontend Docker images
+
+   `docker-compose build`
+
+5. Start the databases and tools in the background, as we usually don't need to monitor these for errors
+
+   `docker-compose up -d mongo mongoclient redis`
+
+6. Start the backend and frontend in the foreground, so we can watch for errors during development
+
+   `docker-compose up backend frontend`
+
+7. You should now be able to start working on files! The backend is auto reloaded when
+   you make changes and the frontend is auto compiled and live reloaded by webpack
+   when you make changes. You should be able to access Musare in your local browser
+   at `http://<docker-machine-ip>:8080/` where `docker-machine-ip` can be found below:
+
+   * Docker for Windows / Mac: This is just `localhost`
+   
+   * Docker ToolBox: The output of `docker-machine ip default`
+   
+## Extra
+
+Below is a list of helpful tips / solutions we've collected while developing MusareNode.
+
+### Mounting a non-standard directory in Docker Toolbox on Windows
+
+Docker Toolbox usually mounts only `C:/Users` as a shared volume with Docker Toolbox
+(boot2docker which uses VirtualBox). So say if your code is all located else were on
+your machine. You can use variations of the following commands to give Docker Toolbox
+access to those files.
+
+1. First lets ensure the machine isn't running
+
+   `docker-machine stop default`
+
+1. Next we'll want to tell the machine about the folder we want to share.
+
+   `"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" sharedfolder add default --name "d/DockerBasedProjects" --hostpath "D:\DockerBasedProjects" --automount`
+
+2. Now start the machine back up and ssh into it
 
-4. `docker-compose build`
-5. `docker-compose up`
+   `docker-machine start default && docker-machine ssh default`
+   
+3. Tell boot2docker to mount our volume at startup, by appending to its startup script
 
-This will ensure that the services we've created start up correctly.
+   ```bash
+   sudo tee -a /mnt/sda1/var/lib/boot2docker/profile >/dev/null <<EOF
+   
+   mkdir -p /d/Programming/HTML/MusareNode
+   mount -t vboxsf -o uid=1000,gid=50 d/Programming/HTML/MusareNode /d/Programming/HTML/MusareNode
+   EOF
+   ```
 
-Once this is done you should be able to access Musare in your local browser at [localhost](http://localhost:8080/).
+4. Restart the docker machine so that it uses the new shared folder
 
-If you are using Docker ToolBox, you will access Musare at `192.168.99.100` instead of `localhost` or `127.0.0.1`.
+   `docker-machine restart default`
+   
+5. You should now be good to go!

+ 3 - 0
docker-compose.yml

@@ -8,6 +8,7 @@ services:
     - ./backend:/opt/app
     links:
     - mongo
+    - redis
   frontend:
     build: ./frontend
     ports:
@@ -22,3 +23,5 @@ services:
     image: mongoclient/mongoclient
     ports:
     - "3000:3000"
+  redis:
+    image: redis