Skip to content

Commit 11bed01

Browse files
committed
added dev docker file
1 parent 28bcc44 commit 11bed01

14 files changed

+48
-47
lines changed

Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:13
1+
FROM node:20
22

33
WORKDIR /usr/app
44

@@ -8,9 +8,8 @@ RUN npm install
88

99
COPY . .
1010

11-
RUN npm run build:docker
12-
1311
EXPOSE 8080
1412
EXPOSE 3000
13+
EXPOSE 5173
1514

16-
CMD [ "npm", "run", "start"]
15+
CMD [ "npm", "run", "dev"]

backend/enviroment/env.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default {
3030
tempVideoThumbnailLimit: process.env.TEMP_VIDEO_THUMBNAIL_LIMIT
3131
? +process.env.TEMP_VIDEO_THUMBNAIL_LIMIT
3232
: 0,
33+
docker: process.env.DOCKER === "true",
3334
};
3435

3536
module.exports = {
@@ -64,4 +65,5 @@ module.exports = {
6465
tempVideoThumbnailLimit: process.env.TEMP_VIDEO_THUMBNAIL_LIMIT
6566
? +process.env.TEMP_VIDEO_THUMBNAIL_LIMIT
6667
: 0,
68+
docker: process.env.DOCKER === "true",
6769
};

backend/services/chunk-service/actions/file-system-actions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from "fs";
22
import { UserInterface } from "../../../models/user-model";
33
import { GenericParams, IStorageActions } from "../store-types";
44
import env from "../../../enviroment/env";
5+
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
56

67
class FilesystemActions implements IStorageActions {
78
async getAuth() {
@@ -60,7 +61,7 @@ class FilesystemActions implements IStorageActions {
6061
stream: NodeJS.ReadableStream,
6162
randomID: string
6263
) => {
63-
const path = `${env.fsDirectory}${randomID}`;
64+
const path = `${getFSStoragePath()}${randomID}`;
6465
return {
6566
writeStream: fs.createWriteStream(path),
6667
emitter: null,

backend/services/chunk-service/utils/createImageThumbnail.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { FilesystemActions } from "../actions/file-system-actions";
1111
import { EventEmitter } from "stream";
1212
import FileDB from "../../../db/mongoDB/fileDB";
1313
import { getStorageActions } from "../actions/helper-actions";
14+
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
1415

1516
const fileDB = new FileDB();
1617

@@ -58,7 +59,7 @@ const processData = (
5859
name: filename,
5960
owner: user._id,
6061
IV: thumbnailIV,
61-
path: env.fsDirectory + thumbnailFilename,
62+
path: getFSStoragePath() + thumbnailFilename,
6263
s3ID: thumbnailFilename,
6364
});
6465

backend/services/chunk-service/utils/createVideoThumbnail.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { S3Actions } from "../actions/S3-actions";
1515
import { FilesystemActions } from "../actions/file-system-actions";
1616
import { createGenericParams } from "./storageHelper";
1717
import { getStorageActions } from "../actions/helper-actions";
18+
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
1819

1920
const storageActions = getStorageActions();
2021

@@ -24,7 +25,7 @@ const attemptToRemoveChunks = async (
2425
) => {
2526
try {
2627
const readStreamParams = createGenericParams({
27-
filePath: env.fsDirectory + thumbnailFilename,
28+
filePath: getFSStoragePath() + thumbnailFilename,
2829
Key: thumbnailFilename,
2930
});
3031
await storageActions.removeChunks(readStreamParams);
@@ -98,7 +99,7 @@ const createVideoThumbnail = (
9899
name: filename,
99100
owner: user._id,
100101
IV: thumbnailIV,
101-
path: env.fsDirectory + thumbnailFilename,
102+
path: getFSStoragePath() + thumbnailFilename,
102103
s3ID: thumbnailFilename,
103104
});
104105

backend/services/chunk-service/utils/getBusboyData.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import videoChecker from "../../../utils/videoChecker";
1515
import createVideoThumbnail from "./createVideoThumbnail";
1616
import createThumbnail from "./createImageThumbnail";
1717
import { RequestTypeFullUser } from "../../../controllers/file-controller";
18+
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
1819

1920
// TODO: We should stop using moongoose directly here,
2021
// Also in our fileDB make sure we are actually using File instead
@@ -115,7 +116,7 @@ const processData = (
115116
} as FileMetadateInterface;
116117

117118
if (env.dbType === "fs") {
118-
metadata.filePath = env.fsDirectory + randomFilenameID;
119+
metadata.filePath = getFSStoragePath() + randomFilenameID;
119120
} else {
120121
metadata.s3ID = randomFilenameID;
121122
}

backend/services/chunk-service/utils/getFolderUploadBusboyData.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import createThumbnail from "./createImageThumbnail";
1818
import { EventEmitter } from "events";
1919
import { getStorageActions } from "../actions/helper-actions";
2020
import { RequestTypeFullUser } from "../../../controllers/file-controller";
21+
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
2122

2223
type FileDataType = {
2324
name: string;
@@ -133,7 +134,7 @@ const processData = (
133134
} as FileMetadateInterface;
134135

135136
if (env.dbType === "fs") {
136-
metadata.filePath = env.fsDirectory + randomFilenameID;
137+
metadata.filePath = getFSStoragePath() + randomFilenameID;
137138
} else {
138139
metadata.s3ID = randomFilenameID;
139140
}

backend/services/chunk-service/utils/storageHelper.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import env from "../../../enviroment/env";
2+
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
23

34
type GenericParmasType = {
45
filePath?: string;
@@ -13,11 +14,11 @@ export const createGenericParams = ({ filePath, Key }: GenericParmasType) => {
1314
const filePathSplit = filePath!.split("/");
1415
const fileName = filePathSplit[filePathSplit.length - 1];
1516
return {
16-
filePath: env.fsDirectory + fileName,
17+
filePath: getFSStoragePath() + fileName,
1718
};
1819
} else {
1920
return {
20-
filePath: env.fsDirectory + Key!,
21+
filePath: getFSStoragePath() + Key!,
2122
};
2223
}
2324
} else {

backend/services/chunk-service/utils/tempCreateVideoThumbnail.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { S3Actions } from "../actions/S3-actions";
1414
import { FilesystemActions } from "../actions/file-system-actions";
1515
import { createGenericParams } from "./storageHelper";
1616
import { getStorageActions } from "../actions/helper-actions";
17+
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
1718

1819
const storageActions = getStorageActions();
1920

@@ -73,7 +74,7 @@ const tempCreateVideoThumbnail = (
7374
name: filename,
7475
owner: user._id,
7576
IV: thumbnailIV,
76-
path: env.fsDirectory + thumbnailFilename,
77+
path: getFSStoragePath() + thumbnailFilename,
7778
s3ID: thumbnailFilename,
7879
});
7980

backend/utils/getFSStoragePath.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import env from "../enviroment/env";
2+
3+
export const getFSStoragePath = () => {
4+
if (env.docker) {
5+
return "/data/";
6+
} else {
7+
return env.fsDirectory;
8+
}
9+
};

0 commit comments

Comments
 (0)