Skip to content

Commit 75708b3

Browse files
committed
feat: Define API_ROOT_DIR for configurable storage paths in Docker and local environments
1 parent cf551d5 commit 75708b3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

apps/api/src/config.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ import { JwtModuleOptions } from '@nestjs/jwt'
88
import { StorageManagerConfig } from '~/_common/factorydrive'
99
import { AmazonWebServicesS3StorageConfig } from '~/_common/factorydrive'
1010
import { HttpModuleOptions } from '@nestjs/axios'
11+
import { join } from 'path'
12+
13+
/**
14+
* Répertoire de base de l'application API
15+
* En environnement Docker: /data/apps/api
16+
* En développement local: le répertoire du projet
17+
*/
18+
const API_ROOT_DIR = process.env['SESAME_API_ROOT_DIR'] || join(process.cwd(), 'apps', 'api')
1119

1220
/**
1321
* Schéma de validation Joi pour les variables d'environnement
@@ -306,13 +314,13 @@ export default (): ConfigInstance => ({
306314
local: {
307315
driver: 'local',
308316
config: {
309-
root: process.cwd() + '/storage',
317+
root: join(API_ROOT_DIR, 'storage'),
310318
},
311319
},
312320
identities: {
313321
driver: 'local',
314322
config: {
315-
root: process.cwd() + '/storage/identities',
323+
root: join(API_ROOT_DIR, 'storage', 'identities'),
316324
},
317325
},
318326
},

0 commit comments

Comments
 (0)