DEV Community

Justin
Justin

Posted on

📦 Set up minio w/ Laravel (Local S3)

Example docker-compose.yml for development

version: "3.9"
services:
  web:
    build:
      context: .
      dockerfile: Dockerfile.web
    volumes:
      - ./:/app
    ports:
      - "8000:8000"
  storage:
      hostname: minio
      image: quay.io/minio/minio
      command: server /data --console-address :9001
      environment:
          MINIO_ROOT_USER: minio
          MINIO_ROOT_PASSWORD: minio123
      healthcheck:
          test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
          interval: 30s
          timeout: 20s
          retries: 3
      volumes:
          - ./storage/data:/data
      ports:
          - "9005:9000"
          - "9006:9001"
Enter fullscreen mode Exit fullscreen mode

Now with that in place, setup a .env

AWS_ACCESS_KEY_ID=minio
AWS_SECRET_ACCESS_KEY=minio123
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=testbucket
AWS_USE_PATH_STYLE_ENDPOINT=true
AWS_ENDPOINT=http://minio:9000
Enter fullscreen mode Exit fullscreen mode

And that is it! You are ready to rock. Just remember to set

FILESYSTEM_DRIVER=s3
Enter fullscreen mode Exit fullscreen mode

And let it eat!

Route::get('/',function(){
    return Storage::files();
});
Enter fullscreen mode Exit fullscreen mode

Stick around and later we'll learn how to upload files there!

Top comments (1)

Collapse
 
robinbastiaan profile image
Robin Bastiaan • Edited

What is minio and why would you do this? What are you trying to do? And what are your considerations of doing it like you do? I do not understand the article just by reading it.