From b8c5aafa1de96e7e7a063563b58c91e1b0f7b36b Mon Sep 17 00:00:00 2001 From: Miguel Medina Date: Sun, 3 Dec 2023 19:59:01 -0600 Subject: [PATCH 1/2] Add option to skip storage bucket check & creation in storage service --- apps/server/src/config/schema.ts | 4 ++++ apps/server/src/storage/storage.service.ts | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/apps/server/src/config/schema.ts b/apps/server/src/config/schema.ts index bcd881c72..362b070c4 100644 --- a/apps/server/src/config/schema.ts +++ b/apps/server/src/config/schema.ts @@ -39,6 +39,10 @@ export const configSchema = z.object({ .string() .default("false") .transform((s) => s !== "false" && s !== "0"), + STORAGE_SKIP_CREATE_BUCKET: z + .string() + .default("false") + .transform((s) => s !== "false" && s !== "0"), // Redis REDIS_URL: z.string().url().startsWith("redis://").optional(), diff --git a/apps/server/src/storage/storage.service.ts b/apps/server/src/storage/storage.service.ts index 01ccf6f70..d97775233 100644 --- a/apps/server/src/storage/storage.service.ts +++ b/apps/server/src/storage/storage.service.ts @@ -44,6 +44,8 @@ export class StorageService implements OnModuleInit { private client: Client; private bucketName: string; + private skipCreateBucket: boolean; + constructor( private readonly configService: ConfigService, private readonly minioService: MinioService, @@ -55,6 +57,12 @@ export class StorageService implements OnModuleInit { async onModuleInit() { this.client = this.minioService.client; this.bucketName = this.configService.getOrThrow("STORAGE_BUCKET"); + this.skipCreateBucket = this.configService.getOrThrow("STORAGE_SKIP_CREATE_BUCKET"); + + if (this.skipCreateBucket) { + this.logger.log("Skipping the creation of the storage bucket."); + return; + } try { // Create a storage bucket if it doesn't exist From 9955a64c56ae12400f7d0550d5ad06876a639969 Mon Sep 17 00:00:00 2001 From: Miguel Medina Date: Mon, 4 Dec 2023 01:34:52 -0600 Subject: [PATCH 2/2] add warning if skipped bucket creation --- apps/server/src/storage/storage.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/server/src/storage/storage.service.ts b/apps/server/src/storage/storage.service.ts index d97775233..7fdc2bcb3 100644 --- a/apps/server/src/storage/storage.service.ts +++ b/apps/server/src/storage/storage.service.ts @@ -61,6 +61,10 @@ export class StorageService implements OnModuleInit { if (this.skipCreateBucket) { this.logger.log("Skipping the creation of the storage bucket."); + this.logger.warn("Make sure that the following paths are publicly accessible: "); + this.logger.warn("- /pictures/*"); + this.logger.warn("- /previews/*"); + this.logger.warn("- /resumes/*"); return; }