In this blogpost you'll learn howto setup Minio as database for Medusa.
Introduction
MinIO is a High Performance Object Storage released under GNU Affero General Public License v3.0. It is API compatible with the Amazon S3 cloud storage service. It can handle unstructured data such as photos, videos, log files, backups, and container images with a current maximum supported object size of 5TB.
As beeing compatible with Amazon S3 Minio is a hot choice as data-storage.
Setup Medusa
First we gonna setup Medusajs. You can follow this Quickstart Guide to do so.
Setup Minio
Minio provides many install options you can refer the Documentation Page.
In this case we decide to install Minio and Medusa on macOS.
We're going to use Homebrew:
brew install minio/stable/minio
Starting the Minio Server:
export MINIO_CONFIG_ENV_FILE=/etc/default/minio
minio server --console-address :9090
Changing Minios port
Minios and Medusajs backend both us the same port 9000 to avoid a collision we're going to change Minios port to 9001.
minio server ~/minio --console-address :9090 --address :9001
Create a Minio bucket
We're going to create a bucket storing the Medusajs backend files.
- Log into the Minio Console
- Click on the create bucket button
- Enter the name of the bucket in the Bucket Namefield
- Click on the create bucket button
- on the buckets page click on the cog icon on the the top to configure the bucket.
- Click on the edit icon next to Access Policy.
- Change the selected value to public and click Set.
Generate Access Keys
- Click on Access Keys from the Minio Console
- Click on the "Create access key" button
Tihs is will open up a form with generated keys click on Create button.
A pop-up will show Access-Key and Secret-Key copy both as we will use them later.
Plugin installation
In the folder of your Medusa backend run the following command:
npm install medusa-file-minio
Then add the following environment variables in .env :
MINIO_ENDPOINT=<ENDPOINT>
MINIO_BUCKET=<BUCKET>
MINIO_ACCESS_KEY=<ACCESS_KEY>
MINIO_SECRET_KEY=<SECRET_KEY>
Finally configure medusa-config.js to include the plugin with required options:
const plugins = [
// ...
{
resolve: `medusa-file-minio`,
options: {
endpoint: process.env.MINIO_ENDPOINT,
bucket: process.env.MINIO_BUCKET,
access_key_id: process.env.MINIO_ACCESS_KEY,
secret_access_key: process.env.MINIO_SECRET_KEY,
},
},
]
Thats it I hope you enjoyed this blogpost about using Minio as database for a Medusajs backend.
Feel free to follow me on Twitter
Top comments (0)