-
Notifications
You must be signed in to change notification settings - Fork 379
Add MinIO Container
ucan-lab edited this page Jun 14, 2023
·
3 revisions
https://hub.docker.com/r/minio/minio
volumes:
minio-store:
services:
app:
# ...
environment:
- AWS_ACCESS_KEY_ID=${MINIO_ACCESS_KEY}
- AWS_SECRET_ACCESS_KEY=${MINIO_SECRET_KEY}
- AWS_DEFAULT_REGION=us-east-1
- AWS_BUCKET=laravel-local
- AWS_ENDPOINT=http://localhost:9000
minio:
image: minio/minio
ports:
- target: 9000
published: ${MINIO_PORT:-9000}
protocol: tcp
mode: host
volumes:
- type: volume
source: minio-store
target: /data
volume:
nocopy: true
environment:
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY}
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
command: server /data
MINIO_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXX
MINIO_SECRET_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-
.env
in the project root - The contents of the key can be anything
$ docker compose up -d
-
http://localhost:9000
- Enter your access key and secret key to log in
- Create a
laravel-local
bucket to match the AWS_BUCKET environment variable
https://github.com/thephpleague/flysystem-aws-s3-v3
$ docker compose exec app bash
$ composer require league/flysystem-aws-s3-v3:^1.0
- Laravel 8.x uses version 1 series
return [
'disks' => [
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
// Add
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', true),
],
],
// ...
];
$ docker compose exec app bash
$ php artisan tinker
>>> use Illuminate\Support\Facades\Storage;
>>> Storage::disk('s3')->put('example.txt', 'Contents');
=> true
>>> Storage::disk('s3')->get('example.txt');
=> "Contents"