A Step-by-Step Tutorial on How to Deploy a Medusa Server on DigitalOcean Droplet with Easypanel

By Grzegorz Tomaka

Featured image

Learn how to deploy Medusa on DigitalOcean Droplet with Easypanel.

Medusa.js is an open-source, self-hosted, headless commerce engine designed to build customizable eCommerce experiences.

While there are many ways to deploy a Medusa server, at Rigby we have found it very convenient to use DigitalOcean Droplets with Easypanel to create our development environments.

This guide's purpose is to walk you through the steps of deploying a Medusa server on a DigitalOcean Droplet using Easypanel.

What is DigitalOcean Droplet

dodroplet.png

A DigitalOcean Droplet is a scalable virtual machine that runs on DigitalOcean's cloud platform. It offers a flexible and cost-effective way to deploy applications and websites, with the ability to choose from various sizes and configurations to match your specific needs. Droplets can be quickly created, destroyed, and scaled, making them an ideal choice for projects ranging from small personal blogs to large-scale enterprise applications.

What is Easypanel

easypanel.png

Easypanel is a Docker-based web control panel that simplifies server and application management. It's like a self-hosted Heroku, making deploying applications in various programming languages easier without extensive server administration knowledge.

Before You Begin

Ensure you have:

  • A GitHub account and a repository. Your repository should be a clone of medusa-starter-default.
  • A DigitalOcean account.

Configuring Your Medusa Server Repository

  1. Uncomment the redis_url in medusa-config.js.
medusa-config.png
  1. Add a Dockerfile to your project. Here's an example Dockerfile you could use:
FROM node:latest

WORKDIR /app/medusa

COPY . .

RUN apt-get update && apt-get install -y python3 python3-pip python-is-python3

RUN yarn global add @medusajs/medusa-cli

RUN yarn

RUN yarn build

CMD medusa migrations run && yarn start

Setting Up a Droplet with EasyPanel

The quickest way to get started is through DigitalOcean's One-Click Marketplace. Choose the pre-configured Ubuntu setup with Easypanel to skip manual server setup and application installation.

Creating Your Droplet

  1. Click “Create EasyPanel Droplet.”
one-click-easypanel.png
  1. Select your nearest datacenter.
datacenter.png
  1. Ensure the Easypanel image is selected.
easypanel-image.png
  1. Choose your authentication method.
authentication-method.png
  1. Pick a server size that fits your development needs.
server-size.png
  1. Click “Create Droplet.” Wait a bit, and your Droplet with Easypanel will be ready.
medusa-droplet.png

Setting Up Easypanel

  1. Access the Easypanel management console and click “Get started.” If Easypanel isn't immediately accessible, give it a few more minutes.
medusa-easypanel.png
  1. Use “Quick access to EasyPanel” to set up your account.
quick-access.png
  1. Set up an Easypanel account.
setup-easypanel.png

Adding a GitHub Token

(Required for private repositories) In EasyPanel, go to settings and add your GitHub Token. If you don’t have one, create it here.

github-token.png

Creating Your Project in Easypanel

Click “Create project” and name it descriptively.

create-project.png

Adding Postgres

  1. Click “+ Service” and select “Postgres.”
postgres-easypanel.png
  1. Enter a name and password, then click “Create.” Your database will soon be ready.
medusa-db-easypanel.png

Setting Up Redis

  1. Add the Redis service by selecting it after clicking “+ Service.”
  2. Name it, set a password, and create it. Your Redis will be live shortly.
medusa-redis-easypanel.png

Creating an App

  1. Add an app by clicking “+ Service” and then “App.”
medusa-app-easypanel.png
  1. Name your app, create it, and it'll start setting up.
medusa-app-easypanel-name.png

Configuring Your App

  1. In the Source section, choose “Github” and enter your details.
github-easypanel.png
  1. In Build options, select Dockerfile, enter its name, and save.
dockerfile-medusa.png
  1. Add essential environment variables like JWT_SECRET, COOKIE_SECRET, NODE_ENV, DATABASE_URL, and REDIS_URL. Create a .env file and save.
env-medusa.png

💡 Finding Your Database and Redis URLs

These are located in the credentials section of the containers you've set up.

medusa-db-credentials.png

Deploying Your App

With everything configured, hit Deploy and monitor the progress in the “Deployments” section.

medusa-deployment.png

Testing Your Environment

  1. Access your app via the “Open link” button.
medusa-open.png
  1. Append /store/products to your URL and check for a proper JSON response.

Final Steps

Your setup is complete! Opt for auto-deploy to keep your environment up-to-date with branch changes.

autodeploy-medusa.png

And that's it—you're all set for Medusa development! 🎉

Do you need help with Medusa development?

Let's talk about your project

Other blog posts

Building Automating USPS Shipping Label Generation in Medusa

Explore how we created custom software solution for automated USPS shipping label generation in Medusa...

Building a Custom Order Mechanism for Trading Events in Medusa

In this article, we’ll show you how we created a custom order mechanism for trading events in Medusa...

Tell us about your project

Got a project in mind? Let's make it happen!

By clicking “Send Message” you grant us, i.e., Rigby, consent for email marketing of our services as part of the communication regarding your project. You may withdraw your consent, for example via hello@rigbyjs.com.
More information
placeholder

Grzegorz Tomaka

Co-CEO & Co-founder

LinkedIn icon
placeholder

Jakub Zbaski

Co-CEO & Co-founder

LinkedIn icon