Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.env.staging
.vscode/
node_modules/
minio/
npm-debug.log
dump.rdb
static/dist/
Expand Down
99 changes: 99 additions & 0 deletions contributor_docs/s3_configuration.md
Original file line number Diff line number Diff line change
@@ -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.
```
Expand Down