Dockerfile
We’ll use the official minio/minio Docker image, but with a custom start command. Here’s the Dockerfile to build that:server /data --console-address :9001, so that the server runs using the /data directory for storage. We’ll get to that directory in a moment. The --console-address flag specifies which port to run the web-based admin console on. Otherwise, MinIO chooses a random port. See below for how to access this panel after MinIO has been deployed.
Initializing the app
Initialize the app withfly launch. Here we use flags to specify an app name and the organization it belongs to. The most important flag is --no-deploy, because we still have Things to Do before we deploy:
(Un)configure networking
There’s no need for this app to be accessible from the public internet, if you run your object storage within the same Fly IPV6 private network as the app(s) that want to connect to it. Delete the[http_service] block in fly.toml. Now the Fly proxy won’t pass any requests to the app from outside your private network.
Disk storage
The application’s VM and image are ephemeral. When the app is stopped or moved it loses any data written to its file system. For persistent storage, provision a volume with a name and a size in the same region as the app./data directory, by appending to fly.toml:
Secrets
MinIO uses environment variablesMINIO_ROOT_USER and MINIO_ROOT_PASSWORD to store administrator login information. Instead of using normal environment variables, use fly secrets set to pass these sensitive values to the server in encrypted form. They’ll only be decrypted at runtime.
Deployment
Now the app is, in fact, ready to deploy:Accessing the web-based MinIO admin panel
MinIO has a web interface. It’s served on the port specified by--console-address in the Dockerfile, which we set to 9001. We can access this panel over our private WireGuard network.
One way to do this is to set up a regular WireGuard tunnel, and visit http://my-minio.internal:9001 in the browser.
A simpler way is to use flyctl’s user-mode WireGuard to proxy a local port to the app:
localhost:9001 with the browser.
Log into the admin panel with the MINIO_ROOT_USER and MINIO_ROOT_PASSWORD values set using Fly Secrets above, and you can create buckets, do administration, and upload and download files right from the browser.
Using the mc MinIO Client
You can connect to your MinIO with the mc command-line MinIO Client.
MinIO listens for non-browser connections on port 9000, by default. If you’re connecting using fly proxy, you’ll have to proxy port 9000 to use mc.
You can set up an alias to connect more conveniently to your MinIO.
If you’re using fly proxy:
readwrite permissions. This user won’t have full admin privileges, but will be able to create and save files to buckets.
<NEW-USER> can log in and read the contents of your buckets. Make that read-write access:
Multi-node deployment
What if you want high availability? You can deploy MinIO in a multi-node configuration! Each node needs to know where to find the other nodes in the configuration. This can be done using either hostnames or IP addresses, but MinIO requires that they’re sequential. We’ll use hostnames since we can modify/etc/hosts to ensure their “sequential-ness”. Ensuring sequential IP addresses is much more tricky!
There’s going to be a bit of back-and-forth here since we don’t have any private IPs to put into /etc/hosts until we create the Machines, but we need a Dockerfile to create them in the first place. Bear with me!
Dockerfile
We need to change theCMD in the Dockerfile to declare that we intend to run a multi-node deployment:
Disk Storage
Create 3 volumes, one for each node:Initial deployment
You need to deploy and scale the app in order for private IPs to be assigned. First, deploy:Private networking
One of the great things about Fly.io is the private networking we get for free. We’ll use our Machines’ private IPs to define hostnames in/etc/hosts which our nodes will use to communicate with each other.
Get the private IPs of your Machines:
/etc/hosts directly in the Dockerfile, but Docker won’t let us do this at build time. Instead, we’ll create a script called run.sh that will add our host definitions at runtime:
Final deployment
Now update your Dockerfile to executerun.sh:
fly deploy, we should have a working multi-node MinIO deployment!
If you want to see it in action, try proxying to two different Machines. In one terminal:
http://localhost:9001 and http://localhost:9002 in separate browser tabs, and log in to both with your MINIO_ROOT_USER and MINIO_ROOT_PASSWORD.
Create a bucket in one tab and then refresh the other tab. If everything is working, you should see the bucket in both!