docs: changes to deployment + remove admin deployment guides (#10345)

* docs: change headings and text in deployment

* remove admin deployment guide

* generate changes
This commit is contained in:
Shahed Nasser
2024-11-28 14:48:10 +02:00
committed by GitHub
parent aca7907d81
commit 768f970926
9 changed files with 35 additions and 279 deletions
@@ -39,7 +39,7 @@ When you deploy your Medusa application, make sure your chosen hosting provider
1. PostgreSQL database: If your hosting provider doesn't support database hosting, you must find another hosting provider for the PostgreSQL database.
2. Redis database: If your hosting provider doesn't support database hosting, you must find another hosting provider for the Redis database.
3. Medusa application in server and worker mode. This means your hosting provider should support deploying two applications or instances from the same codebase.
5. If you're also hosting the Medusa Admin with the server, the hosting provider and plan should offer at least 2GB of RAM.
4. For optimal experience, the hosting provider and plan must offer at least 2GB of RAM.
---
@@ -68,18 +68,7 @@ Later, youll set different values of the `MEDUSA_WORKER_MODE` environment var
### Configure Medusa Admin
There are two cases where you may disable the Medusa Admin in your deployed Medusa application:
1. If you choose to host it separately.
2. In the Medusa application running in worker mode, as it doesnt need to run the admin.
<Note>
To host the admin with the Medusa application, the hosting provider and plan should offer at least 2GB of RAM.
</Note>
So, add the following configuration in `medusa-config.ts`:
You need to disable the Medusa Admin in the worker Medusa application, while keeping it enabled in the server Medusa application. So, add the following configuration in `medusa-config.ts`:
```ts title="medusa-config.ts"
module.exports = defineConfig({
@@ -208,7 +197,6 @@ JWT_SECRET=supersecret # TODO GENERATE SECURE SECRET
STORE_CORS= # STOREFRONT URL
ADMIN_CORS= # ADMIN URL
AUTH_CORS= # STOREFRONT AND ADMIN URLS, SEPARATED BY COMMAS
# change to false if you're hosting the admin with the application
DISABLE_MEDUSA_ADMIN=true
MEDUSA_WORKER_MODE=server
PORT=9000
@@ -220,9 +208,9 @@ Where:
- The value of `COOKIE_SECRET` and `JWT_SECRET` must be a randomly generated secret.
- `STORE_CORS`'s value is the URL of your storefront. If you dont have it yet, you can skip adding it for now.
- `ADMIN_CORS`'s value is the URL of the admin dashboard. If you dont have it yet, or youre deploying the admin with the Medusa application, you can skip adding it for now.
- `ADMIN_CORS`'s value is the URL of the admin dashboard, which is the same as the server Medusa application. You can add it later if you don't currently have it.
- `AUTH_CORS`'s value is the URLs of any application authenticating users, customers, or other actor types, such as the storefront and admin URLs. The URLs are separated by commas. If you dont have the URLs yet, you can set its value later.
- Change `DISABLE_MEDUSA_ADMIN` to `false` if youre hosting the admin with the Medusa application.
- Set `DISABLE_MEDUSA_ADMIN`'s value to `false` so that the admin is built with the server application.
- Set the PostgreSQL database's connection URL as the value of `DATABASE_URL`
- Set the Redis database's connection URL as the value of `REDIS_URL`.
@@ -240,11 +228,9 @@ If your hosting provider doesn't support setting a current-working directory, se
cd .medusa/server && npm run predeploy && npm run start
```
### Additional Configuration if Deploying with Admin
### Set Backend URL in Admin Configuration
If youre deploying the Medusa application in server mode with the admin, you have to make some changes after youve obtained the applications URL.
First, add the following configuration to `medusa-config.ts`:
After youve obtained the Medusa applications URL, add the following configuration to `medusa-config.ts`:
```ts title="medusa-config.ts"
module.exports = defineConfig({
@@ -299,7 +285,7 @@ REDIS_URL= # REDIS DATABASE URL
Where:
- The value of `COOKIE_SECRET` and `JWT_SECRET` must be a randomly generated secret.
- Keep `DISABLE_MEDUSA_ADMIN`'s value set to `true`, even if youre hosting the admin with the Medusa application.
- Set `DISABLE_MEDUSA_ADMIN`'s value to `true` so that the admin isn't built with the worker application.
- Set the PostgreSQL database's connection URL as the value of `DATABASE_URL`
- Set the Redis database's connection URL as the value of `REDIS_URL`.
@@ -323,9 +309,7 @@ cd .medusa/server && npm run predeploy && npm run start
Once the application is deployed and live, go to `<APP_URL>/health`, where `<APP_URL>` is the URL of the Medusa application in server mode. If the deployment was successful, youll see the `OK` response.
### Open Deployed Medusa Admin
If you deployed the Medusa Admin with the application, itll be available at `<APP_URL>/app`.
The Medusa Admin is also available at `<APP_URL>/app`.
---
+8 -44
View File
@@ -15,26 +15,22 @@ A standard Medusa project is made up of:
![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.
You deploy the Medusa application, with the server and admin, separately from the storefront.
---
## Deploying the Medusa Server
## Deploying the Medusa Application
You must deploy the Medusa server before the admin or storefront, as both of them connect to it and wont work without a deployed Medusa server URL.
You must deploy the Medusa application before the storefront, as it connects to the server and wont work without a deployed Medusa server URL.
The Medusa application must be deployed to a hosting provider supporting Node.js server deployments, such as Railway, DigitalOcean, AWS, Heroku, etc…
![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 Medusa server must be deployed to a hosting provider supporting Node.js server deployments, such as Railway, DigitalOcean, AWS, Heroku, etc…
<Note title="Tip">
For optimal experience, make sure that the hosting provider and plan offer at least 2GB of RAM.
</Note>
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).
When you deploy your Medusa application, you also deploy the Medusa Admin. For optimal experience, your hosting provider and plan must offer at least 2GB of RAM.
### How to Deploy Medusa?
Medusa Cloud is our managed services offering that makes deploying and operating Medusa applications possible without having to worry about configuring, scaling, and maintaining infrastructure. Medusa Cloud hosts your server, Admin dashboard, database, and Redis instance.
@@ -48,39 +44,7 @@ With Medusa Cloud, you maintain full customization control as you deploy your ow
[Sign up and learn more about Medusa Cloud](https://medusajs.com/contact)
To self-host Medusa, the [next chapter](./general/page.mdx) explains the general steps to deploy your Medusa application.
Refer to [this reference](!resources!/deployment) to find how-to deployment guides for general and specific hosting providers.
---
## Deploying the Medusa Admin
### Deploy Admin with the Server
The Medusa Admin can be deployed on the same hosting with the server.
In this scenario, make sure the hosting provider and plan of your choice provide at least 2GB of RAM, as the admin build requires high RAM usage.
![Diagram showcasing how the admin would be deployed along with the Medusa server.](https://res.cloudinary.com/dza7lstvk/image/upload/v1708601021/Medusa%20Book/admin_deployment_1_lyg4cp.jpg)
<Note title="Tip">
The [server deployment guides](!resources!/deployment) mention details on how to deploy the admin with the Medusa server.
</Note>
### Deploy Admin Separately
You can deploy the admin into a separate hosting provider or instance. The admin can be hosted on providers that support front-end websites and frameworks, such as Vercel.
<Note title="Important">
Per Vercels [license and plans](https://vercel.com/pricing), their free plan can only be used for personal, non-commercial projects. So, you can deploy the Medusa Admin on the free plan for development purposes, but for commercial projects, you must update your Vercel plan.
</Note>
Refer to [this reference](!resources!/deployment) to find how-to deployment guides for specific hosting providers.
To self-host Medusa, the [next chapter](./general/page.mdx) explains the general steps to deploy your Medusa application. Refer to [this reference](!resources!/deployment) to find how-to deployment guides for general and specific hosting providers.
---
@@ -1,142 +0,0 @@
---
sidebar_label: "Vercel"
---
import { Prerequisites } from "docs-ui"
export const metadata = {
title: `Deploy Medusa Admin to Vercel`,
}
# {metadata.title}
In this document, youll learn how to deploy the Medusa Admin to [Vercel](https://vercel.com).
<Prerequisites items={[
{
text: "Medusa applications codebase hosted on GitHub repository.",
link: "!docs!/learn/installation"
},
{
text: "Deployed Medusa application.",
link: "../../page.mdx#medusa-application"
},
]} />
## 1. Configure Admin in Medusa
In `medusa-config.ts`, set the following admin configuration:
```ts title="medusa-config.ts"
module.exports = defineConfig({
// ...
admin: {
disable: process.env.DISABLE_MEDUSA_ADMIN === "true",
backendUrl: process.env.MEDUSA_BACKEND_URL,
path: process.env.MEDUSA_ADMIN_PATH,
},
})
```
Where:
- You set `disable` to the environment variable `DISABLE_MEDUSA_ADMIN`. In the deployed Medusa application, you set the environment variables value to `true` to disable the admin, and when deploying the admin you set it to `false`.
- `backendUrl` will be the URL of the deployed Medusa backend.
- `path` is the base path of the admin, which is `/app` by default. When you set the environment variable `MEDUSA_ADMIN_PATH` later while deploying the admin, youll set it to `/`.
---
## 2. Add Vercel Rewrite
Create the file `vercel.json` in the root directory of your Medusa application with the following content:
```json title="vercel.json"
{
"rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}
```
---
## 3. Create Vercel Project
<Note>
Push all changes youve made in the previous step to the GitHub repository before proceeding.
</Note>
To create a Vercel project, on your Vercel dashboard:
1. Click on the Add New button at the top right.
2. Choose Project from dropdown.
3. In the list of GitHub repository shown, find the GitHub repository and click its Import button.
4. This shows a form to configure the project:
1. Choose Other for the Framework Preset field.
2. Keep the root directory to `.`
3. Expand the Build and Output Settings section:
- Set the Build Command field to the following:
```bash npm2yarn
npm run build --admin-only
```
- Set the Output Directory field to `.medusa/admin`.
- Set the Install Command field to the following:
```bash npm2yarn
npm install
```
4. Expand the Environment Variables section and add the following variables:
```bash
DISABLE_MEDUSA_ADMIN=false
MEDUSA_BACKEND_URL = # URL of deployed Medusa application
MEDUSA_ADMIN_PATH=/
```
Where the value of `MEDUSA_BACKEND_URL` is the URL to your deployed Medusa application.
Then, click the Deploy button to deploy the admin. This takes a couple of minutes. Once the deployment is done, click the Continue to Dashboard button.
---
## 4. Set Admin URL
Vercel generates a random domain name for your project. You can use it or [set a custom domain name](https://vercel.com/guides/how-do-i-add-a-custom-domain-to-my-vercel-project).
Once you have the admins domain name, you must set the `ADMIN_CORS` environment variable in the Medusa application to the admins URL:
```bash
ADMIN_CORS=https://admin-...
```
And add the admin URL to the `AUTH_CORS` environment variable in the Medusa application:
```bash
AUTH_CORS=<OTHER_URLS>,https://admin-...
```
Where `<OTHER_URLS>` are URLs added previously to `AUTH_CORS`, such as the URL of a storefront. URLs in `AUTH_CORS` are separated by a comma.
Then, redeploy the Medusa application.
---
## Test the Admin
To test the admin, open its URL and login with an admin users credentials.
<Note>
If you dont have an admin user on your Medusa application, use the [user command of the Medusa CLI tool](../../../medusa-cli/page.mdx#user).
</Note>
---
## Troubleshooting
If youre running into issues in your admin, find the logs in your Vercel projects dashboard under the Logs tab.
@@ -16,9 +16,8 @@ In this document, youll learn how to deploy your Medusa application to [Railw
1. PostgreSQL database.
2. Redis database.
3. Medusa application in server mode.
3. Medusa application in server mode, with the Medusa Admin.
4. Medusa application in worker mode.
5. (Optional) Medusa Admin.
<Note>
@@ -56,18 +55,7 @@ Later, youll set different values of the `MEDUSA_WORKER_MODE` environment var
### Configure Medusa Admin
There are two cases where you may disable the Medusa Admin in your deployed Medusa application:
1. If you choose to host it separately.
2. In the Medusa application running in worker mode, as it doesnt need to run the admin.
<Note>
To host the admin with the Medusa application, the hosting provider and plan should offer at least 2GB of RAM.
</Note>
Add the following configuration in `medusa-config.ts`:
You need to disable the Medusa Admin in the worker Medusa application, while keeping it enabled in the server Medusa application. So, add the following configuration in `medusa-config.ts`:
```ts title="medusa-config.ts"
module.exports = defineConfig({
@@ -225,7 +213,6 @@ JWT_SECRET=supersecret # TODO GENERATE SECURE SECRET
STORE_CORS= # STOREFRONT URL
ADMIN_CORS= # ADMIN URL
AUTH_CORS= # STOREFRONT AND ADMIN URLS, SEPARATED BY COMMAS
# change to false if you're hosting the admin with the application
DISABLE_MEDUSA_ADMIN=true
MEDUSA_WORKER_MODE=server
PORT=9000
@@ -237,9 +224,9 @@ Where:
- The value of `COOKIE_SECRET` and `JWT_SECRET` must be a randomly generated secret.
- `STORE_CORS`'s value is the URL of your storefront. If you dont have it yet, you can skip adding it for now.
- `ADMIN_CORS`'s value is the URL of the admin dashboard. If you dont have it yet, or youre deploying the admin with the Medusa application, you can skip adding it for now.
- `ADMIN_CORS`'s value is the URL of the admin dashboard, which is the same as the server Medusa application. You can add it later if you don't currently have it.
- `AUTH_CORS`'s value is the URLs of any application authenticating users, customers, or other actor types, such as the storefront and admin URLs. The URLs are separated by commas. If you dont have the URLs yet, you can set its value later.
- Change `DISABLE_MEDUSA_ADMIN` to `false` if youre hosting the admin with the Medusa application.
- Set `DISABLE_MEDUSA_ADMIN`'s value to `false` so that the admin is built with the server application.
- `REDIS_URL`'s value is automatically generated using Railways template syntax. You add the `?family=0` to the connection string to support both IPv6 and IPv4 connections.
Feel free to add any other relevant environment variables. Once youre done, click the Update Variables button.
@@ -272,11 +259,9 @@ You can either generate a random domain name or set a custom one. To do that:
1. Choose the `9000` port.
5. Save the changes.
### Additional Configuration if Deploying with Admin
### Set Backend URL in Admin Configuration
If youre deploying the Medusa application in server mode with the admin, you have to make some changes now that youve obtained the applications URL.
First, add the following configuration to `medusa-config.ts`:
After youve obtained the Medusa applications URL, add the following configuration to `medusa-config.ts`:
```ts title="medusa-config.ts"
module.exports = defineConfig({
@@ -345,7 +330,7 @@ REDIS_URL=${{Redis.REDIS_URL}}?family=0
Where:
- The value of `COOKIE_SECRET` and `JWT_SECRET` must be a randomly generated secret.
- Keep `DISABLE_MEDUSA_ADMIN`'s value set to `true`, even if youre hosting the admin with the Medusa application.
- Set `DISABLE_MEDUSA_ADMIN`'s value to `true` so that the admin isn't built with the worker application.
- `REDIS_URL`'s value is automatically generated using Railways template syntax. You add the `?family=0` to the connection string to support both IPv6 and IPv4 connections.
Feel free to add any other relevant environment variables. Once youre done, click the Update Variables button.
@@ -373,9 +358,7 @@ To deploy the changes of the Medusa application in working mode, click on the De
To test out the deployed application, go to `<APP_URL>/health`, where `<APP_URL>` is the URL of the Medusa application in server mode. If the deployment was successful, youll see the `OK` response.
### Open Deployed Medusa Admin
If you deployed the Medusa Admin with the application, itll be available at `<APP_URL>/app`.
The Medusa Admin is also available at `<APP_URL>/app`.
---
+4 -16
View File
@@ -8,9 +8,7 @@ export const metadata = {
Find guides to deploy your Medusa application, Medusa Admin, and Next.js storefront.
## Deploy Medusa Application
### Medusa Cloud
## Medusa Cloud
Medusa Cloud is our managed services offering for Medusa applications. Medusa Cloud hosts your server, Admin dashboard, database, and Redis instance. The infrastructure is security-compliant and optimized for Medusa and supports:
@@ -28,24 +26,14 @@ With Medusa Cloud, you maintain full customization control as you deploy your ow
[Sign up and learn more about Medusa Cloud](https://medusajs.com/contact)
### Self-hosting
---
## Self-hosting Medusa
To host and maintain Medusa on your own, check out the following guides.
<ChildDocs showItems={["Medusa Application"]} hideTitle={true} />
### Medusa Admin
To host and maintain on your own the Medusa Admin separately from your Medusa application, check out the following guides.
<Note title="Tip">
If you're hosting your admin dashboard with the Medusa application, then check out the [deployment guides of the Medusa application](#self-hosting) instead.
</Note>
<ChildDocs showItems={["Medusa Admin"]} hideTitle={true} />
---
## Deploy Next.js Starter Storefront
@@ -567,10 +567,6 @@ export const filesMap = [
"filePath": "/www/apps/resources/app/create-medusa-app/page.mdx",
"pathname": "/create-medusa-app"
},
{
"filePath": "/www/apps/resources/app/deployment/admin/vercel/page.mdx",
"pathname": "/deployment/admin/vercel"
},
{
"filePath": "/www/apps/resources/app/deployment/medusa-application/railway/page.mdx",
"pathname": "/deployment/medusa-application/railway"
+1 -18
View File
@@ -9150,7 +9150,7 @@ export const generatedSidebar = [
"loaded": true,
"isPathHref": true,
"type": "category",
"title": "Medusa Application",
"title": "Self-Hosting",
"children": [
{
"loaded": true,
@@ -9170,23 +9170,6 @@ export const generatedSidebar = [
}
]
},
{
"loaded": true,
"isPathHref": true,
"type": "category",
"title": "Medusa Admin",
"autogenerate_path": "/deployment/admin",
"children": [
{
"loaded": true,
"isPathHref": true,
"type": "link",
"path": "/deployment/admin/vercel",
"title": "Vercel",
"children": []
}
]
},
{
"loaded": true,
"isPathHref": true,
+5
View File
@@ -104,6 +104,11 @@ const nextConfig = {
destination: "/commerce-modules/promotion/links-to-other-modules",
permanent: true,
},
{
source: "/deployment/admin/vercel",
destination: "/deployment",
permanent: true,
},
]
},
// Redirects shouldn't be necessary anymore since we have remark / rehype
+1 -6
View File
@@ -2159,7 +2159,7 @@ export const sidebar = sidebarAttachHrefCommonOptions([
},
{
type: "category",
title: "Medusa Application",
title: "Self-Hosting",
children: [
{
type: "link",
@@ -2173,11 +2173,6 @@ export const sidebar = sidebarAttachHrefCommonOptions([
},
],
},
{
type: "category",
title: "Medusa Admin",
autogenerate_path: "/deployment/admin",
},
{
type: "category",
title: "Next.js Starter",