Ferdigheter · Apper
Fix a failed deploy
Find out why a deployment failed from its status, error and logs, fix the cause, and deploy again or roll back.
A deployment fails while it builds or while the new version starts. Either way the previous version keeps serving, because a new version only takes over once it is ready. Read the log before changing anything.
In short
get_deploymentfor itsstatus,errorandlog.- Match the
errorto the table below; the log says the rest. - For a live app that misbehaves, read
get_app_logs. - Fix the cause and deploy again, or go back with
rollback_app.
Step 1: read the deployment
{ "name": "get_deployment", "arguments": { "deploymentId": "<deployment id>" } }
get_app lists the app's newest deployments with their ids. While building, the log is live, and waiting says why a build has not started yet. awaiting_approval is not a failure: it waits for an owner (skill://apps/previews-and-approval). rejected means an owner said no.
The log says how it was built (==> Building with the project's Dockerfile or ==> No Dockerfile; detecting the app with Railpack) and lists the variable names the build got (==> Build secrets:). When the new version failed to start, the log ends with ==> Last lines from the app: the app's own output.
Step 2: what the error means
error starts with | Cause and fix |
|---|---|
| The build failed. | An install or build command failed. Read the end of the log. |
| The build did not finish within 15 minutes | Speed up the build, or find a step that waits for input. |
| The app crashed on start. | The process exited at least twice. The last lines from the app name the cause. |
| The app did not become ready within 150 s. | Nothing accepted connections on port 8080. See "The port" below. |
| The project has no room to start the new version | The project's memory or CPU limit is used up. Remove an app, a preview or a database, then deploy again. |
| The commit has no files under the root directory | Git deploys: the linked folder is wrong (skill://apps/deploy-from-git). |
| The source is larger than 50 MB | Leave out build output, node_modules and large assets. |
| The organisation already has … deployments waiting | Wait for one to finish, then deploy again. |
| The build pushed no image. / The build job disappeared. | Rare platform failures. Deploy again. |
A log line Could not fetch the app's environment variables means Skybu's secret store was briefly unavailable. Deploy again in a minute.
Step 3: common causes
The port. Skybu runs the app with PORT=8080 and HOSTNAME=0.0.0.0, which override an ENV PORT in a Dockerfile. The app must read PORT and listen on all addresses, not only localhost. A hard-coded 3000 gives "did not become ready". The app runs as an ordinary user (uid 1000), so it cannot use ports below 1024 or write where only root may, and it has 1 GiB of local disk.
How it starts. Without a Dockerfile, Railpack works out how to build and start the app from its files. For Node, give package.json a start script (and a build script if it needs one). With a Dockerfile, its CMD starts the app, and the Dockerfile must be at the top of the app's folder.
The lockfile. Send the lockfile (package-lock.json, pnpm-lock.yaml, yarn.lock and so on) and keep it in step with package.json: an install from a lockfile fails when they disagree, and a Dockerfile that copies a missing lockfile fails.
Variables at build time. The build gets the app's own variables as BuildKit secrets, never DATABASE_URL or the other variables Skybu adds at run time. Run migrations and database queries when the app starts, not in the build. Railpack builds see the variables as they are; a Dockerfile must mount each one in the step that needs it:
RUN --mount=type=secret,id=NEXT_PUBLIC_SITE,env=NEXT_PUBLIC_SITE npm run build
NEXT_PUBLIC_* values are compiled into the JavaScript, so they are public, and changing one needs a new build (skill://apps/environment-variables).
Memory. An app gets the memory of its size (512 MiB by default). Using more stops the process, which shows as a crash. Lower the app's use (for Node, NODE_OPTIONS=--max-old-space-size=…), or ask Skybu for a larger size: only Skybu's staff can change it.
Outbound connections. If the app cannot reach an outside service, get_app_egress shows what it tried and was refused (skill://access/outbound-traffic).
Step 4: logs of the live app
{ "name": "get_app_logs", "arguments": { "appId": "<app id>" } }
The last 300 lines from the running app. Use it when a live app answers with errors, and after changing variables: if a new value makes the app crash, the old process keeps serving but nothing marks the change as failed.
Step 5: deploy again, or go back
Deploy the fix the way the app was deployed (deploy_files or deploy_upload with the same name, a push, or deploy_latest_commit). To serve an earlier version meanwhile:
{ "name": "rollback_app", "arguments": { "appId": "<app id>", "deploymentId": "<earlier deployment id>" } }
Pick a deployment from get_app with status live or superseded and restorable: true; Skybu keeps the images of the five newest successful versions. It switches in a couple of seconds. When the organisation requires approval, the answer is approval: "pending" and the rollback waits for an owner.
Things to know
- On an app's first deploy there is no previous version, so a failure leaves nothing serving.
- A failed preview keeps its previous version answering, like production.
- Refusals that come before a deployment exists (
deploys_waiting,deploy_queue_full,app_quota_reached,source_too_large) come back as the tool's error, with a message saying what to do.