You've already forked openaccounting-server
forked from cybercinch/openaccounting-server
feat: implement unified S3-compatible storage system
Consolidates storage backends into a single S3-compatible driver that supports: - AWS S3 (native) - Backblaze B2 (S3-compatible API) - Cloudflare R2 (S3-compatible API) - MinIO and other S3-compatible services - Local filesystem for development This replaces the previous separate B2 driver with a unified approach, reducing dependencies and complexity while adding support for more services. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
94
README.md
94
README.md
@@ -6,6 +6,7 @@ Open Accounting Server is a modern financial accounting system built with Go, fe
|
||||
|
||||
- **GORM Integration**: Modern ORM with SQLite and MySQL support
|
||||
- **Viper Configuration**: Flexible config management with environment variables
|
||||
- **Modular Storage**: S3-compatible attachment storage (Local, AWS S3, Backblaze B2, Cloudflare R2, MinIO)
|
||||
- **Docker Ready**: Containerized deployment with multi-stage builds
|
||||
- **SQLite Support**: Easy local development and testing
|
||||
- **Security**: Environment variable support for sensitive data
|
||||
@@ -81,6 +82,35 @@ All configuration can be overridden with environment variables using the `OA_` p
|
||||
| `OA_MAILGUN_EMAIL` | MailgunEmail | | Mailgun email |
|
||||
| `OA_MAILGUN_SENDER` | MailgunSender | | Mailgun sender name |
|
||||
|
||||
#### Storage Configuration
|
||||
|
||||
| Environment Variable | Config Field | Default | Description |
|
||||
|---------------------|--------------|---------|-------------|
|
||||
| `OA_STORAGE_BACKEND` | Storage.Backend | `local` | Storage backend: `local` or `s3` |
|
||||
|
||||
**Local Storage**
|
||||
| Environment Variable | Config Field | Default | Description |
|
||||
|---------------------|--------------|---------|-------------|
|
||||
| `OA_STORAGE_LOCAL_ROOTDIR` | Storage.Local.RootDir | `./uploads` | Root directory for file storage |
|
||||
| `OA_STORAGE_LOCAL_BASEURL` | Storage.Local.BaseURL | | Base URL for serving files |
|
||||
|
||||
**S3-Compatible Storage** (AWS S3, Backblaze B2, Cloudflare R2, MinIO)
|
||||
| Environment Variable | Config Field | Default | Description |
|
||||
|---------------------|--------------|---------|-------------|
|
||||
| `OA_STORAGE_S3_REGION` | Storage.S3.Region | | Region (use "auto" for Cloudflare R2) |
|
||||
| `OA_STORAGE_S3_BUCKET` | Storage.S3.Bucket | | Bucket name |
|
||||
| `OA_STORAGE_S3_PREFIX` | Storage.S3.Prefix | | Optional prefix for all objects |
|
||||
| `OA_STORAGE_S3_ACCESSKEYID` | Storage.S3.AccessKeyID | | Access Key ID ⚠️ |
|
||||
| `OA_STORAGE_S3_SECRETACCESSKEY` | Storage.S3.SecretAccessKey | | Secret Access Key ⚠️ |
|
||||
| `OA_STORAGE_S3_ENDPOINT` | Storage.S3.Endpoint | | Custom endpoint (see examples below) |
|
||||
| `OA_STORAGE_S3_PATHSTYLE` | Storage.S3.PathStyle | `false` | Use path-style addressing |
|
||||
|
||||
**S3-Compatible Service Endpoints:**
|
||||
- **AWS S3**: Leave endpoint empty, set appropriate region
|
||||
- **Backblaze B2**: `https://s3.us-west-004.backblazeb2.com` (replace region as needed)
|
||||
- **Cloudflare R2**: `https://<account-id>.r2.cloudflarestorage.com`
|
||||
- **MinIO**: `http://localhost:9000` (or your MinIO server URL)
|
||||
|
||||
⚠️ **Security**: Always use environment variables for sensitive data like passwords and API keys.
|
||||
|
||||
### Configuration Examples
|
||||
@@ -109,6 +139,51 @@ export OA_MAILGUN_KEY=key-abc123
|
||||
OA_DATABASE_DRIVER=mysql OA_PASSWORD=secret OA_MAILGUN_KEY=key-123 ./server
|
||||
```
|
||||
|
||||
#### Storage Configuration Examples
|
||||
```bash
|
||||
# Local storage (default)
|
||||
export OA_STORAGE_BACKEND=local
|
||||
export OA_STORAGE_LOCAL_ROOTDIR=./uploads
|
||||
./server
|
||||
|
||||
# AWS S3
|
||||
export OA_STORAGE_BACKEND=s3
|
||||
export OA_STORAGE_S3_REGION=us-west-2
|
||||
export OA_STORAGE_S3_BUCKET=my-app-attachments
|
||||
export OA_STORAGE_S3_ACCESSKEYID=your-access-key
|
||||
export OA_STORAGE_S3_SECRETACCESSKEY=your-secret-key
|
||||
./server
|
||||
|
||||
# Backblaze B2 (S3-compatible)
|
||||
export OA_STORAGE_BACKEND=s3
|
||||
export OA_STORAGE_S3_REGION=us-west-004
|
||||
export OA_STORAGE_S3_BUCKET=my-app-attachments
|
||||
export OA_STORAGE_S3_ACCESSKEYID=your-b2-key-id
|
||||
export OA_STORAGE_S3_SECRETACCESSKEY=your-b2-application-key
|
||||
export OA_STORAGE_S3_ENDPOINT=https://s3.us-west-004.backblazeb2.com
|
||||
export OA_STORAGE_S3_PATHSTYLE=true
|
||||
./server
|
||||
|
||||
# Cloudflare R2
|
||||
export OA_STORAGE_BACKEND=s3
|
||||
export OA_STORAGE_S3_REGION=auto
|
||||
export OA_STORAGE_S3_BUCKET=my-app-attachments
|
||||
export OA_STORAGE_S3_ACCESSKEYID=your-r2-access-key
|
||||
export OA_STORAGE_S3_SECRETACCESSKEY=your-r2-secret-key
|
||||
export OA_STORAGE_S3_ENDPOINT=https://your-account-id.r2.cloudflarestorage.com
|
||||
./server
|
||||
|
||||
# MinIO (self-hosted)
|
||||
export OA_STORAGE_BACKEND=s3
|
||||
export OA_STORAGE_S3_REGION=us-east-1
|
||||
export OA_STORAGE_S3_BUCKET=my-app-attachments
|
||||
export OA_STORAGE_S3_ACCESSKEYID=minioadmin
|
||||
export OA_STORAGE_S3_SECRETACCESSKEY=minioadmin
|
||||
export OA_STORAGE_S3_ENDPOINT=http://localhost:9000
|
||||
export OA_STORAGE_S3_PATHSTYLE=true
|
||||
./server
|
||||
```
|
||||
|
||||
#### Docker
|
||||
```bash
|
||||
# SQLite with volume mount
|
||||
@@ -123,6 +198,25 @@ docker run -p 8080:8080 \
|
||||
-e OA_DATABASE_ADDRESS=mysql:3306 \
|
||||
-e OA_PASSWORD=secret \
|
||||
openaccounting-server:latest
|
||||
|
||||
# With AWS S3 storage
|
||||
docker run -p 8080:8080 \
|
||||
-e OA_STORAGE_BACKEND=s3 \
|
||||
-e OA_STORAGE_S3_REGION=us-west-2 \
|
||||
-e OA_STORAGE_S3_BUCKET=my-attachments \
|
||||
-e OA_STORAGE_S3_ACCESSKEYID=your-key \
|
||||
-e OA_STORAGE_S3_SECRETACCESSKEY=your-secret \
|
||||
openaccounting-server:latest
|
||||
|
||||
# With Cloudflare R2 storage
|
||||
docker run -p 8080:8080 \
|
||||
-e OA_STORAGE_BACKEND=s3 \
|
||||
-e OA_STORAGE_S3_REGION=auto \
|
||||
-e OA_STORAGE_S3_BUCKET=my-attachments \
|
||||
-e OA_STORAGE_S3_ACCESSKEYID=your-r2-key \
|
||||
-e OA_STORAGE_S3_SECRETACCESSKEY=your-r2-secret \
|
||||
-e OA_STORAGE_S3_ENDPOINT=https://account-id.r2.cloudflarestorage.com \
|
||||
openaccounting-server:latest
|
||||
```
|
||||
|
||||
## Database Setup
|
||||
|
||||
Reference in New Issue
Block a user