diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..9b568bfc --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,32 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile +{ + "name": "Existing Dockerfile", + "build": { + // Sets the run context to one level up instead of the .devcontainer folder. + "context": "..", + // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. + "dockerfile": "../Dockerfile" + }, + "features": { + "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, + "ghcr.io/devcontainers/features/git-lfs:1": {}, + "ghcr.io/devcontainers/features/github-cli:1": {}, + "ghcr.io/devcontainers/features/node:1": {} + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Uncomment the next line to run commands after the container is created. + // "postCreateCommand": "cat /etc/os-release", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "devcontainer" +} diff --git a/.dockerignore b/.dockerignore index db1431af..809ba837 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,23 +1,24 @@ -.git/ -.gitignore -.dockerignore -docker-compose* -Dockerfile -makefile -htmlcov/ -coverage.xml -.coverage* - -.vscode/ -*.dat - -.DS_Store -node_modules -/build -/package -.env -.env.* -!.env.example -vite.config.js.timestamp-* -vite.config.ts.timestamp-* -.idea \ No newline at end of file +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..f33a02cd --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for more information: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://containers.dev/guide/dependabot + +version: 2 +updates: + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..4f20d93d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,63 @@ +{ + "configurations": [ + { + "name": "Attach to Chrome", + "port": 9222, + "request": "attach", + "type": "chrome", + "webRoot": "+-" + }, + { + "name": "Attach", + "port": 9229, + "request": "attach", + "skipFiles": [ + "/**" + ], + "type": "node" + }, + { + "name": "Docker Node.js Launch", + "type": "docker", + "request": "launch", + "preLaunchTask": "docker-run: debug", + "platform": "node" + }, + { + "name": "Python Debugger: Current File with Arguments", + "type": "debugpy", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal", + "args": "${command:pickArgs}" + }, + { + "name": "Python Debugger: Current File", + "type": "debugpy", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal" + }, + { + "name": "Python Debugger: Module", + "type": "debugpy", + "request": "launch", + "module": "${input:moduleName}", + "console": "integratedTerminal" + }, + { + "name": "Python Debugger: Django", + "type": "debugpy", + "request": "launch", + "module": "${input:moduleName}", + "console": "integratedTerminal" + }, + { + "name": "Containers: Node.js Launch", + "type": "docker", + "request": "launch", + "preLaunchTask": "docker-run: debug", + "platform": "node" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..9b388533 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.testing.pytestArgs": [ + "tests" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..d416da54 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,39 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "docker-build", + "label": "docker-build", + "platform": "node", + "dockerBuild": { + "dockerfile": "${workspaceFolder}/Dockerfile", + "context": "${workspaceFolder}", + "pull": true + } + }, + { + "type": "docker-run", + "label": "docker-run: release", + "dependsOn": [ + "docker-build" + ], + "platform": "node" + }, + { + "type": "docker-run", + "label": "docker-run: debug", + "dependsOn": [ + "docker-build" + ], + "dockerRun": { + "env": { + "DEBUG": "*", + "NODE_ENV": "development" + } + }, + "node": { + "enableDebugging": true + } + } + ] +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 100a68a2..f49af45e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [4.1.0](https://github.com/subnub/myDrive/compare/v4.0.2...v4.1.0) (2025-03-09) + + +### Features + +* Add block account creation ([#80](https://github.com/subnub/myDrive/issues/80)) ([fc48827](https://github.com/subnub/myDrive/commit/fc48827338c3eb5632249e34dcc1f5b8d1c61031)) +* **docker:** add MongoDB and improve setup instructions ([#82](https://github.com/subnub/myDrive/issues/82)) ([b82c366](https://github.com/subnub/myDrive/commit/b82c3665a1fb72964237b154facb29b0ea891768)) + + +### Bug Fixes + +* removed unneeded package that was also causing build issues ([ceb0866](https://github.com/subnub/myDrive/commit/ceb08661740de7690df525d9f1ee55d767032eeb)) + ## 4.0.2 (2025-03-01) diff --git a/Dockerfile b/Dockerfile index 02a7baa3..9d802ffd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,8 @@ -FROM node:20-alpine AS builder - -# 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 - +FROM node:lts-alpine +ENV NODE_ENV=production +WORKDIR /usr/src/app +COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"] +RUN npm install --production --silent COPY . . RUN npm run build @@ -28,5 +22,5 @@ COPY --from=builder /usr/app-production . EXPOSE 8080 EXPOSE 3000 - -CMD ["npm", "run", "start"] +USER node +CMD ["npm", "start"] diff --git a/docker-compose.debug.yml b/docker-compose.debug.yml new file mode 100644 index 00000000..94a0f003 --- /dev/null +++ b/docker-compose.debug.yml @@ -0,0 +1,12 @@ +services: + mydrive: + image: mydrive + build: + context: . + dockerfile: ./Dockerfile + environment: + NODE_ENV: development + ports: + - 3000:3000 + - 9229:9229 + command: ["node", "--inspect=0.0.0.0:9229", "index.js"] diff --git a/docker-compose.yml b/docker-compose.yml index 170ab3cc..ebcdde32 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,47 +1,10 @@ services: - 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: + mydrive: + image: mydrive + build: + context: . + dockerfile: ./Dockerfile + environment: + NODE_ENV: production + ports: + - 3000:3000 diff --git a/env b/env new file mode 100644 index 00000000..703350f9 --- /dev/null +++ b/env @@ -0,0 +1,99 @@ +# If you are using Docker, set DOCKER=true +DOCKER=true + +# MongoDB URL: Connection string for your MongoDB database +# 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 +# s3 = Amazon S3 +DB_TYPE=fs + +# If using fs, +# File Storage Directory: The directory where the files will be stored. Must be exact path. +# PATH MUST END IN A SLASH +# Example: /home/kyle/mydrive/ (must end in a slash) +FS_DIRECTORY=/data/ + +# If using s3, +# S3 Data: The S3 bucket and key where the files will be stored. +S3_ID= +S3_KEY= +S3_BUCKET= + +# Encryiption Key (optional): The encryption key used to encrypt the files. +# DO NOT LOSE OR FORGET THIS KEY AS ALL DATA WILL BE LOST IF YOU LOSE IT. +# If you do not supply a key, the app will instead prompt you to type one into the terminal when you start the server. +KEY=encryptionkey + +# Access tokens, refresh, and cookie +# These should be randomly generated in a secure manner. +# If you lose these tokens, all users will be logged out. +# You can also change these if you want to force all users to be logged out. +# Each token should be a different string. +# Example: sa4hQqJwGFLC1LJk59 +PASSWORD_ACCESS=secretaccesspassword +PASSWORD_REFRESH=secretrefreshpassword +PASSWORD_COOKIE=secretcookiepassword + +# Video thumbnails (optional): If you want to enable video thumbnails, configure as so. +# Video thumbnail generation relies on ffmpeg, please ensure you have it installed. +# VIDEO_THUMBNAILS_ENABLED=true +VIDEO_THUMBNAILS_ENABLED=true + +# Video thumbnails continued (optional): +# Sometimes generating a video thumbnail will fail with the default method. +# If so you can choose to instead temporarily store the video in a directory, and generate a thumbnail from that. +# WARNING: The file will be temporarily stored in this directory UNENCRYPTED. +# Temp directory example: /Users/kyle/mydrive/temp/ (must end in a slash) +# Temp video thumbnail limit: The maximum size of a video thumbnail in bytes. +# Example: 5000000000 +TEMP_DIRECTORY=/temp/ +TEMP_VIDEO_THUMBNAIL_LIMIT=5000000000 + +# Block account creation (optional): If you want to block account creation, configure as so, but after you create an account. +# BLOCK_CREATE_ACCOUNT=true + +# Ports (optional): The ports to run the server on. +# HTTP_PORT: Default port is 3000 +# HTTPS_PORT: Default port is 8080 +HTTP_PORT=3000 + +HTTPS_PORT=8080 + + +# URL (optional): The URL to run the server on. +# Most likely not needed, this changes the ip address/url express listens on. +URL= + +# Email verifcation (optional): If you want to enable email verification configure as so. +# EMAIL_VERIFICATION=true +# Remote URL: This refers to the URL sent in the verification email: Example https://mydrive-storage.com +# Please navigate to the following link to verify your email address: {REMOTE_URL}/verify +# Should NOT end with a slash +EMAIL_VERIFICATION= +EMAIL_DOMAIN= +EMAIL_ADDRESS= +EMAIL_API_KEY= +EMAIL_HOST= +REMOTE_URL= + +# Marks cookie generation as secure (Optional) +# This is recommended and should be enabled if you are running the app on HTTPS. +# SECURE_COOKIES=true +SECURE_COOKIES= + + +# SSL (Optional): If you want to enable SSL, configure as so. +# SSL=true +# Place your SSL certificate files in the root directory of the project +# With the names: certificate.crt, certificate.key, and certificate.ca-bundle; +SSL= + +# HTTPS cert paths (optional): If you need to change the paths of the https certs +# You can do so with these env variables. +# By default myDrive looks for certificate.crt, certificate.ca-bundle and certificate.key on the root of the project +HTTPS_KEY_PATH= +HTTPS_CA_PATH= +HTTPS_CRT_PATH= \ No newline at end of file diff --git a/package.json b/package.json index 34890303..6256afe4 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mydrive", - "version": "4.0.2", + "version": "4.1.0", "main": "index.js", "license": "GNU General Public License v3.0", "engines": {