From 0a72039681801b68dcf56a044e45d2defd91143e Mon Sep 17 00:00:00 2001 From: amhsirak Date: Mon, 4 Nov 2024 21:59:05 +0530 Subject: [PATCH 1/2] chore: expose minio webui port --- docker-compose.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1aeefd26..d03334e0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,9 +32,10 @@ services: environment: MINIO_ROOT_USER: ${MINIO_ACCESS_KEY} MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY} - command: server /data + command: server /data --console-address :9001 ports: - - "9000:9000" + - "9000:9000" # API port + - "9001:9001" # WebUI port volumes: - minio_data:/data From 6a187872c4e6a04593eab9e59d4b349fc5e28655 Mon Sep 17 00:00:00 2001 From: amhsirak Date: Mon, 4 Nov 2024 22:10:39 +0530 Subject: [PATCH 2/2] feat: properly apply minio public-read policy --- server/src/storage/mino.ts | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/server/src/storage/mino.ts b/server/src/storage/mino.ts index 3b83e386..03702c2c 100644 --- a/server/src/storage/mino.ts +++ b/server/src/storage/mino.ts @@ -21,38 +21,39 @@ minioClient.bucketExists('maxun-test') console.error('Error connecting to MinIO:', err); }) -async function createBucketWithPolicy(bucketName: string, policy?: 'public-read' | 'private') { +async function createBucketWithPolicy(bucketName: string, policy = 'public-read') { try { const bucketExists = await minioClient.bucketExists(bucketName); if (!bucketExists) { await minioClient.makeBucket(bucketName); console.log(`Bucket ${bucketName} created successfully.`); - - if (policy === 'public-read') { - // Define a public-read policy - const policyJSON = { - Version: "2012-10-17", - Statement: [ - { - Effect: "Allow", - Principal: "", - Action: ["s3:GetObject"], - Resource: [`arn:aws:s3:::${bucketName}/*`] - } - ] - }; - await minioClient.setBucketPolicy(bucketName, JSON.stringify(policyJSON)); - console.log(`Public-read policy applied to bucket ${bucketName}.`); - } } else { console.log(`Bucket ${bucketName} already exists.`); } + + if (policy === 'public-read') { + // Apply public-read policy after confirming the bucket exists + const policyJSON = { + Version: "2012-10-17", + Statement: [ + { + Effect: "Allow", + Principal: "*", + Action: ["s3:GetObject"], + Resource: [`arn:aws:s3:::${bucketName}/*`] + } + ] + }; + await minioClient.setBucketPolicy(bucketName, JSON.stringify(policyJSON)); + console.log(`Public-read policy applied to bucket ${bucketName}.`); + } } catch (error) { console.error('Error in bucket creation or policy application:', error); } } + class BinaryOutputService { private bucketName: string;