Add MinIO S3 storage integration
All checks were successful
Deploy Production (crewsportswear.com) / deploy (push) Successful in 2m9s
All checks were successful
Deploy Production (crewsportswear.com) / deploy (push) Successful in 2m9s
- Add minio disk configuration in filesystems.php - Create helper functions for MinIO URLs (minio_url, minio_image_url) - Update composer.json with AWS SDK (for future S3 support) - Add MinIO env vars to docker-compose.local.yml - Add .env examples for MinIO configuration
This commit is contained in:
6
.env.local.example
Normal file
6
.env.local.example
Normal file
@@ -0,0 +1,6 @@
|
||||
# Local Development MinIO Configuration
|
||||
# Copy to .env.local and update with your MinIO credentials
|
||||
|
||||
# MinIO credentials (get from your production server)
|
||||
MINIO_KEY=your_minio_root_user
|
||||
MINIO_SECRET=your_minio_root_password
|
||||
21
.env.minio.example
Normal file
21
.env.minio.example
Normal file
@@ -0,0 +1,21 @@
|
||||
# MinIO S3 Storage Configuration
|
||||
# Add these to your production .env file
|
||||
|
||||
# MinIO Endpoint (internal Docker network)
|
||||
MINIO_ENDPOINT=http://crew-minio-prod:9000
|
||||
|
||||
# MinIO Credentials (get from /var/www/apps/minio-storage/.env)
|
||||
MINIO_KEY=your_minio_root_user
|
||||
MINIO_SECRET=your_minio_root_password
|
||||
|
||||
# Bucket name
|
||||
MINIO_BUCKET=crewsportswear
|
||||
|
||||
# Region (required for S3 compatibility)
|
||||
MINIO_REGION=us-east-1
|
||||
|
||||
# Use path-style endpoint (required for MinIO)
|
||||
MINIO_USE_PATH_STYLE=true
|
||||
|
||||
# Public URL for accessing files (use your actual domain)
|
||||
MINIO_URL=https://minio.crewsportswear.app
|
||||
33
app/helpers.php
Normal file
33
app/helpers.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
if (!function_exists('minio_url')) {
|
||||
/**
|
||||
* Generate MinIO URL for a file
|
||||
*
|
||||
* @param string $path File path relative to bucket
|
||||
* @return string Full MinIO URL
|
||||
*/
|
||||
function minio_url($path)
|
||||
{
|
||||
$bucket = env('MINIO_BUCKET', 'crewsportswear');
|
||||
$baseUrl = env('MINIO_URL', 'https://minio.crewsportswear.app');
|
||||
|
||||
// Remove leading slash if present
|
||||
$path = ltrim($path, '/');
|
||||
|
||||
return $baseUrl . '/' . $bucket . '/' . $path;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('minio_image_url')) {
|
||||
/**
|
||||
* Generate MinIO URL for an image in uploads/images/
|
||||
*
|
||||
* @param string $filename Image filename
|
||||
* @return string Full MinIO URL
|
||||
*/
|
||||
function minio_image_url($filename)
|
||||
{
|
||||
return minio_url('uploads/images/' . $filename);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,8 @@
|
||||
"guzzlehttp/guzzle": "~5.0",
|
||||
"google/recaptcha": "~1.1",
|
||||
"spatie/laravel-analytics": "^1.4",
|
||||
"league/flysystem-sftp": "^1.0"
|
||||
"league/flysystem-sftp": "^1.0",
|
||||
"aws/aws-sdk-php": "~3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0",
|
||||
@@ -24,7 +25,10 @@
|
||||
],
|
||||
"psr-4": {
|
||||
"App\\": "app/"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"app/helpers.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [
|
||||
|
||||
@@ -86,6 +86,18 @@ return [
|
||||
'driver' => 'local',
|
||||
'root' => '/var/www/html/uploads/images',
|
||||
],
|
||||
|
||||
'minio' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('MINIO_KEY'),
|
||||
'secret' => env('MINIO_SECRET'),
|
||||
'region' => env('MINIO_REGION', 'us-east-1'),
|
||||
'bucket' => env('MINIO_BUCKET', 'crewsportswear'),
|
||||
'endpoint' => env('MINIO_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('MINIO_USE_PATH_STYLE', true),
|
||||
'url' => env('MINIO_URL', 'https://minio.crewsportswear.app'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
];
|
||||
@@ -48,6 +48,14 @@ services:
|
||||
- ANALYTICS_SITE_ID=
|
||||
- ANALYTICS_CLIENT_ID=
|
||||
- ANALYTICS_SERVICE_EMAIL=
|
||||
# MinIO S3 Storage (connect to production MinIO for testing)
|
||||
- MINIO_ENDPOINT=https://minio.crewsportswear.app
|
||||
- MINIO_KEY=${MINIO_KEY:-minioadmin}
|
||||
- MINIO_SECRET=${MINIO_SECRET:-minioadmin}
|
||||
- MINIO_BUCKET=crewsportswear
|
||||
- MINIO_REGION=us-east-1
|
||||
- MINIO_USE_PATH_STYLE=false
|
||||
- MINIO_URL=https://minio.crewsportswear.app
|
||||
volumes:
|
||||
- ./:/var/www/html
|
||||
- ./storage:/var/www/html/storage
|
||||
|
||||
Reference in New Issue
Block a user