mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
feat: implement S3/MinIO setup script and configuration
- Added a new setup-s3.sh script to automate the configuration of S3 or MinIO based on environment variables. - Updated docker-compose.yml to include the new script and ensure it runs during service initialization. - Enhanced .env.example with S3 storage configuration details and CORS setup instructions. This change improves the deployment process by providing a streamlined way to set up S3 or MinIO, ensuring proper configuration for local development and production environments.
This commit is contained in:
parent
e48ba9c209
commit
508a5bfb51
3 changed files with 84 additions and 6 deletions
|
|
@ -32,13 +32,17 @@ CONTENT_FETCH_URL=http://content-fetch:8080/?token=some_token
|
|||
GCS_USE_LOCAL_HOST=true
|
||||
GCS_UPLOAD_BUCKET=omnivore
|
||||
AUTO_VERIFY=true
|
||||
# S3 Storage Configuration
|
||||
# For MinIO (local development): Use minio/miniominio credentials below
|
||||
# For AWS S3 (production): Replace with real AWS credentials and bucket name
|
||||
# The setup script will automatically configure CORS for AWS S3 using CLIENT_URL as allowed origin
|
||||
AWS_ACCESS_KEY_ID=minio # Used for Minio S3 Client
|
||||
AWS_SECRET_ACCESS_KEY=miniominio
|
||||
AWS_REGION=us-east-1
|
||||
CONTENT_FETCH_QUEUE_ENABLED=true
|
||||
|
||||
IMAGE_PROXY_URL=http://localhost:7070 # Need to change this for NGINX
|
||||
CLIENT_URL=http://localhost:3000 # Need to change this when using NGINX
|
||||
CLIENT_URL=http://localhost:3000 # Need to change this when using NGINX. Also used for S3 CORS configuration.
|
||||
LOCAL_MINIO_URL=http://localhost:1010
|
||||
|
||||
# Redis
|
||||
|
|
|
|||
|
|
@ -131,15 +131,15 @@ services:
|
|||
- BUCKET_NAME=omnivore
|
||||
- ENDPOINT=http://minio:9000
|
||||
- AWS_S3_ENDPOINT_URL=http://minio:9000
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- ./setup-s3.sh:/setup-s3.sh:ro
|
||||
depends_on:
|
||||
- minio
|
||||
entrypoint: >
|
||||
/bin/bash -c "
|
||||
sleep 5;
|
||||
until (/usr/bin/mc alias set myminio http://minio:9000 minio miniominio) do echo '...waiting...' && sleep 1; done;
|
||||
/usr/bin/mc mb myminio/omnivore;
|
||||
/usr/bin/mc anonymous set public myminio/omnivore;
|
||||
exit 0;
|
||||
chmod +x /setup-s3.sh && /setup-s3.sh
|
||||
"
|
||||
mail-watch-server:
|
||||
image: "ghcr.io/omnivore-app/sh-local-mail-watcher:latest"
|
||||
|
|
|
|||
74
self-hosting/docker-compose/setup-s3.sh
Normal file
74
self-hosting/docker-compose/setup-s3.sh
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "Starting S3/MinIO setup..."
|
||||
|
||||
# Wait for MinIO to be ready if using MinIO
|
||||
if [ "$AWS_ACCESS_KEY_ID" = "minio" ]; then
|
||||
echo "Detected MinIO configuration"
|
||||
echo "Waiting for MinIO to be ready..."
|
||||
sleep 5
|
||||
|
||||
# Setup MinIO with bucket creation
|
||||
until (/usr/bin/mc alias set myminio http://minio:9000 minio miniominio) do
|
||||
echo '...waiting for MinIO...'
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "Creating MinIO bucket: ${GCS_UPLOAD_BUCKET:-omnivore}"
|
||||
/usr/bin/mc mb myminio/${GCS_UPLOAD_BUCKET:-omnivore} || true
|
||||
/usr/bin/mc anonymous set public myminio/${GCS_UPLOAD_BUCKET:-omnivore}
|
||||
echo "MinIO setup complete"
|
||||
|
||||
else
|
||||
echo "Detected AWS S3 configuration"
|
||||
|
||||
# Install AWS CLI if not present
|
||||
if ! command -v aws &> /dev/null; then
|
||||
echo "Installing AWS CLI..."
|
||||
apk add --no-cache aws-cli
|
||||
fi
|
||||
|
||||
BUCKET_NAME="${GCS_UPLOAD_BUCKET:-omnivore}"
|
||||
CORS_ORIGIN="${CLIENT_URL:-https://localhost:3000}"
|
||||
AWS_REGION="${AWS_REGION:-us-east-1}"
|
||||
|
||||
echo "Configuring CORS for S3 bucket: $BUCKET_NAME"
|
||||
echo "Allowed origin: $CORS_ORIGIN"
|
||||
|
||||
# Create CORS configuration JSON
|
||||
cat > /tmp/cors.json << EOF
|
||||
{
|
||||
"CORSRules": [
|
||||
{
|
||||
"AllowedHeaders": ["*"],
|
||||
"AllowedMethods": ["GET", "PUT", "POST", "DELETE", "HEAD"],
|
||||
"AllowedOrigins": ["$CORS_ORIGIN"],
|
||||
"ExposeHeaders": [
|
||||
"ETag",
|
||||
"x-amz-server-side-encryption",
|
||||
"x-amz-request-id",
|
||||
"x-amz-id-2"
|
||||
],
|
||||
"MaxAgeSeconds": 3000
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
|
||||
# Apply CORS configuration
|
||||
echo "Applying CORS configuration..."
|
||||
aws s3api put-bucket-cors \
|
||||
--bucket "$BUCKET_NAME" \
|
||||
--region "$AWS_REGION" \
|
||||
--cors-configuration file:///tmp/cors.json
|
||||
|
||||
echo "S3 CORS configuration complete for bucket: $BUCKET_NAME"
|
||||
|
||||
# Verify CORS configuration
|
||||
echo "Verifying CORS configuration..."
|
||||
aws s3api get-bucket-cors --bucket "$BUCKET_NAME" --region "$AWS_REGION" || echo "CORS verification failed (this may be normal if bucket doesn't exist yet)"
|
||||
fi
|
||||
|
||||
echo "S3 setup completed successfully"
|
||||
Loading…
Reference in a new issue