DEV Community

Cover image for Setting up Minio as a database for Medusajs
Norbert Fuhs
Norbert Fuhs

Posted on

1 1 1 1 1

Setting up Minio as a database for Medusajs

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
Enter fullscreen mode Exit fullscreen mode

Starting the Minio Server:

export MINIO_CONFIG_ENV_FILE=/etc/default/minio
minio server --console-address :9090
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Create a Minio bucket

We're going to create a bucket storing the Medusajs backend files.

  1. Log into the Minio Console
  2. Click on the create bucket button
  3. Enter the name of the bucket in the Bucket Namefield
  4. Click on the create bucket button
  5. on the buckets page click on the cog icon on the the top to configure the bucket.
  6. Click on the edit icon next to Access Policy.
  7. Change the selected value to public and click Set.

Generate Access Keys

  1. Click on Access Keys from the Minio Console
  2. Click on the "Create access key" button
  3. Tihs is will open up a form with generated keys click on Create button.

  4. 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
Enter fullscreen mode Exit fullscreen mode

Then add the following environment variables in .env :

MINIO_ENDPOINT=<ENDPOINT>
MINIO_BUCKET=<BUCKET>
MINIO_ACCESS_KEY=<ACCESS_KEY>
MINIO_SECRET_KEY=<SECRET_KEY>
Enter fullscreen mode Exit fullscreen mode

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,
    },
  },
]
Enter fullscreen mode Exit fullscreen mode

Thats it I hope you enjoyed this blogpost about using Minio as database for a Medusajs backend.

Feel free to follow me on Twitter

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay