From c52288bf797d9ab256d33fb30add93e34e99f713 Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Fri, 8 Nov 2024 12:37:42 +0530 Subject: [PATCH] feat: update backend server guide --- www/apps/book/app/learn/deployment/page.mdx | 29 +++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/www/apps/book/app/learn/deployment/page.mdx b/www/apps/book/app/learn/deployment/page.mdx index 4c91773771786..8cee284826748 100644 --- a/www/apps/book/app/learn/deployment/page.mdx +++ b/www/apps/book/app/learn/deployment/page.mdx @@ -12,7 +12,7 @@ A standard Medusa project is made up of: - Medusa application: The Medusa server and the Medusa Admin. - One or more storefronts - + ![Diagram showcasing the connection between the three deployed components](https://res.cloudinary.com/dza7lstvk/image/upload/v1708600807/Medusa%20Book/deployment-options_ceuuvo.jpg) You can either deploy the Medusa application fully (server with the admin), or deploy the Medusa Admin separately. The storefront is always deployed separately. @@ -21,11 +21,9 @@ You can either deploy the Medusa application fully (server with the admin), or d ## Deploying the Medusa Server -You must deploy the Medusa server before the admin or storefront, as both of them connect to it and won’t work without a deployed Medusa server URL. - -![Diagram showcasing how the Medusa server and its associated services would be deployed](https://res.cloudinary.com/dza7lstvk/image/upload/v1708600972/Medusa%20Book/backend_deployment_pgexo3.jpg) +The `npm run build` command will compile your Medusa backend server and create a static bundle for the Admin dashboard. The output is written inside the `.medusa/server` directory, and you can deploy this directory without relying on the original TypeScript source. -The Medusa server must be deployed to a hosting provider supporting Node.js server deployments, such as Railway, DigitalOcean, AWS, Heroku, etc… +Following are the hypothetical steps for creating and running the production build. The actual setup may vary depending upon your deployment host. However, the goal is to follow the following steps and run the production server from within the `.medusa/server` directory. @@ -33,6 +31,27 @@ For optimal experience, make sure that the hosting provider and plan offer at le +```sh +# First create a build +npm run build + +# Cd into the output directory. + +cd .medusa/server + +# Install production dependencies + +npm ci --omit=dev + +# Define environment variables before you attempt to start the server + +# Run production server + +npx medusa start +``` + +### Additional services + Your server connects to a PostgreSQL database, Redis, and other services relevant for your setup. Most hosting providers support deploying and managing these databases along with your Medusa server (such as Railway and DigitalOcean). Refer to [this reference](!resources!/deployment) to find how-to deployment guides for specific hosting providers.