Răsfoiți Sursa

Merge tag 'v3.4.0-rc1' into staging

Owen Diffey 3 ani în urmă
părinte
comite
88ce60ebab

+ 1 - 0
.env.example

@@ -14,6 +14,7 @@ MONGO_ROOT_PASSWORD=PASSWORD_HERE
 MONGO_USER_USERNAME=musare
 MONGO_USER_PASSWORD=OTHER_PASSWORD_HERE
 MONGO_DATA_LOCATION=.db
+MONGO_VERSION=5.0
 
 REDIS_HOST=127.0.0.1
 REDIS_PORT=6379

+ 1 - 0
.github/workflows/build-eslint.yml

@@ -15,6 +15,7 @@ env:
     MONGO_USER_USERNAME: musare
     MONGO_USER_PASSWORD: OTHER_PASSWORD_HERE
     MONGO_DATA_LOCATION: .db
+    MONGO_VERSION: 5.0
     REDIS_HOST: 127.0.0.1
     REDIS_PORT: 6379
     REDIS_PASSWORD: PASSWORD

+ 1 - 0
.wiki/Configuration.md

@@ -111,6 +111,7 @@ The container port refers to the external docker container port, used to access
 | `MONGO_USER_USERNAME` | Application username for MongoDB. |
 | `MONGO_USER_PASSWORD` | Application password for MongoDB. |
 | `MONGO_DATA_LOCATION` | The location where MongoDB stores its data. Usually the `.db` folder inside the `Musare` folder. |
+| `MONGO_VERSION` | The MongoDB version to use for scripts and docker-compose. Must be numerical. Currently supported MongoDB versions are 4.0, 4.2, 4.4 and 5.0. |
 | `REDIS_HOST` | Redis container host. |
 | `REDIS_PORT` | Redis container port. |
 | `REDIS_PASSWORD` | Redis password. |

+ 2 - 0
.wiki/Installation.md

@@ -1,6 +1,8 @@
 # Installation
 Musare can be installed with Docker (recommended) or without, guides for both installations can be found below.
 
+To update an existing installation please see [Upgrading](./Upgrading.md).
+
 ## Docker
 
 ### Dependencies

+ 71 - 0
.wiki/Upgrading.md

