├── LICENSE ├── README.md ├── minio-elasticsearch ├── README.md ├── config.json └── docker-compose.yaml ├── minio-kafka ├── README.md ├── config.json └── docker-compose.yaml ├── minio-mqtt ├── README.md ├── config.json ├── docker-compose.yaml └── mqtt.py ├── minio-nats ├── README.md ├── config.json ├── docker-compose.yaml └── nats.go ├── minio-redis ├── README.md ├── config.json ├── docker-compose.yaml └── secret └── wait-for.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Nitish Tiwari 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # minio-compose 2 | Collection of Docker Compose files to setup Minio event notifications with Elasticsearch, Kafka, Nats, MySql, AQMP, Redis 3 | 4 | Currently these are the working examples: 5 | 6 | - [minio-kafka](./minio-kafka/README.md) 7 | - [minio-elasticsearch](./minio-elasticsearch/README.md) 8 | - [minio-redis](./minio-redis/README.md) 9 | - [minio-nats](./minio-nats/README.md) 10 | - [minio-mqtt](./minio-mqtt/README.md) 11 | 12 | -------------------------------------------------------------------------------- /minio-elasticsearch/README.md: -------------------------------------------------------------------------------- 1 | # minio-elasticsearch 2 | 3 | Setup Minio + Elasticsearch for testing bucket notifications. 4 | 5 | ## Prerequisites 6 | - Docker installed (Docker version 17.05.0-ce on Linux) 7 | - docker-compose installed (1.8.0) 8 | 9 | ## Setup Minio and Elasticsearch with docker-compose 10 | We'll use docker-compose to set up Minio and Elasticsearch containers. Download the [docker-compose.yml](./docker-compose.yaml) file in your working directory. This docker-compose file declares two containers. 11 | 12 | First one, `elasticsearch` runs official image. It exposes itself under `elasticsearch` hostname, with two environment variables set: 13 | 14 | ``` 15 | discovery.type=single-node 16 | xpack.security.enabled=false 17 | ``` 18 | 19 | `discovery.type` describe that this is a single node Elasticsearch setup. `xpack.security.enabled` set to `false` indicates `xpack` is disabled in this instance. Read more [here](https://www.elastic.co/guide/en/x-pack/current/xpack-settings.html). 20 | 21 | Second container, minio runs latest Minio server. It needs to connect to the running Elasticsearch server, that's why there is the `depends_on` entry in docker-compose. 22 | 23 | ### Start the environment 24 | Once the `docker-compose.yml` file is ready, navigate to working directory via terminal and run: 25 | 26 | ``` 27 | docker-compose up 28 | ``` 29 | 30 | After running this command, you can check status of the containers by 31 | 32 | ``` 33 | docker-compose ps 34 | ``` 35 | 36 | ### Test setup 37 | After both the containers are running successfully, use [mc](https://docs.minio.io/docs/minio-client-quickstart-guide) to setup event notifications and see it notifications in action. 38 | 39 | #### Add mc alias 40 | Add current Minio server as host by 41 | 42 | ```sh 43 | mc config host add myminio http://172.24.0.3:9000 minio minio123 44 | ``` 45 | 46 | #### Create a bucket 47 | 48 | ```sh 49 | mc mb myminio/test 50 | ``` 51 | 52 | #### Set up notifications 53 | Below event will notify Elasticsearch of any object being created, accessed, or deleted from `test` bucket. 54 | 55 | ```sh 56 | mc events add myminio/test arn:minio:sqs:us-east-1:1:elasticsearch 57 | ``` 58 | #### Upload an object 59 | Let's upload an object to `test` bucket and see if we get the notifications in Elasticsearch. 60 | 61 | ```sh 62 | mc cp ./testfile myminio/test/testfile 63 | ``` 64 | #### Check notification with curl 65 | You should now see the notification available in Elasticsearch index topic `minio_index`. 66 | 67 | ```sh 68 | curl "http://localhost:9200/minio_index/_search?pretty=true" 69 | ``` 70 | 71 | ### Stop the environment 72 | Once you are done, turn off running containers, by 73 | 74 | ``` 75 | docker-compose down 76 | ``` -------------------------------------------------------------------------------- /minio-elasticsearch/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "19", 3 | "credential": { 4 | "accessKey": "minio", 5 | "secretKey": "minio123" 6 | }, 7 | "region": "us-east-1", 8 | "browser": "on", 9 | "logger": { 10 | "console": { 11 | "enable": true 12 | }, 13 | "file": { 14 | "enable": false, 15 | "filename": "" 16 | } 17 | }, 18 | "notify": { 19 | "elasticsearch": { 20 | "1": { 21 | "enable": true, 22 | "format": "namespace", 23 | "url": "http://elasticsearch:9200", 24 | "index": "minio_index" 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /minio-elasticsearch/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | elasticsearch: 5 | image: docker.elastic.co/elasticsearch/elasticsearch:5.6.3 6 | environment: 7 | - "discovery.type=single-node" 8 | - "xpack.security.enabled=false" 9 | ports: 10 | - "9200:9200" 11 | - "9300:9300" 12 | 13 | minio: 14 | image: minio/minio 15 | depends_on: 16 | - elasticsearch 17 | ports: 18 | - "9000:9000" 19 | volumes: 20 | - minio-data:/export 21 | - minio-config:/root/.minio 22 | entrypoint: > 23 | /bin/sh -c " 24 | curl https://raw.githubusercontent.com/nitisht/minio-compose/master/wait-for.sh -o wait-for.sh; 25 | curl https://raw.githubusercontent.com/nitisht/minio-compose/master/minio-elasticsearch/config.json -o /root/.minio/config.json; 26 | chmod +x wait-for.sh; 27 | ./wait-for.sh elasticsearch:9200 -- /usr/bin/docker-entrypoint.sh minio server /export; 28 | " 29 | 30 | volumes: 31 | minio-data: 32 | minio-config: -------------------------------------------------------------------------------- /minio-kafka/README.md: -------------------------------------------------------------------------------- 1 | # minio-kafka 2 | 3 | Setup Minio + Apache Kafka for testing bucket notifications. 4 | 5 | ## Prerequisites 6 | - Docker installed (Docker version 17.05.0-ce on Linux) 7 | - docker-compose installed (1.8.0) 8 | 9 | ## Setup Minio and Apache Kafka with docker-compose 10 | We'll use docker-compose to set up Minio and Kafka containers. Download the [docker-compose.yml](./docker-compose.yaml) file in your working directory. This docker-compose file declares two containers. 11 | 12 | First one, `kafka` runs Kafka image developed by Spotify team (it includes Zookeeper). It exposes itself under `kafka` hostname, with two environment variables set: 13 | 14 | ``` 15 | ADVERTISED_HOST: kafka 16 | ADVERTISED_PORT: 9092 17 | ``` 18 | 19 | Those two describe to which hostname the Kafka server should respond from within the container. 20 | 21 | Second container, minio runs latest Minio server. It needs to connect to the running Kafka server, that's why there is the `depends_on` entry in docker-compose. 22 | 23 | ### Start the environment 24 | Once the `docker-compose.yml` file is ready, navigate to working directory via terminal and run: 25 | 26 | ``` 27 | docker-compose up 28 | ``` 29 | 30 | After running this command, you can check status of the containers by 31 | 32 | ``` 33 | docker-compose ps 34 | ``` 35 | 36 | ### Test setup 37 | After both the containers are running successfully, use [mc](https://docs.minio.io/docs/minio-client-quickstart-guide) to setup event notifications and see it notifications in action. 38 | 39 | #### Add mc alias 40 | Add current Minio server as host by 41 | 42 | ```sh 43 | mc config host add myminio http://172.24.0.3:9000 minio minio123 44 | ``` 45 | 46 | #### Create a bucket 47 | 48 | ```sh 49 | mc mb myminio/test 50 | ``` 51 | 52 | #### Set up notifications 53 | Below event will notify Kafka of any object being created, accessed, or deleted from `test` bucket. 54 | 55 | ```sh 56 | mc events add myminio/test arn:minio:sqs:us-east-1:1:kafka 57 | ``` 58 | #### Upload an object 59 | Let's upload an object to `test` bucket and see if we get the notifications in Kafka. 60 | 61 | ```sh 62 | mc cp ./testfile myminio/test/testfile 63 | ``` 64 | #### Check notification with Kafka 65 | You should now see the notification available in Kafka topic `minio-topic`. Check using the [Kafkacat](https://github.com/edenhill/kafkacat) tool. 66 | 67 | ```sh 68 | kafkacat -C -b localhost:9092 -t minio-topic 69 | ``` 70 | 71 | ### Stop the environment 72 | Once you are done, turn off running containers, by 73 | 74 | ``` 75 | docker-compose down 76 | ``` -------------------------------------------------------------------------------- /minio-kafka/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "19", 3 | "credential": { 4 | "accessKey": "minio", 5 | "secretKey": "minio123" 6 | }, 7 | "region": "us-east-1", 8 | "browser": "on", 9 | "logger": { 10 | "console": { 11 | "enable": true 12 | }, 13 | "file": { 14 | "enable": false, 15 | "filename": "" 16 | } 17 | }, 18 | "notify": { 19 | "kafka": { 20 | "1": { 21 | "enable": true, 22 | "brokers": ["kafka:9092"], 23 | "topic": "minio-topic" 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /minio-kafka/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | kafka: 5 | image: spotify/kafka 6 | environment: 7 | - ADVERTISED_HOST=172.17.0.1 8 | - ADVERTISED_PORT=9092 9 | ports: 10 | - "2181:2181" 11 | - "9092:9092" 12 | 13 | minio: 14 | image: minio/minio 15 | depends_on: 16 | - kafka 17 | ports: 18 | - "9000:9000" 19 | volumes: 20 | - minio-data:/export 21 | - minio-config:/root/.minio 22 | entrypoint: > 23 | /bin/sh -c " 24 | curl https://raw.githubusercontent.com/nitisht/minio-compose/master/wait-for.sh -o wait-for.sh; 25 | curl https://raw.githubusercontent.com/nitisht/minio-compose/master/minio-kafka/config.json -o /root/.minio/config.json; 26 | chmod +x wait-for.sh; 27 | ./wait-for.sh kafka:9092 -- /usr/bin/docker-entrypoint.sh minio server /export; 28 | " 29 | 30 | volumes: 31 | minio-data: 32 | minio-config: -------------------------------------------------------------------------------- /minio-mqtt/README.md: -------------------------------------------------------------------------------- 1 | # minio-mqtt 2 | 3 | Setup Minio + MQTT for testing bucket notifications. 4 | 5 | ## Prerequisites 6 | - Docker installed (Docker version 17.05.0-ce on Linux) 7 | - docker-compose installed (1.8.0) 8 | 9 | ## Setup Minio and MQTT with docker-compose 10 | We'll use docker-compose to set up Minio and MQTT containers. Download the [docker-compose.yml](./docker-compose.yaml) file in your working directory. This docker-compose file declares two containers. 11 | 12 | First one, `mqtt` runs official image. It exposes itself under `mqtt` hostname. 13 | 14 | Second container, `minio` runs latest Minio server. It needs to connect to the running MQTT server, that's why there is the `depends_on` entry in docker-compose. 15 | 16 | ### Start the environment 17 | Once the `docker-compose.yml` file is ready, navigate to working directory via terminal and run: 18 | 19 | ``` 20 | docker-compose up 21 | ``` 22 | 23 | After running this command, you can check status of the containers by 24 | 25 | ``` 26 | docker-compose ps 27 | ``` 28 | 29 | ### Test setup 30 | After both the containers are running successfully, use [mc](https://docs.minio.io/docs/minio-client-quickstart-guide) to setup event notifications and see it notifications in action. 31 | 32 | #### Add mc alias 33 | Add current Minio server as host by 34 | 35 | ```sh 36 | mc config host add myminio http://172.24.0.3:9000 minio minio123 37 | ``` 38 | 39 | #### Create a bucket 40 | 41 | ```sh 42 | mc mb myminio/test 43 | ``` 44 | 45 | #### Set up notifications 46 | Below event will notify MQTT of any object being created, accessed, or deleted from `test` bucket. 47 | 48 | ```sh 49 | mc events add myminio/test arn:minio:sqs:us-east-1:1:mqtt 50 | ``` 51 | 52 | #### Test using paho-mqtt library 53 | Use the program [mqtt.py](./mqtt.py) to read notifications from `mqtt` 54 | 55 | ```py 56 | python mqtt.py 57 | Connected with result code 0 58 | ``` 59 | 60 | #### Upload an object 61 | Open another terminal and upload an object to `test` bucket and see if we get the notifications in MQTT. 62 | 63 | ```sh 64 | mc cp ./testfile myminio/test/testfile 65 | ``` 66 | 67 | You should see the notifications sent out to `mqtt` in the `python` program terminal. 68 | 69 | ### Stop the environment 70 | Once you are done, turn off running containers, by 71 | 72 | ``` 73 | docker-compose down 74 | ``` -------------------------------------------------------------------------------- /minio-mqtt/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "19", 3 | "credential": { 4 | "accessKey": "minio", 5 | "secretKey": "minio123" 6 | }, 7 | "region": "us-east-1", 8 | "browser": "on", 9 | "logger": { 10 | "console": { 11 | "enable": true 12 | }, 13 | "file": { 14 | "enable": false, 15 | "filename": "" 16 | } 17 | }, 18 | "notify": { 19 | "mqtt": { 20 | "1": { 21 | "enable": true, 22 | "broker": "tcp://mqtt:1883", 23 | "topic": "minio_events", 24 | "qos": 1, 25 | "clientId": "minio", 26 | "username": "", 27 | "password": "" 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /minio-mqtt/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | mqtt: 5 | image: eclipse-mosquitto 6 | ports: 7 | - "1883:1883" 8 | - "9001:9001" 9 | 10 | minio: 11 | image: minio/minio 12 | depends_on: 13 | - mqtt 14 | ports: 15 | - "9000:9000" 16 | volumes: 17 | - minio-data:/export 18 | - minio-config:/root/.minio 19 | entrypoint: > 20 | /bin/sh -c " 21 | curl https://raw.githubusercontent.com/nitisht/minio-compose/master/wait-for.sh -o wait-for.sh; 22 | curl https://raw.githubusercontent.com/nitisht/minio-compose/master/minio-mqtt/config.json -o /root/.minio/config.json; 23 | chmod +x wait-for.sh; 24 | ./wait-for.sh mqtt:1883 -- /usr/bin/docker-entrypoint.sh minio server /export; 25 | " 26 | 27 | volumes: 28 | minio-data: 29 | minio-config: -------------------------------------------------------------------------------- /minio-mqtt/mqtt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import print_function 3 | import paho.mqtt.client as mqtt 4 | 5 | # The callback for when the client receives a CONNACK response from the server. 6 | def on_connect(client, userdata, flags, rc): 7 | print("Connected with result code", rc) 8 | 9 | # Subscribing in on_connect() means that if we lose the connection and 10 | # reconnect then subscriptions will be renewed. 11 | client.subscribe("minio_events") 12 | 13 | # The callback for when a PUBLISH message is received from the server. 14 | def on_message(client, userdata, msg): 15 | print(msg.payload) 16 | 17 | client = mqtt.Client() 18 | client.on_connect = on_connect 19 | client.on_message = on_message 20 | 21 | client.connect("127.0.0.1", 1883, 60) 22 | 23 | # Blocking call that processes network traffic, dispatches callbacks and 24 | # handles reconnecting. 25 | # Other loop*() functions are available that give a threaded interface and a 26 | # manual interface. 27 | client.loop_forever() -------------------------------------------------------------------------------- /minio-nats/README.md: -------------------------------------------------------------------------------- 1 | # minio-nats 2 | 3 | Setup Minio + Nats for testing bucket notifications. 4 | 5 | ## Prerequisites 6 | - Docker installed (Docker version 17.05.0-ce on Linux) 7 | - docker-compose installed (1.8.0) 8 | 9 | ## Setup Minio and Nats with docker-compose 10 | We'll use docker-compose to set up Minio and Nats containers. Download the [docker-compose.yml](./docker-compose.yaml) file in your working directory. This docker-compose file declares two containers. 11 | 12 | First one, `nats` runs official image. It exposes itself under `nats` hostname, with port `4222` exposed. Nats username and password is set to `user` and `password`. 13 | 14 | Second container, `minio` runs latest Minio server. It needs to connect to the running Nats server, that's why there is the `depends_on` entry in docker-compose. 15 | 16 | ### Start the environment 17 | Once the `docker-compose.yml` file is ready, navigate to working directory via terminal and run: 18 | 19 | ``` 20 | docker-compose up 21 | ``` 22 | 23 | After running this command, you can check status of the containers by 24 | 25 | ``` 26 | docker-compose ps 27 | ``` 28 | 29 | ### Test setup 30 | After both the containers are running successfully, use [mc](https://docs.minio.io/docs/minio-client-quickstart-guide) to setup event notifications and see it notifications in action. 31 | 32 | #### Add mc alias 33 | Add current Minio server as host by 34 | 35 | ```sh 36 | mc config host add myminio http://172.24.0.3:9000 minio minio123 37 | ``` 38 | 39 | #### Create a bucket 40 | 41 | ```sh 42 | mc mb myminio/test 43 | ``` 44 | 45 | #### Set up notifications 46 | Below event will notify Nats of any object being created, accessed, or deleted from `test` bucket. 47 | 48 | ```sh 49 | mc events add myminio/test arn:minio:sqs:us-east-1:1:nats 50 | ``` 51 | 52 | #### Test notifications 53 | Use the file [nats.go](./nats.go) to test events. Run the file using 54 | 55 | ```go 56 | go run nats.go 57 | ``` 58 | 59 | You should see the notifications sent out to this terminal after files are updated. 60 | 61 | #### Upload an object 62 | Open another terminal and upload an object to `test` bucket and see if we get the notifications in Nats. 63 | 64 | ```sh 65 | mc cp ./testfile myminio/test/testfile 66 | ``` 67 | 68 | ### Stop the environment 69 | Once you are done, turn off running containers, by 70 | 71 | ``` 72 | docker-compose down 73 | ``` -------------------------------------------------------------------------------- /minio-nats/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "19", 3 | "credential": { 4 | "accessKey": "minio", 5 | "secretKey": "minio123" 6 | }, 7 | "region": "us-east-1", 8 | "browser": "on", 9 | "logger": { 10 | "console": { 11 | "enable": true 12 | }, 13 | "file": { 14 | "enable": false, 15 | "filename": "" 16 | } 17 | }, 18 | "notify": { 19 | "nats": { 20 | "1": { 21 | "enable": true, 22 | "address": "nats:4222", 23 | "subject": "minio_events", 24 | "username": "user", 25 | "password": "password", 26 | "token": "", 27 | "secure": false, 28 | "pingInterval": 0, 29 | "streaming": { 30 | "enable": false, 31 | "clusterID": "", 32 | "clientID": "", 33 | "async": false, 34 | "maxPubAcksInflight": 0 35 | } 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /minio-nats/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | nats: 5 | image: nats 6 | entrypoint: "/gnatsd -DV --user user --pass password" 7 | ports: 8 | - "8222:8222" 9 | - "4222:4222" 10 | 11 | minio: 12 | image: minio/minio 13 | depends_on: 14 | - nats 15 | ports: 16 | - "9000:9000" 17 | volumes: 18 | - minio-data:/export 19 | - minio-config:/root/.minio 20 | entrypoint: > 21 | /bin/sh -c " 22 | curl https://raw.githubusercontent.com/nitisht/minio-compose/master/wait-for.sh -o wait-for.sh; 23 | curl https://raw.githubusercontent.com/nitisht/minio-compose/master/minio-nats/config.json -o /root/.minio/config.json; 24 | chmod +x wait-for.sh; 25 | ./wait-for.sh nats:4222 -- /usr/bin/docker-entrypoint.sh minio server /export; 26 | " 27 | 28 | volumes: 29 | minio-data: 30 | minio-config: -------------------------------------------------------------------------------- /minio-nats/nats.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Import Go and NATS packages 4 | import ( 5 | "log" 6 | "runtime" 7 | 8 | "github.com/nats-io/nats" 9 | ) 10 | 11 | func main() { 12 | 13 | // Create server connection 14 | natsConnection, _ := nats.Connect("nats://user:password@localhost:4222") 15 | log.Println("Connected") 16 | 17 | // Subscribe to subject 18 | log.Printf("Subscribing to subject 'minio_events'\n") 19 | natsConnection.Subscribe("minio_events", func(msg *nats.Msg) { 20 | 21 | // Handle the message 22 | log.Printf("Received message '%s\n", string(msg.Data)+"'") 23 | }) 24 | 25 | // Keep the connection alive 26 | runtime.Goexit() 27 | } 28 | -------------------------------------------------------------------------------- /minio-redis/README.md: -------------------------------------------------------------------------------- 1 | # minio-redis 2 | 3 | Setup Minio + Redis for testing bucket notifications. 4 | 5 | ## Prerequisites 6 | - Docker installed (Docker version 17.05.0-ce on Linux) 7 | - docker-compose installed (1.8.0) 8 | 9 | ## Setup Minio and Redis with docker-compose 10 | We'll use docker-compose to set up Minio and Redis containers. Download the [docker-compose.yml](./docker-compose.yaml) file in your working directory. This docker-compose file declares two containers. 11 | 12 | First one, `redis_db` runs official image. It exposes itself under `redis_db` hostname, with environment variable `REDIS_PASS_FILE` set to a file containing redis password. 13 | 14 | Second container, `minio` runs latest Minio server. It needs to connect to the running Redis server, that's why there is the `depends_on` entry in docker-compose. 15 | 16 | ### Start the environment 17 | Once the `docker-compose.yml` file is ready, navigate to working directory via terminal and run: 18 | 19 | ``` 20 | docker-compose up 21 | ``` 22 | 23 | After running this command, you can check status of the containers by 24 | 25 | ``` 26 | docker-compose ps 27 | ``` 28 | 29 | ### Test setup 30 | After both the containers are running successfully, use [mc](https://docs.minio.io/docs/minio-client-quickstart-guide) to setup event notifications and see it notifications in action. 31 | 32 | #### Add mc alias 33 | Add current Minio server as host by 34 | 35 | ```sh 36 | mc config host add myminio http://172.24.0.3:9000 minio minio123 37 | ``` 38 | 39 | #### Create a bucket 40 | 41 | ```sh 42 | mc mb myminio/test 43 | ``` 44 | 45 | #### Set up notifications 46 | Below event will notify Redis of any object being created, accessed, or deleted from `test` bucket. 47 | 48 | ```sh 49 | mc events add myminio/test arn:minio:sqs:us-east-1:1:redis 50 | ``` 51 | 52 | #### Set up redis-cli 53 | Install `redis-cli` using 54 | 55 | ```sh 56 | sudo apt-get install redis-tools 57 | ``` 58 | 59 | Then start it to monitor the `redis` instance we launched earlier 60 | 61 | ```sh 62 | redis-cli -a yoursecret 63 | 127.0.0.1:6379> monitor 64 | OK 65 | ``` 66 | 67 | #### Upload an object 68 | Open another terminal and upload an object to `test` bucket and see if we get the notifications in Redis. 69 | 70 | ```sh 71 | mc cp ./testfile myminio/test/testfile 72 | ``` 73 | 74 | You should see the notifications sent out to `redis` in the `redis-cli` monitoring terminal. 75 | 76 | 77 | ### Stop the environment 78 | Once you are done, turn off running containers, by 79 | 80 | ``` 81 | docker-compose down 82 | ``` -------------------------------------------------------------------------------- /minio-redis/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "19", 3 | "credential": { 4 | "accessKey": "minio", 5 | "secretKey": "minio123" 6 | }, 7 | "region": "us-east-1", 8 | "browser": "on", 9 | "logger": { 10 | "console": { 11 | "enable": true 12 | }, 13 | "file": { 14 | "enable": false, 15 | "filename": "" 16 | } 17 | }, 18 | "notify": { 19 | "redis": { 20 | "1": { 21 | "enable": true, 22 | "format": "namespace", 23 | "address": "redis_db:6379", 24 | "password": "yoursecret", 25 | "key": "minio_key" 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /minio-redis/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | redis_db: 5 | image: redis 6 | ports: 7 | - "6379:6379" 8 | environment: 9 | REDIS_PASS_FILE: /run/secrets/redis-pass 10 | volumes: 11 | - './secret:/run/secrets/redis-pass' 12 | command: [ 13 | "bash", "-c", 14 | ' 15 | docker-entrypoint.sh 16 | --requirepass "$$(cat $$REDIS_PASS_FILE)" 17 | ' 18 | ] 19 | 20 | minio: 21 | image: minio/minio 22 | depends_on: 23 | - redis_db 24 | ports: 25 | - "9000:9000" 26 | volumes: 27 | - minio-data:/export 28 | - minio-config:/root/.minio 29 | entrypoint: > 30 | /bin/sh -c " 31 | curl https://raw.githubusercontent.com/nitisht/minio-compose/master/wait-for.sh -o wait-for.sh; 32 | curl https://raw.githubusercontent.com/nitisht/minio-compose/master/minio-redis/config.json -o /root/.minio/config.json; 33 | chmod +x wait-for.sh; 34 | ./wait-for.sh redis_db:6379 -- /usr/bin/docker-entrypoint.sh minio server /export; 35 | " 36 | 37 | volumes: 38 | minio-data: 39 | minio-config: -------------------------------------------------------------------------------- /minio-redis/secret: -------------------------------------------------------------------------------- 1 | yoursecret -------------------------------------------------------------------------------- /wait-for.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TIMEOUT=40 4 | QUIET=0 5 | 6 | echoerr() { 7 | if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi 8 | } 9 | 10 | usage() { 11 | exitcode="$1" 12 | cat << USAGE >&2 13 | Usage: 14 | $cmdname host:port [-t timeout] [-- command args] 15 | -q | --quiet Do not output any status messages 16 | -t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout 17 | -- COMMAND ARGS Execute command with args after the test finishes 18 | USAGE 19 | exit "$exitcode" 20 | } 21 | 22 | wait_for() { 23 | command="$*" 24 | ip=$(getent hosts "${HOST}" | awk {'print $2'}) 25 | for i in $(seq $TIMEOUT) ; do 26 | echo "Attempting to connect to $HOST:$PORT - ${i}th time." 27 | nc -z "$ip" "$PORT" 28 | result=$? 29 | if [ $result -eq 0 ] ; then 30 | if [ -n "$command" ] ; then 31 | exec ${command} 32 | fi 33 | exit 0 34 | fi 35 | sleep 1 36 | done 37 | echo "Operation timed out" >&2 38 | exit 1 39 | } 40 | 41 | while [ $# -gt 0 ] 42 | do 43 | case "$1" in 44 | *:* ) 45 | HOST=$(printf "%s\n" "$1"| cut -d : -f 1) 46 | PORT=$(printf "%s\n" "$1"| cut -d : -f 2) 47 | shift 1 48 | ;; 49 | -t) 50 | TIMEOUT="$2" 51 | if [ "$TIMEOUT" = "" ]; then break; fi 52 | shift 2 53 | ;; 54 | --timeout=*) 55 | TIMEOUT="${1#*=}" 56 | shift 1 57 | ;; 58 | --) 59 | shift 60 | break 61 | ;; 62 | --help) 63 | usage 0 64 | ;; 65 | *) 66 | echoerr "Unknown argument: $1" 67 | usage 1 68 | ;; 69 | esac 70 | done 71 | 72 | if [ "$HOST" = "" -o "$PORT" = "" ]; then 73 | echoerr "Error: you need to provide a host and port to test." 74 | usage 2 75 | fi 76 | 77 | wait_for "$@" --------------------------------------------------------------------------------