|
| 1 | +import { Table } from "docs-ui" |
| 2 | + |
| 3 | +export const metadata = { |
| 4 | + title: `Deployments`, |
| 5 | +} |
| 6 | + |
| 7 | +# {metadata.title} |
| 8 | + |
| 9 | +In this guide, you'll learn about deployments, how they're created, and how you can troubleshoot them in Cloud. |
| 10 | + |
| 11 | +## Deployments Overview |
| 12 | + |
| 13 | +Each [environment](../environments/page.mdx) has at least one deployment, which is publicly accessible at the [environment's URL](#find-environments-url). |
| 14 | + |
| 15 | +A deployment is created from the latest source code of an [environment](../environments/page.mdx)'s branch. An environment can have only one live deployment at a time. |
| 16 | + |
| 17 | +The latest deployment of an environment is the live version of that environment, unless you [redeploy a previous deployment](#redeploy-a-deployment). |
| 18 | + |
| 19 | +### How are Deployments Created? |
| 20 | + |
| 21 | +For long-lived environments, Cloud creates a new deployment every time you push a new commit to the environment's branch. For example, if your Production environment is connected to the `main` branch, Cloud will create a new Production deployment every time you push a new commit to the `main` branch. |
| 22 | + |
| 23 | +For short-lived preview environments, Cloud creates a new environment and deployment when you open a pull request. Cloud will redeploy the preview environment every time you push a new commit to the pull request branch. |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## Find Environment Deployments |
| 28 | + |
| 29 | +You can find the deployments for a project and its environments in the project and environment dashboards. |
| 30 | + |
| 31 | +For example, to find the deployments for the Production environment: |
| 32 | + |
| 33 | +1. [Go to its project's dashboard](../projects/page.mdx#open-project-dashboard). |
| 34 | +2. You can go to the latest Production deployment's details by clicking the "Latest Deployment" link in the Production environment card. |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +3. To find a list of all deployments, click on the "Production" environment card to open the environment's dashboard. |
| 39 | + - The "Latest update" card shows details about the latest deployment. |
| 40 | + - The "Deployments" card shows the list of all previous deployments. |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +The last step applies to all environments in your project, including custom environments (like Staging) and preview environments. |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## Find Deployment Details |
| 49 | + |
| 50 | +You'll often need to check a deployment's details, such as its status, commit information, and logs. |
| 51 | + |
| 52 | +To view a deployment's details: |
| 53 | + |
| 54 | +1. [Go to its project's dashboard](../projects/page.mdx#open-project-dashboard). |
| 55 | +2. If you're looking for the latest deployment: |
| 56 | + - Click the "Latest Deployment" link in its environment's card. |
| 57 | +3. If you're looking for an older deployment: |
| 58 | + - Click on its environment's card to open its dashboard. |
| 59 | + - In the "Deployments" card, click on the deployment you want to view. |
| 60 | + |
| 61 | +This will open the deployment's details page, where you can also see the deployment's commit at the top of the page. |
| 62 | + |
| 63 | +On the deployment details page, you'll find: |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +1. **Commit**: The commit that the deployment was created from. |
| 68 | +2. **Status**: The current [status](#deployment-statuses-and-lifecycle) of the deployment. For example, "Live" or "Build Failed". |
| 69 | +3. **Author**: The GitHub user who pushed the commit that created the deployment. |
| 70 | +4. **Build Logs**: The logs from the build process. They are useful to understand why a deployment failed. Learn more in the [Logs](#) guide. |
| 71 | + |
| 72 | +### Switch Between Deployments |
| 73 | + |
| 74 | +The deployment's commit at the top of the Cloud dashboard is also a deployment switcher. |
| 75 | + |
| 76 | +To switch to a different deployment: |
| 77 | + |
| 78 | +1. Click on the deployment's commit at the top of the Cloud dashboard, next to the environment's name. |
| 79 | +2. Choose the deployment you want to switch to from the dropdown. |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | +This will change the view to the selected deployment and you'll see its details and logs. |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## Access Live Deployment |
| 88 | + |
| 89 | +You can only access a deployment once its status is "Live". You can access it through its environment's URL. |
| 90 | + |
| 91 | +### Find Environment's URL |
| 92 | + |
| 93 | +<Note> |
| 94 | + |
| 95 | +For preview environments, refer to the [Environments](../environments/page.mdx#access-deployed-preview-environment) guide to find the URL of the preview environment. |
| 96 | + |
| 97 | +</Note> |
| 98 | + |
| 99 | +An environment's URL is in the format `<subdomain>.medusajs.app`, where `<subdomain>` is the subdomain you set either when [creating its project](../projects/page.mdx#create-a-project) or when [creating the environment](../environments/page.mdx#create-a-long-lived-environment). |
| 100 | + |
| 101 | +You can also find the URL of a deployment's environment through the Cloud dashboard: |
| 102 | + |
| 103 | +1. Select a project from the [organization's dashboard](../organizations/page.mdx#organization-dashboard). |
| 104 | +2. In the project's dashboard, find the URL in the environment's card under its name. For example, find the production URL in the Production environment card. |
| 105 | + |
| 106 | +<Note title="Why are there two URLs?"> |
| 107 | + |
| 108 | +Aside from the subdomain you set when [creating the environment](../environments/page.mdx#create-a-long-lived-environment), Cloud also provides a unique, randomly generated URL for each environment. Both of these URLs point to the same deployment. |
| 109 | + |
| 110 | +</Note> |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | +3. You can also click on the environment's name to open its dashboard, where you'll find the URL under the environment's name. |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | +### Access the Deployment's Medusa Admin |
| 119 | + |
| 120 | +To access the Medusa Admin of a live deployment, click on [the environment's URL](#find-environments-url). |
| 121 | + |
| 122 | +You can then log in using the email and password set either [during project creation](../projects/page.mdx#create-a-project) or [in the environment's variables](../environments/page.mdx#create-medusa-admin-user-in-environment). |
| 123 | + |
| 124 | +### Send Requests to the Deployment |
| 125 | + |
| 126 | +You can send requests to a live deployment's API routes using its URL. |
| 127 | + |
| 128 | +For example, to check the health of the live deployment, you can send a `GET` request to the `/health` endpoint: |
| 129 | + |
| 130 | +```bash |
| 131 | +curl https://my-project.medusajs.app/health |
| 132 | +``` |
| 133 | + |
| 134 | +Where `my-project` is the subdomain you set either when [creating the project](../projects/page.mdx#create-a-project) or when [creating the environment](../environments/page.mdx#create-a-long-lived-environment). |
| 135 | + |
| 136 | +### Access Deployment's Server through SSH |
| 137 | + |
| 138 | +Cloud doesn't support SSH access to the server instance of a deployment. However, you can still access the server's [runtime and build logs](#) to debug issues in your application. |
| 139 | + |
| 140 | +If this isn't sufficient for your use case, you can [contact support](#) to discuss alternatives. |
| 141 | + |
| 142 | +--- |
| 143 | + |
| 144 | +## Deployment Statuses and Lifecycle |
| 145 | + |
| 146 | +A deployment can have one of the following statuses: |
| 147 | + |
| 148 | +<Table> |
| 149 | + <Table.Header> |
| 150 | + <Table.Row> |
| 151 | + <Table.HeaderCell> |
| 152 | + Status |
| 153 | + </Table.HeaderCell> |
| 154 | + <Table.HeaderCell> |
| 155 | + Description |
| 156 | + </Table.HeaderCell> |
| 157 | + </Table.Row> |
| 158 | + </Table.Header> |
| 159 | + <Table.Body> |
| 160 | + <Table.Row> |
| 161 | + <Table.Cell> |
| 162 | + Building |
| 163 | + </Table.Cell> |
| 164 | + <Table.Cell> |
| 165 | + The deployment is currently being built. This is the initial status of a deployment. |
| 166 | + </Table.Cell> |
| 167 | + </Table.Row> |
| 168 | + <Table.Row> |
| 169 | + <Table.Cell> |
| 170 | + Build canceled |
| 171 | + </Table.Cell> |
| 172 | + <Table.Cell> |
| 173 | + The build process was canceled due to a newer commit pushed to the branch, which resulted in a new deployment. |
| 174 | + </Table.Cell> |
| 175 | + </Table.Row> |
| 176 | + <Table.Row> |
| 177 | + <Table.Cell> |
| 178 | + Build failed |
| 179 | + </Table.Cell> |
| 180 | + <Table.Cell> |
| 181 | + The build process failed due to a build error. You can check the [build logs](#) to troubleshoot the issue. |
| 182 | + </Table.Cell> |
| 183 | + </Table.Row> |
| 184 | + <Table.Row> |
| 185 | + <Table.Cell> |
| 186 | + Awaiting deployment |
| 187 | + </Table.Cell> |
| 188 | + <Table.Cell> |
| 189 | + The deployment has finished building and is waiting to be deployed. |
| 190 | + </Table.Cell> |
| 191 | + </Table.Row> |
| 192 | + <Table.Row> |
| 193 | + <Table.Cell> |
| 194 | + Deploying |
| 195 | + </Table.Cell> |
| 196 | + <Table.Cell> |
| 197 | + The deployment is currently being deployed. |
| 198 | + </Table.Cell> |
| 199 | + </Table.Row> |
| 200 | + <Table.Row> |
| 201 | + <Table.Cell> |
| 202 | + Deploy failed |
| 203 | + </Table.Cell> |
| 204 | + <Table.Cell> |
| 205 | + The deployment failed during the deployment process. You can check the [Runtime Logs](#) to troubleshoot the issue. |
| 206 | + </Table.Cell> |
| 207 | + </Table.Row> |
| 208 | + <Table.Row> |
| 209 | + <Table.Cell> |
| 210 | + Live |
| 211 | + </Table.Cell> |
| 212 | + <Table.Cell> |
| 213 | + The deployment finished successfully and is now the live version of the environment. |
| 214 | + </Table.Cell> |
| 215 | + </Table.Row> |
| 216 | + <Table.Row> |
| 217 | + <Table.Cell> |
| 218 | + Ready |
| 219 | + </Table.Cell> |
| 220 | + <Table.Cell> |
| 221 | + The deployment was previously deployed, but it's not currently the live version of the environment. This happens when a new deployment becomes the live version. |
| 222 | + </Table.Cell> |
| 223 | + </Table.Row> |
| 224 | + </Table.Body> |
| 225 | +</Table> |
| 226 | + |
| 227 | +So, the lifecycle of a successful deployment is Building → Awaiting deployment → Deploying → Live. Then, once a new deployment is created, the previous deployment's status changes to Ready. |
| 228 | + |
| 229 | +<Note> |
| 230 | + |
| 231 | +If a deployment is stuck at a status like "Building" or "Deploying" for a long time, [contact support](#) for assistance. |
| 232 | + |
| 233 | +</Note> |
| 234 | + |
| 235 | + |
| 236 | + |
| 237 | +--- |
| 238 | + |
| 239 | +## Troubleshooting Failed Deployments |
| 240 | + |
| 241 | +### Troubleshooting Build Failures |
| 242 | + |
| 243 | +If a deployment's status is "Build failed", you can check the [build logs](#) to understand why it failed. The build logs will show you the errors that occurred during the build process, which can help you fix the issue in your code. |
| 244 | + |
| 245 | +You can also [contact support](#) for help with the issue, if necessary. |
| 246 | + |
| 247 | +### Troubleshooting Deployment Failures |
| 248 | + |
| 249 | +If a deployment's status is "Deploy failed", you can check the [runtime logs](#) to understand why it failed. The runtime logs will show you the errors that occurred during the deployment process, which can help you fix the issue in your code. |
| 250 | + |
| 251 | +You can also [contact support](#) for help with the issue, if necessary. |
| 252 | + |
| 253 | +--- |
| 254 | + |
| 255 | +## Redeploy a Deployment |
| 256 | + |
| 257 | +You might need to redeploy an old deployment if there are unexpected issues with the current live deployment. |
| 258 | + |
| 259 | +By redeploying a previous deployment, you revert or rollback the live version of its environment to the code in that deployment's commit. |
| 260 | + |
| 261 | +<Note title="Important"> |
| 262 | + |
| 263 | +Redeploying a deployment will not revert database changes made in the latest deployment. If you need to revert database changes, [contact support](#) for assistance based on your use case. |
| 264 | + |
| 265 | +</Note> |
| 266 | + |
| 267 | +To redeploy a deployment: |
| 268 | + |
| 269 | +1. [Go to the deployment's details page](#find-deployment-details). |
| 270 | +2. Click the "Redeploy" button at the top right of the page. |
| 271 | + |
| 272 | + |
| 273 | + |
| 274 | +This will trigger the redeployment process for the selected deployment. The deployment will go through [the same lifecycle](#deployment-statuses-and-lifecycle) as a new deployment. |
| 275 | + |
| 276 | +Once the redeployment is complete, the deployment's status will change to "Live" and it will become the new live version of the environment. |
0 commit comments