From 65a2f2325955ca97503f46c329e66ad6a7616842 Mon Sep 17 00:00:00 2001 From: Nandu Krishna Date: Sun, 8 Mar 2026 13:28:16 +0530 Subject: [PATCH] Add setup instructions for minio --- .gitignore | 1 + contributor_docs/s3_configuration.md | 99 ++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/.gitignore b/.gitignore index bfedbe9b96..e96e5328de 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .env.staging .vscode/ node_modules/ +minio/ npm-debug.log dump.rdb static/dist/ diff --git a/contributor_docs/s3_configuration.md b/contributor_docs/s3_configuration.md index 92c38817ae..0080298d2e 100644 --- a/contributor_docs/s3_configuration.md +++ b/contributor_docs/s3_configuration.md @@ -1,4 +1,103 @@ # S3 Bucket Configuration + +This guide covers two options for S3 storage configuration: +- **[Option 1: MinIO (Local Development)](#minio-local-development)** - Recommended for local development +- **[Option 2: AWS S3 (Production)](#aws-s3-production)** - For production environments + +## MinIO (Local Development) + +MinIO is an S3-compatible object storage server that can run locally, making it ideal for development without needing AWS credentials or incurring cloud storage costs. + +### Installation + +Install `minio-client` from a package manager then, choose one of the following installation methods: + +#### Option A: AUR (Arch Linux) +```bash +yay -S minio +``` + +#### Option B: Download Binary (Linux) +```bash +wget https://dl.min.io/server/minio/release/linux-amd64/minio +chmod +x minio +sudo mv minio /usr/local/bin/ +``` + +Visit [https://www.min.io/download](https://www.min.io/download) for other installation options. + +### Setup + +1. **Start MinIO server:** +```bash +minio server minio/ --console-address ":9090" +``` + +This will start MinIO and create the folder if it doesn't exist and outputs the following information: +- API endpoint (typically `http://127.0.0.1:9000`) +- WebUI (typically `http://127.0.0.1:9090`) +- Root credentials (default: `minioadmin` / `minioadmin`) + +2. **Access the MinIO Web Console:** + - Open your browser and navigate to `http://127.0.0.1:9090` + - Login (default): + - Username: `minioadmin` + - Password: `minioadmin` + +3. **Create a bucket:** + - In the left panel, click "Create Bucket" + - Enter bucket name: `p5js-editor` + - Click "Create Bucket" + +4. **Configure bucket access (Public Access):** + - In your prefered terminal, configure the bucket to allow anonymous viewing `mcli anonymous set public local/p5js-editor` + +5. **Update your `.env` file:** +```bash +# MinIO Configuration +AWS_ACCESS_KEY=minioadmin +AWS_SECRET_KEY=minioadmin +AWS_REGION=us-east-1 +AWS_S3_ENDPOINT=http://127.0.0.1:9000 +AWS_S3_SIGNATURE_VERSION=v4 +S3_BUCKET=p5js-editor +S3_BUCKET_URL_BASE=http://127.0.0.1:9000/p5js-editor/ +``` + +6. **Update S3 client configuration in code:** + +The following files need to be updated to use MinIO locally: + +**server/controllers/aws.controller.js:** +```javascript +const s3Client = new S3Client({ + endpoint: process.env.AWS_S3_ENDPOINT || 'http://127.0.0.1:9000', + credentials: { + accessKeyId: process.env.AWS_ACCESS_KEY, + secretAccessKey: process.env.AWS_SECRET_KEY + }, + region: process.env.AWS_REGION, + forcePathStyle: true +}); +``` + +**server/migrations/s3UnderUser.js:** +```javascript +const s3Client = new S3Client({ + endpoint: process.env.AWS_S3_ENDPOINT || 'http://127.0.0.1:9000', + credentials: { + accessKeyId: process.env.AWS_ACCESS_KEY, + secretAccessKey: process.env.AWS_SECRET_KEY + }, + region: process.env.AWS_REGION, + forcePathStyle: true +}); +``` + +## AWS S3 (Production) + +For production environments, use AWS S3: + 1. [Create an S3 bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html), with any name. 2. Navigate to the S3 bucket permissions and add the following CORS policy. This is for development only, as it allows CORS from any origin. ```