Jonathan 19faaffbfc chore: mongoclient auto. has configuration for docker | 4 years ago | |
---|---|---|
backend | 4 years ago | |
frontend | 4 years ago | |
tools | 5 years ago | |
.env.example | 5 years ago | |
.gitattributes | 4 years ago | |
.gitignore | 4 years ago | |
.travis.yml | 4 years ago | |
LICENCE | 8 years ago | |
README.md | 4 years ago | |
docker-compose.yml | 4 years ago | |
fallback.html | 7 years ago | |
windows-start.cmd | 4 years ago |
Based off of the original Musare, which utilized Meteor.
MusareNode now uses NodeJS, Express, SocketIO and VueJS - among other technologies. We have also implemented the ability to host Musare in Docker Containers.
The master branch is available at musare.com You can also find the staging branch at musare.dev
The frontend is a vue-cli generated, vue-loader single page app, that's served over Nginx or Express. The Nginx server not only serves the frontend, but can also serve as a load balancer for requests going to the backend.
The backend is a scalable NodeJS / Redis / MongoDB app. 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.
We currently only utilize 1 backend, 1 MongoDB server and 1 Redis server running for production, though it is relatively easy to expand.
git clone https://github.com/Musare/MusareNode.git
cd MusareNode
cp backend/config/template.json backend/config/default.json
| Property | Description |
| - | - |
| mode
| Should be either development
or production
. No more explanation needed. |
| secret
| Whatever you want - used by express's session module. |
| domain
| Should be the url where the site will be accessible from,usually http://localhost
for non-Docker. |
| serverDomain
| Should be the url where the backend will be accessible from, usually http://localhost:8080
for non-Docker. |
| serverPort
| Should be the port where the backend will listen on, should always be 8080
for Docker, and is recommended for non-Docker. |
| isDocker
| Self-explanatory. Are you using Docker? |
| serverPort
| Should be the port where the backend will listen on, should always be 8080
for Docker, and is recommended for non-Docker. |
| apis.youtube.key
| Can be obtained by setting up a YouTube API Key. You need to use the YouTube Data API v3, and create an API key. |
| apis.recaptcha.secret
| Can be obtained by setting up a ReCaptcha Site (v3). |
| apis.github
| Can be obtained by setting up a GitHub OAuth Application. You need to fill in some values to create the OAuth application. The homepage is the homepage of frontend. The authorization callback url is the backend url with /auth/github/authorize/callback
added at the end. For example http://localhost:8080/auth/github/authorize/callback
. |
| apis.discord.token
| Token for the Discord bot. |
| apis.discord.loggingServer
| Server ID of the Discord logging server. |
| apis.discord.loggingChannel
| ID of the channel to be used in the Discord logging server. |
| apis.mailgun
| Can be obtained by setting up a Mailgun account, or you can disable it. |
| apis.spotify
| Can be obtained by setting up a Spotify client id, or you can disable it. |
| apis.discogs
| Can be obtained by setting up a Discogs application, or you can disable it. |
| redis.url
| Should be left alone for Docker, and changed to redis://localhost:6379/0
for non-Docker. |
| redis.password
| Should be the Redis password you either put in your startRedis.cmd
file for Windows, or .env
for docker. |
| mongo.url
| Needs to have the proper password for the MongoDB musare user, and for non-Docker you need to replace @musare:27017
with @localhost:27017
. |
| cookie.domain
| Should be the ip or address you use to access the site, without protocols (http/https), so for example localhost
. |
| cookie.secure
| Should be true
for SSL connections, and false
for normal http connections. |
cp frontend/build/config/template.json frontend/build/config/default.json
| Property | Description |
| - | - |
| serverDomain
| Should be the url where the backend will be accessible from, usually http://localhost:8080
for non-Docker. |
| frontendDomain
| Should be the url where the frontend will be accessible from, usually http://localhost
for docker or http://localhost:80
for non-Docker. |
| frontendPort
| Should be the port where the frontend will be accessible from, should always be port 81
for Docker, and is recommended to be port 80
for non-Docker. |
| recaptcha.key
| Can be obtained by setting up a ReCaptcha Site (v3). |
| cookie.domain
| Should be the ip or address you use to access the site, without protocols (http/https), so for example localhost
. |
| cookie.secure
| Should be true
for SSL connections, and false
for normal http connections. |
| siteSettings.logo
| Path to the logo image, by default it is /assets/wordmark.png
. |
| siteSettings.siteName
| Should be the name of the site. |
| siteSettings.socialLinks
| github
, twitter
and facebook
are set to the official Musare accounts by default, but can be changed. |
Simply cp .env.example .env
to setup your environment variables.
To setup snyk (which is what we use for our precommit git-hooks), you will need to:
SNYK_TOKEN
environment variable.
We use snyk to test our dependencies / dev-dependencies for vulnerabilities.
After initial configuration, there are two different options to use for your local development environment.
1) Docker 2) Standard Setup
We highly recommend using Docker - both for stability and speed of setup. We also use Docker on our production servers.
Configure the .env
file to match your settings in backend/config/default.json
.
| Property | Description |
| - | - |
| Ports | Will be how you access the services on your machine, or what ports you will need to specify in your nginx files when using proxy_pass. |
| COMPOSE_PROJECT_NAME
| Should be a unique name for this installation, especially if you have multiple instances of Musare on the same machine. |
| FRONTEND_MODE
| Should be either dev
or prod
(self-explanatory). |
| MONGO_ROOT_PASSWORD
| Password of the root/admin user of MongoDB |
| MONGO_USER_USERNAME
| Password for the "musare" user (what the backend uses) of MongoDB |
Install Docker for Desktop
Build the backend and frontend Docker images (from the root folder)
docker-compose build
Start the MongoDB database (in detached mode), which will generate the correct MongoDB users based on the .env
file.
docker-compose up -d mongo
If you want to use linting extensions in IDEs, then you must attach the IDE to the docker containers. This is entirely possible with VS Code.
Install NodeJS
Install nodemon globally
npm install -g nodemon
Install node-gyp globally (first check out https://github.com/nodejs/node-gyp#installation)
npm install -g node-gyp
.
Install webpack globally
npm install -g webpack
In the root directory, create a folder called .database
Create a file called startMongo.cmd
in the root directory with the contents:
"C:\Program Files\MongoDB\Server\3.2\bin\mongod.exe" --dbpath "D:\Programming\HTML\MusareNode\.database"
Make sure to adjust your paths accordingly.
Set up the MongoDB database itself
Start the database by executing the script startMongo.cmd
you just made
Connect to Mongo from a command prompt
mongo admin
Create an admin user
db.createUser({user: 'admin', pwd: 'PASSWORD_HERE', roles: [{role: 'userAdminAnyDatabase', db: 'admin'}]})
Connect to the Musare database
use musare
Create the "musare" user
db.createUser({user: 'musare', pwd: 'OTHER_PASSWORD_HERE', roles: [{role: 'readWrite', db: 'musare'}]})
Exit
exit
Add the authentication
In startMongo.cmd
add --auth
at the end of the first line
In the folder where you installed Redis, edit the redis.windows.conf
file
1) In there, look for the property notify-keyspace-events
.
2) Make sure that property is uncommented and has the value Ex
.
It should look like `notify-keyspace-events Ex` when done.
Create a file called startRedis.cmd
in the main folder with the contents:
"D:\Redis\redis-server.exe" "D:\Redis\redis.windows.conf" "--requirepass" "PASSWORD"
And again, make sure that the paths lead to the proper config and executable. Replace PASSWORD
with your Redis password.
Start the MongoDB database in the background.
docker-compose up -d mongo
Start redis and the mongo client in the background, as we usually don't need to monitor these for errors.
docker-compose up -d mongoclient redis
Start the backend and frontend in the foreground, so we can watch for errors during development.
docker-compose up backend frontend
You should now be able to begin development!
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://localhost:8080/
.
windows-start.cmd
or just double click the windows-start.cmd
file and all servers will automatically start up.Run startRedis.cmd
and startMongo.cmd
to start Redis and Mongo.
Execute cd frontend && npm dev
and cd backend && npm dev
separately.
Below is a list of helpful tips / solutions we've collected while developing MusareNode.
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).
You can call Toasts using our custom package, vue-roaster
, using the following code:
import Toast from "vue-roaster";
new Toast({ content: "Hi!", persistant: true });
When setting up you will need to grant yourself the admin role, using the following commands:
docker-compose exec mongo mongo admin
use musare
db.auth("MUSAREDBUSER","MUSAREDBPASSWORD")
db.users.update({username: "USERNAME"}, {$set: {role: "admin"}})
Get in touch with us via email at core@musare.com or join our Discord Guild.