added dev docker file

This commit is contained in:
subnub
2025-02-24 11:29:21 -05:00
parent 28bcc44ea2
commit 11bed01c50
14 changed files with 48 additions and 47 deletions
+3 -4
View File
@@ -1,4 +1,4 @@
FROM node:13
FROM node:20
WORKDIR /usr/app
@@ -8,9 +8,8 @@ RUN npm install
COPY . .
RUN npm run build:docker
EXPOSE 8080
EXPOSE 3000
EXPOSE 5173
CMD [ "npm", "run", "start"]
CMD [ "npm", "run", "dev"]
+2
View File
@@ -30,6 +30,7 @@ export default {
tempVideoThumbnailLimit: process.env.TEMP_VIDEO_THUMBNAIL_LIMIT
? +process.env.TEMP_VIDEO_THUMBNAIL_LIMIT
: 0,
docker: process.env.DOCKER === "true",
};
module.exports = {
@@ -64,4 +65,5 @@ module.exports = {
tempVideoThumbnailLimit: process.env.TEMP_VIDEO_THUMBNAIL_LIMIT
? +process.env.TEMP_VIDEO_THUMBNAIL_LIMIT
: 0,
docker: process.env.DOCKER === "true",
};
@@ -2,6 +2,7 @@ import fs from "fs";
import { UserInterface } from "../../../models/user-model";
import { GenericParams, IStorageActions } from "../store-types";
import env from "../../../enviroment/env";
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
class FilesystemActions implements IStorageActions {
async getAuth() {
@@ -60,7 +61,7 @@ class FilesystemActions implements IStorageActions {
stream: NodeJS.ReadableStream,
randomID: string
) => {
const path = `${env.fsDirectory}${randomID}`;
const path = `${getFSStoragePath()}${randomID}`;
return {
writeStream: fs.createWriteStream(path),
emitter: null,
@@ -11,6 +11,7 @@ import { FilesystemActions } from "../actions/file-system-actions";
import { EventEmitter } from "stream";
import FileDB from "../../../db/mongoDB/fileDB";
import { getStorageActions } from "../actions/helper-actions";
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
const fileDB = new FileDB();
@@ -58,7 +59,7 @@ const processData = (
name: filename,
owner: user._id,
IV: thumbnailIV,
path: env.fsDirectory + thumbnailFilename,
path: getFSStoragePath() + thumbnailFilename,
s3ID: thumbnailFilename,
});
@@ -15,6 +15,7 @@ import { S3Actions } from "../actions/S3-actions";
import { FilesystemActions } from "../actions/file-system-actions";
import { createGenericParams } from "./storageHelper";
import { getStorageActions } from "../actions/helper-actions";
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
const storageActions = getStorageActions();
@@ -24,7 +25,7 @@ const attemptToRemoveChunks = async (
) => {
try {
const readStreamParams = createGenericParams({
filePath: env.fsDirectory + thumbnailFilename,
filePath: getFSStoragePath() + thumbnailFilename,
Key: thumbnailFilename,
});
await storageActions.removeChunks(readStreamParams);
@@ -98,7 +99,7 @@ const createVideoThumbnail = (
name: filename,
owner: user._id,
IV: thumbnailIV,
path: env.fsDirectory + thumbnailFilename,
path: getFSStoragePath() + thumbnailFilename,
s3ID: thumbnailFilename,
});
@@ -15,6 +15,7 @@ import videoChecker from "../../../utils/videoChecker";
import createVideoThumbnail from "./createVideoThumbnail";
import createThumbnail from "./createImageThumbnail";
import { RequestTypeFullUser } from "../../../controllers/file-controller";
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
// TODO: We should stop using moongoose directly here,
// Also in our fileDB make sure we are actually using File instead
@@ -115,7 +116,7 @@ const processData = (
} as FileMetadateInterface;
if (env.dbType === "fs") {
metadata.filePath = env.fsDirectory + randomFilenameID;
metadata.filePath = getFSStoragePath() + randomFilenameID;
} else {
metadata.s3ID = randomFilenameID;
}
@@ -18,6 +18,7 @@ import createThumbnail from "./createImageThumbnail";
import { EventEmitter } from "events";
import { getStorageActions } from "../actions/helper-actions";
import { RequestTypeFullUser } from "../../../controllers/file-controller";
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
type FileDataType = {
name: string;
@@ -133,7 +134,7 @@ const processData = (
} as FileMetadateInterface;
if (env.dbType === "fs") {
metadata.filePath = env.fsDirectory + randomFilenameID;
metadata.filePath = getFSStoragePath() + randomFilenameID;
} else {
metadata.s3ID = randomFilenameID;
}
@@ -1,4 +1,5 @@
import env from "../../../enviroment/env";
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
type GenericParmasType = {
filePath?: string;
@@ -13,11 +14,11 @@ export const createGenericParams = ({ filePath, Key }: GenericParmasType) => {
const filePathSplit = filePath!.split("/");
const fileName = filePathSplit[filePathSplit.length - 1];
return {
filePath: env.fsDirectory + fileName,
filePath: getFSStoragePath() + fileName,
};
} else {
return {
filePath: env.fsDirectory + Key!,
filePath: getFSStoragePath() + Key!,
};
}
} else {
@@ -14,6 +14,7 @@ import { S3Actions } from "../actions/S3-actions";
import { FilesystemActions } from "../actions/file-system-actions";
import { createGenericParams } from "./storageHelper";
import { getStorageActions } from "../actions/helper-actions";
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
const storageActions = getStorageActions();
@@ -73,7 +74,7 @@ const tempCreateVideoThumbnail = (
name: filename,
owner: user._id,
IV: thumbnailIV,
path: env.fsDirectory + thumbnailFilename,
path: getFSStoragePath() + thumbnailFilename,
s3ID: thumbnailFilename,
});
+9
View File
@@ -0,0 +1,9 @@
import env from "../enviroment/env";
export const getFSStoragePath = () => {
if (env.docker) {
return "/data/";
} else {
return env.fsDirectory;
}
};
-13
View File
@@ -1,13 +0,0 @@
version: '3'
services:
app:
container_name: mydrive-node-no-mongo
restart: always
build: .
ports:
- '3000:3000'
- '8080:8080'
env_file:
- docker-variables.env
+14 -20
View File
@@ -1,24 +1,18 @@
version: '3'
version: "3.8"
services:
app:
container_name: mydrive-node
restart: always
build: .
ports:
- '3000:3000'
- '8080:8080'
build:
context: .
dockerfile: Dockerfile
env_file:
- docker-variables.env
links:
- mongo
mongo:
container_name: mongo
image: mongo
ports:
- '27017:27017'
- ./backend/config/.env.development
volumes:
- 'mongodb_data_volume:/data/db'
volumes:
mongodb_data_volume:
external: true
- .:/usr/app
- /usr/app/node_modules
- ${FS_DIRECTORY}:/data
ports:
- "3000:3000"
- "8080:8080"
- "5173:5173"
environment:
- DOCKER=true
+3 -1
View File
@@ -18,7 +18,9 @@
"create-video-thumbnails:dev": "NODE_ENV=development node serverUtils/createVideoThumbnails.js",
"migrate-to-mydrive4": "NODE_ENV=production node serverUtils/migrateMyDrive4.js",
"migrate-to-mydrive4:dev": "NODE_ENV=development node serverUtils/migrateMyDrive4.js",
"test": "NODE_ENV=test jest"
"test": "NODE_ENV=test jest",
"docker:dev": "docker-compose -f docker-compose.yml --env-file ./backend/config/.env.development up",
"docker:down": "docker-compose down"
},
"dependencies": {
"@babel/core": "^7.8.4",
+1
View File
@@ -41,6 +41,7 @@ const envFileFix = (env) => {
env.tempVideoThumbnailLimit = process.env.TEMP_VIDEO_THUMBNAIL_LIMIT
? +process.env.TEMP_VIDEO_THUMBNAIL_LIMIT
: 0;
env.docker = process.env.DOCKER === "true";
};
module.exports = {