Skip to content

Instantly share code, notes, and snippets.

@nikooo777
Last active July 6, 2021 20:13
Show Gist options
  • Save nikooo777/73ae72ea7d0d3fabebe247eb490dc79b to your computer and use it in GitHub Desktop.
Save nikooo777/73ae72ea7d0d3fabebe247eb490dc79b to your computer and use it in GitHub Desktop.
S3 cache layer using MinIO Gateway and docker-compose

Intro

Whether you're looking to save money on egress charges or whether you simply want a local cache of a subset of your S3 bucket, all you need is this docker compose configuration to proxy all your read requests and cache files locally.

docker-compose.yaml

version: '3.7'

services:
  minio1:
    image: minio/minio:latest
    hostname: minio1
    volumes:
      - ./local_cache:/data1
    ports:
      - "9000:9000"
    environment:
      MINIO_ROOT_USER: ACCESS_KEY_HERE
      MINIO_ROOT_PASSWORD: SECRET_KEY_HERE
      MINIO_CACHE: "on"
      MINIO_CACHE_DRIVES: /data1
      MINIO_CACHE_QUOTA: 90
      MINIO_CACHE_AFTER: 0
      MINIO_CACHE_WATERMARK_LOW: 70
      MINIO_CACHE_WATERMARK_HIGH: 90
    command: gateway s3 https://my-custom-s3.domain.com

Tune as you please. Find more information here: https://docs.min.io/docs/minio-disk-cache-guide.html and here: https://docs.min.io/docs/minio-gateway-for-s3.html

Reverse proxy

You might want to reverse proxy it. It's not necessary but if you want here is a simple caddy v2 configuration:

s3cache.mycustomdomain.com {
  reverse_proxy localhost:9000
  tls your@email.com
}

Running minio

simply bring the container up with docker-compose up -d

Done

You're all set, enjoy spending less :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment