From 56627caf5b1f985ae10dc8798ffd83edbed43270 Mon Sep 17 00:00:00 2001 From: Alex Tran Date: Fri, 11 Feb 2022 22:23:06 -0600 Subject: [PATCH] Fixed EACCES permission when mounting bind volume, add dynamic location for backup directory --- mobile/pubspec.lock | 9 ++++++++- server/.env.example | 2 +- server/docker-compose.yml | 7 ++----- server/src/config/multer-option.config.ts | 3 ++- server/src/constants/upload_location.constant.ts | 1 + .../modules/image-optimize/image-optimize.processor.ts | 5 +++-- 6 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 server/src/constants/upload_location.constant.ts diff --git a/mobile/pubspec.lock b/mobile/pubspec.lock index 48c23fe50..8e7163d72 100644 --- a/mobile/pubspec.lock +++ b/mobile/pubspec.lock @@ -520,6 +520,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" meta: dependency: transitive description: @@ -832,7 +839,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" + version: "0.4.8" timing: dependency: transitive description: diff --git a/server/.env.example b/server/.env.example index 70ec18b98..0ea603a6e 100644 --- a/server/.env.example +++ b/server/.env.example @@ -7,7 +7,7 @@ DB_PASSWORD=postgres DB_DATABASE_NAME= # Upload File Config -UPLOAD_LOCATION=./upload +UPLOAD_LOCATION=absolute_location_on_your_machine_where_you_want_to_store_the_backup # JWT SECRET JWT_SECRET= \ No newline at end of file diff --git a/server/docker-compose.yml b/server/docker-compose.yml index 5960736de..f5be85937 100644 --- a/server/docker-compose.yml +++ b/server/docker-compose.yml @@ -12,11 +12,9 @@ services: command: npm run start:dev ports: - "3000:3000" - # expose: - # - 3000 volumes: - .:/usr/src/app - - userdata:/usr/src/app/upload + - ${UPLOAD_LOCATION}:/usr/src/app/upload - /usr/src/app/node_modules env_file: - .env @@ -67,5 +65,4 @@ services: networks: immich_network: volumes: - pgdata: - userdata: \ No newline at end of file + pgdata: \ No newline at end of file diff --git a/server/src/config/multer-option.config.ts b/server/src/config/multer-option.config.ts index d69eebda1..2ec36a956 100644 --- a/server/src/config/multer-option.config.ts +++ b/server/src/config/multer-option.config.ts @@ -4,9 +4,10 @@ import { existsSync, mkdirSync } from 'fs'; import { diskStorage } from 'multer'; import { extname } from 'path'; import { Request } from 'express'; +import { APP_UPLOAD_LOCATION } from '../constants/upload_location.constant'; export const multerConfig = { - dest: process.env.UPLOAD_LOCATION, + dest: APP_UPLOAD_LOCATION, }; export const multerOption: MulterOptions = { diff --git a/server/src/constants/upload_location.constant.ts b/server/src/constants/upload_location.constant.ts new file mode 100644 index 000000000..cba2491f4 --- /dev/null +++ b/server/src/constants/upload_location.constant.ts @@ -0,0 +1 @@ +export const APP_UPLOAD_LOCATION = './upload'; diff --git a/server/src/modules/image-optimize/image-optimize.processor.ts b/server/src/modules/image-optimize/image-optimize.processor.ts index 269aa3824..ab6970035 100644 --- a/server/src/modules/image-optimize/image-optimize.processor.ts +++ b/server/src/modules/image-optimize/image-optimize.processor.ts @@ -7,6 +7,7 @@ import sharp from 'sharp'; import { existsSync, mkdirSync, readFile } from 'fs'; import { ConfigService } from '@nestjs/config'; import ffmpeg from 'fluent-ffmpeg'; +import { APP_UPLOAD_LOCATION } from '../../constants/upload_location.constant'; @Processor('optimize') export class ImageOptimizeProcessor { @@ -21,7 +22,7 @@ export class ImageOptimizeProcessor { async resizeUploadedImage(job: Job) { const { savedAsset }: { savedAsset: AssetEntity } = job.data; - const basePath = this.configService.get('UPLOAD_LOCATION'); + const basePath = APP_UPLOAD_LOCATION; const resizePath = savedAsset.originalPath.replace('/original/', '/thumb/'); // Create folder for thumb image if not exist @@ -77,7 +78,7 @@ export class ImageOptimizeProcessor { async resizeUploadedVideo(job: Job) { const { savedAsset, filename }: { savedAsset: AssetEntity; filename: String } = job.data; - const basePath = this.configService.get('UPLOAD_LOCATION'); + const basePath = APP_UPLOAD_LOCATION; // const resizePath = savedAsset.originalPath.replace('/original/', '/thumb/'); // Create folder for thumb image if not exist const resizeDir = `${basePath}/${savedAsset.userId}/thumb/${savedAsset.deviceId}`;