feat: default to SQLite engine, disable Mongo service by default in compose
Release Please / release-please (push) Has been cancelled
Docker Build and Push (Development) / build-and-push-dev (push) Has been cancelled

Mongo services in both compose files are now commented out (with instructions
to re-enable) since DB_ENGINE now defaults to sqlite - no separate database
container required out of the box. db-data volume is mounted into the app
service (not just mongo) so it can hold the SQLite file too.

Also fixes a require-order bug in tests/utils/express-app.js: routers were
required (eagerly instantiating DB singletons via dbFactory) before the test
env file was loaded, so DB_ENGINE from .env.test was silently never applied -
it only worked before because the old hardcoded default happened to be mongo.
This commit is contained in:
2026-07-05 04:48:54 -07:00
parent ecc340e7b1
commit 22af2caec7
5 changed files with 86 additions and 58 deletions
+10 -8
View File
@@ -3,17 +3,19 @@ DOCKER=true
# Database Engine: Choose between "mongo" and "sqlite", this specifies where file/folder/user METADATA is stored.
# This is separate from DB_TYPE below, which controls where the raw file BYTES are stored.
# mongo = MongoDB (default)
# sqlite = embedded SQLite file, no separate database server needed
DB_ENGINE=mongo
# sqlite = embedded SQLite file, no separate database server needed (default)
# mongo = MongoDB - requires uncommenting the mongo service in the compose file
DB_ENGINE=sqlite
# MongoDB URL: Connection string for your MongoDB database (only used when DB_ENGINE=mongo)
# Note: if using the compose file provided, the connection string should be as follows:
MONGODB_URL=mongodb://username:password@mongo:27017/mydrive?authSource=admin
# MongoDB URL (only used when DB_ENGINE=mongo): Connection string for your MongoDB database.
# Note: if using the compose file provided, uncomment the mongo service there first,
# then the connection string should be as follows:
# MONGODB_URL=mongodb://username:password@mongo:27017/mydrive?authSource=admin
# SQLite DB Path (only used when DB_ENGINE=sqlite): path to the SQLite database file.
# Should live inside a persisted volume (e.g. the same one used for FS_DIRECTORY) so it survives restarts.
SQLITE_DB_PATH=/data/mydrive.db
# Should live inside a persisted volume so it survives restarts.
# Note: if using the compose file provided, this should point into the db-data volume:
SQLITE_DB_PATH=/db-data/mydrive.db
# Database Type: Choose between "fs" and "s3", this specifies where the files will be stored.
# fs = Filesystem
+2 -2
View File
@@ -8,7 +8,7 @@ export default {
root: process.env.ROOT,
url: process.env.URL,
mongoURL: process.env.MONGODB_URL,
dbEngine: process.env.DB_ENGINE || "mongo",
dbEngine: process.env.DB_ENGINE || "sqlite",
sqliteDBPath: process.env.SQLITE_DB_PATH || "./data/mydrive.db",
dbType: process.env.DB_TYPE,
fsDirectory: process.env.FS_DIRECTORY,
@@ -48,7 +48,7 @@ module.exports = {
root: process.env.ROOT,
url: process.env.URL,
mongoURL: process.env.MONGODB_URL,
dbEngine: process.env.DB_ENGINE || "mongo",
dbEngine: process.env.DB_ENGINE || "sqlite",
sqliteDBPath: process.env.SQLITE_DB_PATH || "./data/mydrive.db",
dbType: process.env.DB_TYPE,
fsDirectory: process.env.FS_DIRECTORY,
+34 -22
View File
@@ -12,6 +12,9 @@ services:
# Use the following volumes section if you want to use named volumes:
- mydrive-data:/data/
- mydrive-temp:/temp/
# Only needed when DB_ENGINE=sqlite - stores the embedded SQLite
# metadata file, separate from mydrive-data (which holds file bytes).
- db-data:/db-data/
ports:
- "${HTTP_PORT:-3000}:3000"
# Optional: Uncomment the following line if you want to use HTTPS
@@ -24,30 +27,39 @@ services:
env_file:
- .env.test # Copy .env.example to .env.test or .env and fill in the values
# Only needed when DB_ENGINE=mongo (the default) in your env file.
# If DB_ENGINE=sqlite, this service is unused and can be removed -
# metadata is instead stored in an embedded SQLite file under the
# mydrive-data volume (SQLITE_DB_PATH), so no separate database service is required.
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
# Mongo service - only needed when DB_ENGINE=mongo in your env file.
# Commented out for DB_ENGINE=sqlite testing (metadata is stored in an
# embedded SQLite file under the db-data volume via SQLITE_DB_PATH,
# so no separate database service is required). Note: db-data is also
# mounted into the app service above - it's not Mongo-exclusive, it just
# also happens to be where Mongo keeps its data.
#
# To bring MongoDB back: uncomment this service block below, set
# DB_ENGINE=mongo and MONGODB_URL in your env file, then
# `docker compose -f docker-compose-test.yml up --build`.
# (The db-data volume stays declared below regardless, so any existing
# Mongo data already stored in it is preserved either way.)
#
# 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:
db-data:
db-data: # only used if the `mongo` service above is uncommented; kept declared so existing Mongo data isn't orphaned
+32 -21
View File
@@ -10,6 +10,9 @@ services:
# Use the following volumes section if you want to use named volumes:
- mydrive-data:/data/
- mydrive-temp:/temp/
# Only needed when DB_ENGINE=sqlite - stores the embedded SQLite
# metadata file, separate from mydrive-data (which holds file bytes).
- db-data:/db-data/
ports:
- "${HTTP_PORT:-3000}:3000"
# Optional: Uncomment the following line if you want to use HTTPS
@@ -22,27 +25,35 @@ services:
env_file:
- .env # Copy .env.example to .env and fill in the values
# Only needed when DB_ENGINE=mongo (the default) in your .env file.
# If DB_ENGINE=sqlite, this service is unused and can be removed -
# metadata is instead stored in an embedded SQLite file under the
# mydrive-data volume (SQLITE_DB_PATH), so no separate database service is required.
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
# Mongo service - only needed when DB_ENGINE=mongo in your .env file.
# Commented out by default since DB_ENGINE now defaults to sqlite (metadata
# is stored in an embedded SQLite file under the db-data volume via
# SQLITE_DB_PATH, so no separate database service is required by default).
# Note: db-data is also mounted into the app service above for this reason -
# it's not Mongo-exclusive, it just also happens to be where Mongo keeps its data.
#
# To bring MongoDB back: uncomment this service block below, set
# DB_ENGINE=mongo and MONGODB_URL in your .env file, then
# `docker compose up --build`. Any existing data already stored in
# db-data from prior Mongo use is preserved either way.
#
# 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:
+8 -5
View File
@@ -1,3 +1,11 @@
// NODE_ENV + env variables must load before any router/service is required below -
// those transitively instantiate DB singletons via dbFactory at require-time
// (getFileDB()/getUserDB()/etc. read env.dbEngine as soon as their module loads),
// so DB_ENGINE from .env.test would otherwise never take effect.
process.env.NODE_ENV = "test";
const getEnviromentVariables = require("../../dist-backend/enviroment/get-env-variables");
getEnviromentVariables();
const express = require("express");
// const requestIp = require("request-ip");
const bodyParser = require("body-parser");
@@ -14,11 +22,6 @@ const folderRouter =
const env = require("../../dist-backend/enviroment/env");
const middlewareErrorHandler =
require("../../dist-backend/middleware/utils/middleware-utils").middlewareErrorHandler;
const getEnviromentVariables = require("../../dist-backend/enviroment/get-env-variables");
process.env.NODE_ENV = "test";
getEnviromentVariables();
const app = express();