feat(docker): add MongoDB and improve setup instructions (#82)

* feat(docker): add MongoDB and improve setup instructions

* fix: reduce docker image size and other minor improvements

* fix: reduce docker image size and other minor improvements

* docs: update README for correct env file naming

* feat(docker): add environment variables and enhance Docker instructions

* docs: update README structure and enhance installation instructions

* docs: update README to clarify requirements for Docker and non-Docker setups

* docs: update README to improve Docker instructions and formatting

* docs: update code blocks in README to use shell syntax highlighting

* docs: refine installation steps and environment variable instructions

* docs: enhance README formatting for Docker instructions

* docs: correct formatting for environment variable examples in README

* docs: enhance README with badges and improved formatting

* docs: improve Docker instructions and formatting in README

* docs: update README to use figure elements for image captions

* docs: update README to replace figure elements with markdown images

* docs: update README to use shell syntax highlighting for code blocks

* docs: fix typo in README for environment file renaming step
This commit is contained in:
Ayush Sehrawat
2025-03-02 03:57:32 +05:30
committed by GitHub
parent fc48827338
commit b82c3665a1
9 changed files with 226 additions and 150 deletions
+2 -1
View File
@@ -2,7 +2,8 @@
DOCKER=true
# MongoDB URL: Connection string for your MongoDB database
MONGODB_URL=mongodb://127.0.0.1:27017/mydrive
# Note: if using the compose file provided, the connection string should be as follows:
MONGODB_URL=mongodb://username:password@mongo:27017/mydrive?authSource=admin
# Database Type: Choose between "fs" and "s3", this specifies where the files will be stored.
# fs = Filesystem
+19 -10
View File
@@ -1,23 +1,32 @@
FROM node:20-alpine
FROM node:20-alpine AS builder
RUN apk add --no-cache python3 make g++ ffmpeg \
&& ln -sf python3 /usr/bin/python
ENV FS_DIRECTORY=/data/
ENV TEMP_DIRECTORY=/temp/
# Install build dependencies
RUN apk add --no-cache python3 make g++ ffmpeg && \
ln -sf python3 /usr/bin/python
WORKDIR /usr/app-production
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# Default Ports
# Remove dev dependencies
RUN npm prune --production
FROM node:20-alpine
ENV FS_DIRECTORY=/data/
ENV TEMP_DIRECTORY=/temp/
# Install runtime dependencies
RUN apk add --no-cache ffmpeg
WORKDIR /usr/app-production
COPY --from=builder /usr/app-production .
EXPOSE 8080
EXPOSE 3000
CMD [ "npm", "run", "start"]
CMD ["npm", "run", "start"]
+81 -64
View File
@@ -1,19 +1,30 @@
# ![MyDrive Homepage](https://github.com/subnub/myDrive/blob/master/github_images/homepage.png?raw=true)
# ☁️ MyDrive
MyDrive is an Open Source cloud file storage server (Similar To Google Drive). Host myDrive on your own server or trusted platform and then access myDrive through your web browser. MyDrive uses mongoDB to store file/folder metadata, and supports multiple databases to store the file chunks, such as Amazon S3, or the Filesystem.
<div align="center">
<a href="https://github.com/subnub/myDrive/stargazers"><img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/subnub/myDrive?label=myDrive"></a>
<a href="https://github.com/subnub/myDrive/issues"><img alt="Issues" src="https://img.shields.io/github/issues/subnub/myDrive" /></a>
<a href="https://github.com/subnub/myDrive/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/subnub/myDrive"></a>
<a href="https://github.com/subnub/myDrive/graphs/contributors"><img alt="Contributors" src="https://img.shields.io/github/contributors/subnub/myDrive" /></a>
</div>
[Main myDrive website](https://mydrive-storage.com/)
<div align="center">
<h1>☁️ MyDrive</h1>
<strong>Open Source cloud file storage server (Similar To Google Drive)</strong>
<p>Host myDrive on your own server or trusted platform and then access myDrive through your web browser. MyDrive uses mongoDB to store file/folder metadata, and supports multiple databases to store the file chunks, such as Amazon S3, or the Filesystem.</p>
[Live demo](http://143.244.181.219:3000/)
<a href="https://mydrive-storage.com/">Website</a>
<span> | </span>
<a href="http://143.244.181.219:3000/">Live demo</a>
</div>
## 🔍 Index
- [Features](#features)
- [Tech stack](#tech-stack)
- [Docker image](#docker)
- [Manual installation](#installation)
- [Running](#running)
- [Docker](#docker)
- [Non-Docker](#non-docker)
- [Common installation issues](#common-installation-issues)
- [Screenshots](#screenshots)
- [Video](#video)
@@ -54,40 +65,58 @@ MyDrive is an Open Source cloud file storage server (Similar To Google Drive). H
- Vite
- Jest
<span id="running"></span>
## Running
<span id="docker"></span>
## 🐳 Docker image
### 🐳 Docker
Required:
> [!IMPORTANT]
> Requirements
> - Docker
> - MongoDB (optional, comes with `docker-compose.yml`)
- Docker
- MongoDB (Unless using a service like Atlas)
<br/>
#### **Docker Compose**
Run the following command to download the latest docker image:
1. Make folder for docker-compose.yml and env file.
2. Copy [`docker-compose.yml`](./docker-compose.yml) and [`.env.example`](./.env.example) to your directory.
3. Rename `.env.example` to `.env` and fill in / change the values.
4. Run the following command:
```javascript
```sh
docker compose up -d
```
5. Access the app at `http://localhost:3000`
---
#### **Docker Run**
1. Pull the image
```sh
docker pull kylehoell/mydrive:latest
```
You must provide enviroment variables for the docker image to work. You can supply these during the docker run command instead of creating the env file. <br />
2. Run the image
> [backend/config](backend/config) -> Backend Enviroment Variables
Using `.env` file. Copy the `.env.example` file and fill in the values.
You must also provide a volume for the image if you are using a filesystem database or if you want to use the generate video thumbnails feature. Volumes should be mounted to /data/ and /temp/ For example:
```javascript
-v /path/example/mydrive/data/:/data/ -v /path/example/mydrive/temp/:/temp/
```sh
docker run -d \
-p 3000:3000 \
--env-file ./.env \
-v /path/example/mydrive/data/:/data/ \
-v /path/example/mydrive/temp/:/temp/ \
--name mydrive \
kylehoell/mydrive:latest
```
/data/: This is where the encrypted files will be stored.
/temp/: Where files will temporary be stored to generate video thumbnails as a fallback.
Or directly pass in the environment variables
The docker image will by default run on port 3000.
Here is an example of the full docker command:
```bash
```sh
docker run -d \
-p 3000:3000 \
-e MONGODB_URL=mongodb://127.0.0.1:27017/mydrive \
@@ -104,51 +133,43 @@ docker run -d \
kylehoell/mydrive:latest
```
<span id="installation"></span>
3. Access the app at `http://localhost:3000`
## 💻 Manual Installation
<span id="non-docker"></span>
Required:
### 💻 Non - Docker
- Node.js (20 Recommended)
- MongoDB (Unless using a service like Atlas)
- FFMPEG (Optional, used for video thumbnails)
- build-essential package (If using linux)
> [!IMPORTANT]
> Requirements
> - Node.js (20 Recommended)
> - MongoDB (Unless using a service like Atlas)
> - FFMPEG (Optional, used for video thumbnails)
> - build-essential package (If using linux)
<br/>
1. Install dependencies
Setup (Non Docker Method):
> Install Node Modules
```javascript
```sh
npm install
```
<br>
2. Create Environment Variables
> Create Environment Variables:
You can find enviroment variable examples under: <br />
[`backend/config`](backend/config) -> Backend Enviroment Variables
[`src/config`](src/config) -> Frontend Enviroment Variables
> You can find enviroment variable examples under: <br />
> [backend/config](backend/config) -> Backend Enviroment Variables
> [src/config](src/config) -> Frontend Enviroment Variables
> Simply remove the .example from the end of the filename, and fill in the values.
Simply remove the .example from the end of the filename, and fill in the values.
> Note: In most cases you will only have to change FE enviroment variables for development purposes.
<br />
3. Run the build command
> Run the build command
```javascript
```sh
npm run build
```
<br />
4. Start the server
> Start the server
```javascript
```sh
npm run start
```
@@ -158,27 +179,25 @@ npm run start
Make issue
```javascript
```sh
npm error gyp ERR! stack Error: not found: make
```
This is because you do not have the build essentials installed which is required for Linux. You can install them by running the following command:
```javascript
```sh
sudo apt-get install build-essential
```
<br/>
Memory issue
```javascript
```sh
Aborted (core dumped)
```
When running the `npm run build` command it may take more memory than node allows by default. You will get the above error in such a case. To fix this, you can run the following command instead when building:
```javascript
```sh
NODE_OPTIONS="--max-old-space-size=4096" npm run build
```
@@ -263,14 +282,14 @@ If you are upgrading from myDrive 3 there is some data migration and scripts you
> Run the migration script <br />
> Note: Make sure you have env variables set
```javascript
```sh
npm run migrate-to-mydrive4
```
Also, if you are updating from myDrive 3, or if you did not have video thumbnails enabled and would like to enable them now you can do so by running the following command:<br />
Note: Make sure you have video thumbnails enabled in your env variables and FFMPEG installed.
```javascript
```sh
npm run create-video-thumbnails
```
@@ -280,7 +299,6 @@ npm run create-video-thumbnails
#### Issues
- The docker compose command is currently setup incorrectly since it requires npm to be installed, I am working on a fix for this. (Top priority)
- Video streaming does not always work, especially on Safari.
- PWA downloads does not work on iOS (This may be a current iOS limitation and not a myDrive issue).
- Upload folder will sometimes fail on complex folder structures.
@@ -288,7 +306,6 @@ npm run create-video-thumbnails
#### Future improvments
- Docker image (Top priority)
- OIDC Support (Top priority)
- Option to disable encryption
- File sync from a local device
-3
View File
@@ -1,9 +1,6 @@
# Either remove the .example from the end of this filename.
# Or create a new file with the same name, but without the .example extension.
# NOTE: If you are using docker, you should provide these env variables during the docker run command instead.
# But you can still use this file as a guide.
# MongoDB URL: Connection string for your MongoDB database
# example: mongodb://localhost:27017/mydrive
MONGODB_URL=
-3
View File
@@ -1,9 +1,6 @@
# Either remove the .example from the end of this filename.
# Or create a new file with the same name, but without the .example extension.
# NOTE: If you are using docker, you should provide these env variables during the docker run command instead.
# But you can still use this file as a guide.
# MongoDB URL: Connection string for your MongoDB database
# example: mongodb://localhost:27017/mydrive
MONGODB_URL=
-3
View File
@@ -1,9 +1,6 @@
# Either remove the .example from the end of this filename.
# Or create a new file with the same name, but without the .example extension.
# NOTE: If you are using docker, you should provide these env variables during the docker run command instead.
# But you can still use this file as a guide.
# MongoDB URL: Connection string for your MongoDB database
# example: mongodb://localhost:27017/mydrive
MONGODB_URL=
+44 -20
View File
@@ -1,25 +1,49 @@
version: "3.8"
services:
app:
build:
context: .
dockerfile: Dockerfile
container_name: mydrive
volumes:
# Use the following volumes section if you want to use bind mounts:
# - /path/to/data:/data/
# - /path/to/temp:/temp/
app:
build:
context: .
dockerfile: Dockerfile
container_name: mydrive
volumes:
# Use the following volumes section if you want to use bind mounts:
# - /path/to/data:/data/
# - /path/to/temp:/temp/
# Use the following volumes section if you want to use named volumes:
- mydrive-data:/data/
- mydrive-temp:/temp/
ports:
- "${HTTP_PORT:-3000}:3000"
- "${HTTPS_PORT:-8080}:8080"
env_file:
- .env.test # Copy .env.example to .env.test or .env and fill in the values
# Use the following volumes section if you want to use named volumes:
- mydrive-data:/data/
- mydrive-temp:/temp/
ports:
- "${HTTP_PORT:-3000}:3000"
# Optional: Uncomment the following line if you want to use HTTPS
# - "${HTTPS_PORT:-8080}:8080"
# Use expose: if using a reverse proxy
# expose:
# - 3000
# - 8080
env_file:
- .env.test # Copy .env.example to .env.test or .env and fill in the values
mongo:
image: mongo:8
container_name: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: username
MONGO_INITDB_ROOT_PASSWORD: password
expose:
- 27017
volumes:
- db-data:/data/db
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
timeout: 10s
interval: 10s
retries: 10
start_period: 10s
# Use the following volumes section if you want to use named volumes. Useful for development.
volumes:
mydrive-data:
mydrive-temp:
mydrive-data:
mydrive-temp:
db-data:
+46 -12
View File
@@ -1,13 +1,47 @@
version: "3.8"
services:
app:
container_name: mydrive
image: kylehoell/mydrive:latest
volumes:
- /path/to/data:/data/
- /path/to/temp:/temp/
ports:
- "${HTTP_PORT:-3000}:3000"
- "${HTTPS_PORT:-8080}:8080"
env_file:
- .env # Copy .env.example to .env and fill in the values
app:
container_name: mydrive
image: kylehoell/mydrive:latest
volumes:
# Use the following volumes section if you want to use bind mounts:
# - /path/to/data:/data/
# - /path/to/temp:/temp/
# Use the following volumes section if you want to use named volumes:
- mydrive-data:/data/
- mydrive-temp:/temp/
ports:
- "${HTTP_PORT:-3000}:3000"
# Optional: Uncomment the following line if you want to use HTTPS
#- "${HTTPS_PORT:-8080}:8080"
# Use expose: if using a reverse proxy
# expose:
# - 3000
# - 8080
env_file:
- .env # Copy .env.example to .env and fill in the values
mongo:
image: mongo:8
container_name: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: username
MONGO_INITDB_ROOT_PASSWORD: password
expose:
- 27017
volumes:
- db-data:/data/db
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
timeout: 10s
interval: 10s
retries: 10
start_period: 10s
# Use the following volumes section if you want to use named volumes.
volumes:
mydrive-data:
mydrive-temp:
db-data:
+34 -34
View File
@@ -4,7 +4,7 @@
"main": "index.js",
"license": "GNU General Public License v3.0",
"engines": {
"node": "20.14.0"
"node": ">=20.14.0"
},
"scripts": {
"dev": "concurrently \"vite\" \"tsc -w -p ./backend/tsconfig.json\" \"npm run dev:backend\"",
@@ -21,37 +21,11 @@
"test": "NODE_ENV=test jest"
},
"dependencies": {
"@babel/core": "^7.8.4",
"@babel/parser": "^7.9.4",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.8.4",
"@babel/preset-react": "^7.8.3",
"@babel/types": "^7.9.5",
"@reduxjs/toolkit": "^2.2.5",
"@types/compression": "^1.7.0",
"@types/concat-stream": "^1.6.0",
"@types/connect-busboy": "0.0.2",
"@types/cookie-parser": "^1.4.2",
"@types/express": "^4.17.21",
"@types/helmet": "0.0.45",
"@types/jsonwebtoken": "^8.3.9",
"@types/node": "^20.14.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/request": "^2.48.5",
"@types/request-ip": "0.0.35",
"@types/sharp": "^0.25.0",
"@types/uuid": "^7.0.2",
"@types/validator": "^13.0.0",
"@vitejs/plugin-react": "^4.3.0",
"archiver": "^7.0.1",
"async": "^3.2.6",
"autoprefixer": "^10.4.19",
"aws-sdk": "^2.657.0",
"axios": "^1.7.2",
"babel-polyfill": "^6.26.0",
"bcryptjs": "^3.0.2",
"body-parser": "^1.20.2",
"bytes": "^3.1.0",
@@ -67,7 +41,6 @@
"dayjs": "^1.11.13",
"diskusage": "^1.1.3",
"dotenv": "^8.2.0",
"eslint-plugin-react-hooks": "^4.6.2",
"express": "^4.19.2",
"express-validator": "^7.1.0",
"fluent-ffmpeg": "^2.1.3",
@@ -76,12 +49,10 @@
"jsonwebtoken": "^9.0.2",
"lodash.debounce": "^4.0.8",
"mongodb": "^6.7.0",
"mongodb-memory-server": "^10.1.3",
"mongoose": "^8.4.1",
"nodemailer": "^6.9.14",
"normalize.css": "^8.0.1",
"password-prompt": "^1.1.2",
"postcss": "^8.4.38",
"progress-stream": "^2.0.0",
"prompts": "^2.4.2",
"raf": "^3.4.1",
@@ -95,41 +66,70 @@
"redux": "^5.0.1",
"regenerator-runtime": "^0.13.3",
"sharp": "^0.33.4",
"supertest-session": "^4.1.0",
"sweetalert2": "^11.15.10",
"temp": "^0.9.1",
"typescript": "^5.4.5",
"uuid": "^3.4.0",
"validator": "^13.12.0",
"vite": "^5.2.13"
"validator": "^13.12.0"
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/parser": "^7.9.4",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.8.4",
"@babel/preset-react": "^7.8.3",
"@babel/types": "^7.9.5",
"@eslint/js": "^9.6.0",
"@types/archiver": "^6.0.3",
"@types/async": "^3.2.24",
"@types/bytes": "^3.1.4",
"@types/compression": "^1.7.0",
"@types/concat-stream": "^1.6.0",
"@types/connect-busboy": "0.0.2",
"@types/cookie-parser": "^1.4.2",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/fluent-ffmpeg": "^2.1.24",
"@types/helmet": "0.0.45",
"@types/jest": "^29.5.14",
"@types/jsonwebtoken": "^8.3.9",
"@types/lodash": "^4.17.5",
"@types/node": "^20.14.2",
"@types/nodemailer": "^6.4.15",
"@types/prompts": "^2.4.9",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/request": "^2.48.5",
"@types/request-ip": "0.0.35",
"@types/sharp": "^0.25.0",
"@types/supertest": "^6.0.2",
"@types/uuid": "^7.0.2",
"@types/validator": "^13.0.0",
"@vitejs/plugin-react": "^4.3.0",
"autoprefixer": "^10.4.19",
"babel-polyfill": "^6.26.0",
"concurrently": "^8.2.2",
"cross-env": "^6.0.3",
"dart-sass": "^1.25.0",
"env-cmd": "^10.1.0",
"eslint": "^8.57.0",
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-react-hooks": "^4.6.2",
"globals": "^15.7.0",
"jest": "^29.7.0",
"mongodb-memory-server": "^10.1.3",
"nodemon": "^3.1.3",
"postcss": "^8.4.38",
"rollup-plugin-visualizer": "^5.14.0",
"sass": "^1.77.4",
"superagent-binary-parser": "^1.0.1",
"supertest": "^6.3.4",
"supertest-session": "^4.1.0",
"tailwindcss": "^3.4.4",
"typescript": "^5.4.5",
"typescript-eslint": "^7.14.1",
"vite": "^5.2.13",
"vite-plugin-pwa": "^0.21.1"
}
}