@@ -0,0 +1,71 @@
+# Upgrading
+Musare upgrade process.
+
+To install a new instance please see [Installation](./Installation.md).
+
+## Docker
+
+### Instructions
+1. Make a backup! `./musare.sh backup`
+2. Execute `./musare.sh update`. If an update requires any configuration changes or database migrations, you will be notified.
+    - To update configuration compare example configs against your own and add/update/remove any properties as needed. For more information on properties see [Configuration](./Configuration.md). Frontend and backend configuration updates always update the `configVersion` property.
+        - Backend, compare `backend/config/template.json` against `backend/config/default.json`.
+        - Frontend, compare `frontend/dist/config/template.json` against `frontend/dist/config/default.json`.
+        - Environment, compare `.env.example` against `.env`.
+    - To migrate database;
+        - `./musare.sh stop backend`
+        - Set `migration` to `true` in  `backend/config/default.json`
+        - `./musare.sh start backend`.
+        - Follow backend logs and await migration completion notice `./musare.sh attach backend`.
+        - `./musare.sh stop backend`
+        - Set `migration` to `false` in  `backend/config/default.json`
+        - `./musare.sh start backend`.
+
+---
+
+## Non-Docker
+
+### Instructions
+1. Make a backup!
+2. Stop all services
+3. `git pull`
+4. `cd frontend && npm install`
+5. `cd ../backend && npm install`
+6. Compare example configs against your own and add/update/remove any properties as needed. For more information on properties see [Configuration](./Configuration.md). Frontend and backend configuration updates always update the `configVersion` property.
+    - Backend, compare `backend/config/template.json` against `backend/config/default.json`.
+    - Frontend, compare `frontend/dist/config/template.json` against `frontend/dist/config/default.json`.
+7. Start MongoDB and Redis services.
+8. Run database migration;
+    - Set `migration` to `true` in  `backend/config/default.json`
+    - Start backend service.
+    - Follow backend logs and await migration completion notice.
+    - Stop backend service.
+    - Set `migration` to `false` in  `backend/config/default.json`
+9. Start backend and frontend services.
+
+# Upgrade/downgrade MongoDB
+
+Make sure to always look at the upgrade/downgrade instructions in the [MongoDB release notes](https://docs.mongodb.com/manual/release-notes) before, and always make a full backup of your data before proceeding.
+
+## Docker
+
+### Instructions
+1. Stop the backend (`./musare.sh stop backend`)
+2. Make a backup of MongoDB (`./musare.sh backup`)
+3. Stop and reset the mongo container and delete the database folder (`./musare.sh reset mongo`)
+4. Change the MongoDB version inside your .env file.
+5. Start the mongo container (`./musare.sh start mongo`)
+6. Import your backup of MongoDB (`./musare.sh restore`)
+    - Note: backups are stored inside the backups folder by default.
+7. Start the backend (`./musare.sh start backend`)
+
+## Non-Docker
+
+### Instructions
+1. Stop your backend
+2. Make a backup of MongoDB
+3. Stop and reset MongoDB
+4. Upgrade/downgrade MongoDB
+5. Start MongoDB
+6. Restore your MongoDB backup
+7. Start your backend

+ 5 - 4
CHANGELOG.md

@@ -1,11 +1,9 @@
 # Changelog
 
-## [v3.4.0] - 2022-03-05
+## [v3.4.0-rc1] - 2022-03-06
 
 ### **Breaking Changes**
-This release includes a MongoDB upgrade with breaking changes. Before upgrading please backup your database and reset it, and after upgrading restore it.
-Documentation on how to do each of these steps can be found in [.wiki/Utility_Script.md](.wiki/Utility_Script.md).
-Please note that `musare.sh update` does not automatically do this for you.
+This release makes the MongoDB version configurable in the .env file. Prior to this release, the MongoDB version was 4.0. We recommend upgrading to 5.0 or 4.4. Upgrade instructions can be found in [.wiki/Upgrading](.wiki/Upgrading.md#Upgrade/downgradeMongoDB).
 
 Please run the Update All Songs job after upgrading to ensure playlist and station song data accuracy.
 
@@ -30,6 +28,8 @@ Please run the Update All Songs job after upgrading to ensure playlist and stati
 - feat: Ability to toggle report resolution status
 - feat: Ability to show news items to new users on first visit
 - feat: Added warning label to thumbnails in Edit Song if not square
+- chore: Added Upgrading wiki page
+- feat: Configurable MongoDB container image version
 
 ### Changed
 - refactor: Replaced night mode toggle slider in Main Header with day/night icons
@@ -51,6 +51,7 @@ Please run the Update All Songs job after upgrading to ensure playlist and stati
 - refactor: Set title and thumbnail on YouTube video selection in Create Song
 - refactor: Show YouTube tab by default in Create Song
 - refactor: Move admin tab routing to vue router
+- refactor: Pull images in musare.sh build command
 
 ### Fixed
 - fix: Relative homepage header height causing overlay of content on non-standard resolutions

+ 2 - 1
README.md

@@ -4,12 +4,13 @@
 
 Musare is an open-source collaborative music listening and catalogue curation application. Currently supporting YouTube based content.
 
-A demonstration instance of Musare can be found at [demo.musare.com](https://demo.musare.com).
+A production demonstration instance of Musare can be found at [demo.musare.com](https://demo.musare.com).
 
 ---
 
 ## Documentation
 - [Installation](./.wiki/Installation.md)
+- [Upgrading](./.wiki/Upgrading.md)
 - [Configuration](./.wiki/Configuration.md)
 - [Utility Script](./.wiki/Utility_Script.md)
 - [Backend Commands](./.wiki/Backend_Commands.md)

+ 1 - 1
backend/package-lock.json

@@ -1,6 +1,6 @@
 {
   "name": "musare-backend",
-  "version": "3.4.0",
+  "version": "3.4.0-rc1",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {

+ 1 - 1
backend/package.json

@@ -1,7 +1,7 @@
 {
   "name": "musare-backend",
   "private": true,
-  "version": "3.4.0",
+  "version": "3.4.0-rc1",
   "type": "module",
   "description": "An open-source collaborative music listening and catalogue curation application. Currently supporting YouTube based content.",
   "main": "index.js",

+ 1 - 1
docker-compose.yml

@@ -31,7 +31,7 @@ services:
       - backend
 
   mongo:
-    image: mongo:5.0
+    image: mongo:${MONGO_VERSION}
     restart: ${RESTART_POLICY}
     ports:
       - "${MONGO_HOST}:${MONGO_PORT}:${MONGO_PORT}"

+ 1 - 1
frontend/package-lock.json

@@ -1,6 +1,6 @@
 {
   "name": "musare-frontend",
-  "version": "3.4.0",
+  "version": "3.4.0-rc1",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {

+ 1 - 1
frontend/package.json

@@ -5,7 +5,7 @@
     "*.vue"
   ],
   "private": true,
-  "version": "3.4.0",
+  "version": "3.4.0-rc1",
   "description": "An open-source collaborative music listening and catalogue curation application. Currently supporting YouTube based content.",
   "main": "main.js",
   "author": "Musare Team",

+ 19 - 4
frontend/src/pages/Admin/index.vue

@@ -8,7 +8,10 @@
 					:class="{ minimised: !sidebarActive }"
 				>
 					<div class="inner">
-						<div class="bottom">
+						<div
+							class="bottom"
+							:style="`padding-bottom: ${sidebarPadding}px`"
+						>
 							<div
 								class="sidebar-item toggle-sidebar"
 								@click="toggleSidebar()"
@@ -260,7 +263,8 @@ export default {
 				logo: "",
 				sitename: ""
 			},
-			sidebarActive: true
+			sidebarActive: true,
+			sidebarPadding: 0
 		};
 	},
 	computed: {
@@ -293,6 +297,9 @@ export default {
 		if (this.sidebarActive === null)
 			this.sidebarActive = !(document.body.clientWidth <= 768);
 
+		this.calculateSidebarPadding();
+		window.addEventListener("scroll", this.calculateSidebarPadding);
+
 		keyboardShortcuts.registerShortcut(
 			"admin.toggleKeyboardShortcutsHelper",
 			{
@@ -321,6 +328,8 @@ export default {
 	beforeUnmount() {
 		this.socket.dispatch("apis.leaveRooms");
 
+		window.removeEventListener("scroll", this.calculateSidebarPadding);
+
 		const shortcutNames = [
 			"admin.toggleKeyboardShortcutsHelper",
 			"admin.resetKeyboardShortcutsHelper"
@@ -365,6 +374,12 @@ export default {
 				? localPath.substr(7, localPath.length)
 				: null;
 		},
+		calculateSidebarPadding() {
+			const scrollTop =
+				document.documentElement.scrollTop || document.scrollTop || 0;
+			if (scrollTop <= 64) this.sidebarPadding = 64 - scrollTop;
+			else this.sidebarPadding = 0;
+		},
 		...mapActions("admin", ["toggleChildren"])
 	}
 };
@@ -435,8 +450,8 @@ export default {
 
 				.bottom {
 					overflow-y: auto;
-					height: calc(100vh - 64px);
-					max-height: calc(100vh - 64px);
+					height: 100%;
+					max-height: 100%;
 					display: flex;
 					flex-direction: column;
 					flex: 1 0 auto;

+ 64 - 34
musare.sh

@@ -40,7 +40,7 @@ handleServices()
 
 dockerCommand()
 {
-    validCommands=(start stop restart build ps)
+    validCommands=(start stop restart pull build ps)
     if [[ ${validCommands[*]} =~ (^|[[:space:]])"$2"($|[[:space:]]) ]]; then
         servicesString=$(handleServices "${@:3}")
         if [[ ${servicesString:0:1} == 1 ]]; then
@@ -57,7 +57,7 @@ dockerCommand()
                 # shellcheck disable=SC2086
                 docker-compose up -d ${servicesString}
             fi
-            if [[ ${2} == "build" || ${2} == "ps" ]]; then
+            if [[ ${2} == "pull" || ${2} == "build" || ${2} == "ps" ]]; then
                 # shellcheck disable=SC2086
                 docker-compose "${2}" ${servicesString}
             fi
@@ -92,6 +92,8 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
     build)
         echo -e "${CYAN}Musare | Build Services${NC}"
         # shellcheck disable=SC2068
+        dockerCommand "$(basename "$0")" pull ${@:2}
+        # shellcheck disable=SC2068
         dockerCommand "$(basename "$0")" build ${@:2}
         ;;
 
@@ -103,41 +105,55 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
 
     reset)
         echo -e "${CYAN}Musare | Reset Services${NC}"
-        servicesString=$(handleServices "${@:2}")
-        if [[ ${servicesString:0:1} == 1 && ${servicesString:2:4} == "all" ]]; then
-            echo -e "${GREEN}Are you sure you want to reset all data? ${YELLOW}[y,n]: ${NC}"
-            read -r confirm
-            if [[ "${confirm}" == y* ]]; then
-                docker-compose stop
-                docker-compose rm -v --force
-                if [[ -d ".redis" ]]; then
-                    rm -rf .redis
+        if [[ -f .env ]]; then
+            # shellcheck disable=SC1091
+            source .env
+            servicesString=$(handleServices "${@:2}")
+            if [[ ${servicesString:0:1} == 1 && ${servicesString:2:4} == "all" ]]; then
+                echo -e "${RED}Resetting will remove the ${REDIS_DATA_LOCATION} and ${MONGO_DATA_LOCATION} directories.${NC}"
+                echo -e "${GREEN}Are you sure you want to reset all data? ${YELLOW}[y,n]: ${NC}"
+                read -r confirm
+                if [[ "${confirm}" == y* ]]; then
+                    docker-compose stop
+                    docker-compose rm -v --force
+                    if [[ -d $REDIS_DATA_LOCATION ]]; then
+                        rm -rf $REDIS_DATA_LOCATION
+                    fi
+                    if [[ -d $MONGO_DATA_LOCATION ]]; then
+                        rm -rf $MONGO_DATA_LOCATION
+                    fi
+                else
+                    echo -e "${RED}Cancelled reset${NC}"
                 fi
-                if [[ -d ".db" ]]; then
-                    rm -rf .db
+            elif [[ ${servicesString:0:1} == 1 ]]; then
+                if [[ "${servicesString:2}" == *redis* && "${servicesString:2}" == *mongo* ]]; then
+                    echo -e "${RED}Resetting will remove the ${REDIS_DATA_LOCATION} and ${MONGO_DATA_LOCATION} directories.${NC}"
+                elif [[ "${servicesString:2}" == *redis* ]]; then
+                    echo -e "${RED}Resetting will remove the ${REDIS_DATA_LOCATION} directory.${NC}"
+                elif [[ "${servicesString:2}" == *mongo* ]]; then
+                    echo -e "${RED}Resetting will remove the ${MONGO_DATA_LOCATION} directory.${NC}"
                 fi
-            else
-                echo -e "${RED}Cancelled reset${NC}"
-            fi
-        elif [[ ${servicesString:0:1} == 1 ]]; then
-            echo -e "${GREEN}Are you sure you want to reset all data for $(echo "${servicesString:2}" | tr ' ' ',')? ${YELLOW}[y,n]: ${NC}"
-            read -r confirm
-            if [[ "${confirm}" == y* ]]; then
-                # shellcheck disable=SC2086
-                docker-compose stop ${servicesString:2}
-                # shellcheck disable=SC2086
-                docker-compose rm -v --force ${servicesString:2}
-                if [[ "${servicesString:2}" == *redis* && -d ".redis" ]]; then
-                    rm -rf .redis
-                fi
-                if [[ "${servicesString:2}" == *mongo* && -d ".db" ]]; then
-                    rm -rf .db
+                echo -e "${GREEN}Are you sure you want to reset all data for $(echo "${servicesString:2}" | tr ' ' ',')? ${YELLOW}[y,n]: ${NC}"
+                read -r confirm
+                if [[ "${confirm}" == y* ]]; then
+                    # shellcheck disable=SC2086
+                    docker-compose stop ${servicesString:2}
+                    # shellcheck disable=SC2086
+                    docker-compose rm -v --force ${servicesString:2}
+                    if [[ "${servicesString:2}" == *redis* && -d $REDIS_DATA_LOCATION ]]; then
+                        rm -rf $REDIS_DATA_LOCATION
+                    fi
+                    if [[ "${servicesString:2}" == *mongo* && -d $MONGO_DATA_LOCATION ]]; then
+                        rm -rf $MONGO_DATA_LOCATION
+                    fi
+                else
+                    echo -e "${RED}Cancelled reset${NC}"
                 fi
             else
-                echo -e "${RED}Cancelled reset${NC}"
+                echo -e "${RED}${servicesString:2}\n${YELLOW}Usage: $(basename "$0") build [backend, frontend, mongo, redis]${NC}"
             fi
         else
-            echo -e "${RED}${servicesString:2}\n${YELLOW}Usage: $(basename "$0") build [backend, frontend, mongo, redis]${NC}"
+            echo -e "${RED}Error: .env does not exist${NC}"
         fi
         ;;
 
@@ -155,11 +171,16 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
             if [[ -f .env ]]; then
                 # shellcheck disable=SC1091
                 source .env
+                MONGO_VERSION_INT=${MONGO_VERSION:0:1}
                 if [[ -z $(docker-compose ps -q mongo) ]]; then
                     echo -e "${RED}Error: Mongo offline, please start to attach.${NC}"
                 else
                     echo -e "${YELLOW}Detach with CTRL+C${NC}"
-                    docker-compose exec mongo mongosh musare -u "${MONGO_USER_USERNAME}" -p "${MONGO_USER_PASSWORD}" --eval "disableTelemetry()" --shell
+                    if [[ $MONGO_VERSION_INT -ge 5 ]]; then
+                        docker-compose exec mongo mongosh musare -u "${MONGO_USER_USERNAME}" -p "${MONGO_USER_PASSWORD}" --eval "disableTelemetry()" --shell
+                    else
+                        docker-compose exec mongo mongo musare -u "${MONGO_USER_USERNAME}" -p "${MONGO_USER_PASSWORD}"
+                    fi
                 fi
             else
                 echo -e "${RED}Error: .env does not exist${NC}"
@@ -285,6 +306,7 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
         if [[ -f .env ]]; then
             # shellcheck disable=SC1091
             source .env
+            MONGO_VERSION_INT=${MONGO_VERSION:0:1}
             if [[ $2 == "add" ]]; then
                 if [[ -z $3 ]]; then
                     echo -e "${GREEN}Please enter the username of the user you wish to make an admin: ${NC}"
@@ -295,7 +317,11 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
                 if [[ -z $adminUser ]]; then
                     echo -e "${RED}Error: Username for new admin not provided.${NC}"
                 else
-                    docker-compose exec mongo mongosh musare -u "${MONGO_USER_USERNAME}" -p "${MONGO_USER_PASSWORD}" --eval "disableTelemetry(); db.users.updateOne({username: '${adminUser}'}, {\$set: {role: 'admin'}})"
+                    if [[ $MONGO_VERSION_INT -ge 5 ]]; then
+                        docker-compose exec mongo mongosh musare -u "${MONGO_USER_USERNAME}" -p "${MONGO_USER_PASSWORD}" --eval "disableTelemetry(); db.users.updateOne({username: '${adminUser}'}, {\$set: {role: 'admin'}})"
+                    else
+                        docker-compose exec mongo mongo musare -u "${MONGO_USER_USERNAME}" -p "${MONGO_USER_PASSWORD}" --eval "db.users.updateOne({username: '${adminUser}'}, {\$set: {role: 'admin'}})"
+                    fi
                 fi
             elif [[ $2 == "remove" ]]; then
                 if [[ -z $3 ]]; then
@@ -307,7 +333,11 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
                 if [[ -z $adminUser ]]; then
                     echo -e "${RED}Error: Username for new admin not provided.${NC}"
                 else
-                    docker-compose exec mongo mongosh musare -u "${MONGO_USER_USERNAME}" -p "${MONGO_USER_PASSWORD}" --eval "disableTelemetry(); db.users.updateOne({username: '${adminUser}'}, {\$set: {role: 'default'}})"
+                    if [[ $MONGO_VERSION_INT -ge 5 ]]; then
+                        docker-compose exec mongo mongosh musare -u "${MONGO_USER_USERNAME}" -p "${MONGO_USER_PASSWORD}" --eval "disableTelemetry(); db.users.updateOne({username: '${adminUser}'}, {\$set: {role: 'default'}})"
+                    else
+                        docker-compose exec mongo mongo musare -u "${MONGO_USER_USERNAME}" -p "${MONGO_USER_PASSWORD}" --eval "db.users.updateOne({username: '${adminUser}'}, {\$set: {role: 'default'}})"
+                    fi
                 fi
             else
                 echo -e "${RED}Invalid command $2\n${YELLOW}Usage: $(basename "$0") admin [add,remove] username${NC}"

+ 16 - 6
tools/docker/setup-mongo.sh

@@ -1,8 +1,18 @@
 #!/bin/bash
 
-mongosh musare \
-        --port 27017 \
-        -u "admin" \
-        --authenticationDatabase "admin" \
-        -p ${MONGO_ROOT_PASSWORD} \
-        --eval "disableTelemetry(); db.createUser({ user: '${MONGO_USER_USERNAME}', pwd: '${MONGO_USER_PASSWORD}', roles:[ { role:'readWrite', db: 'musare' } ] } );"
+MONGO_VERSION_INT=${MONGO_VERSION:0:1}
+if [[ $MONGO_VERSION_INT -ge 5 ]]; then
+        mongosh musare \
+                --port 27017 \
+                -u "admin" \
+                --authenticationDatabase "admin" \
+                -p ${MONGO_ROOT_PASSWORD} \
+                --eval "disableTelemetry(); db.createUser({ user: '${MONGO_USER_USERNAME}', pwd: '${MONGO_USER_PASSWORD}', roles:[ { role:'readWrite', db: 'musare' } ] } );"
+else
+        mongo musare \
+                --port 27017 \
+                -u "admin" \
+                --authenticationDatabase "admin" \
+                -p ${MONGO_ROOT_PASSWORD} \
+                --eval "db.createUser({ user: '${MONGO_USER_USERNAME}', pwd: '${MONGO_USER_PASSWORD}', roles:[ { role:'readWrite', db: 'musare' } ] } );"
+fi