Failed balena cli deploy

I have a Dockerfile which results in quite a large image (several GB).
I tried to deploy it using

balena deploy <app> --debug --build

It got all the way through building the 3 services included in my docker-compose.yml but apparently the one really large service was too big?

[Error]   Deploy failed                                                                                                                                                                            [1/16407]
<!DOCTYPE html>                                                                                                                                                                                             
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Payload Too Large</pre>
</body>
</html>
HttpResponseError: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Payload Too Large</pre>
</body>
</html>
    at wrapResponseError (/snapshot/versioned-source/node_modules/balena-release/build/models.js:59:19)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async /snapshot/versioned-source/build/utils/compose_ts.js:710:9
    at async Promise.all (index 0)
From previous event:
    at processImmediate (internal/timers.js:456:21)
    at process.topLevelDomainCallback (domain.js:137:15)
From previous event:
    at /snapshot/versioned-source/build/utils/compose.js:227:21
    at pushServiceImages (/snapshot/versioned-source/build/utils/compose_ts.js:705:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async deployProject (/snapshot/versioned-source/build/utils/compose_ts.js:733:13)
    at async DeployCmd.deployProject (/snapshot/versioned-source/build/commands/deploy.js:142:27)
    at async DeployCmd.run (/snapshot/versioned-source/build/commands/deploy.js:46:25)
    at async DeployCmd._run (/snapshot/versioned-source/node_modules/@oclif/command/lib/command.js:43:20)
    at async Config.runCommand (/snapshot/versioned-source/node_modules/@oclif/config/lib/config.js:175:24)
    at async CustomMain.run (/snapshot/versioned-source/node_modules/@oclif/command/lib/main.js:27:9)
    at async CustomMain._run (/snapshot/versioned-source/node_modules/@oclif/command/lib/command.js:43:20)
    at async Promise.all (index 1)
    at async oclifRun (/snapshot/versioned-source/build/app.js:75:5)
    at async Object.run (/snapshot/versioned-source/build/app.js:88:9)
For further help or support, visit:
https://www.balena.io/docs/reference/balena-cli/#support-faq-and-troubleshooting

Is there a limit? How can I workaround this issue?

Hello, it looks like you might be experiencing the issue noted here: balena deploy --build : Payload Too Large · Issue #2086 · balena-io/balena-cli · GitHub
One workaround mentioned is to run balena build and balena deploy in separate steps, instead of balena deploy --build

1 Like

Just to piggyback on this we’ve also noticed an issue,
When our docker-compose.yaml file uses image: rather than build: we have found that sometimes balena deploy simply fails to deploy saying “no changes” but adding the --build argument to balena deploy workaround it and always deploys.

Hey there, what is happening in this case is you’ve specified an image but the deploy command sees that a copy of the image already exists locally. This is why it reports Everything is up to date.

If you are hoping to pull the latest image with each deploy you will have to use the --build flag, or manually run docker-compose pull in the same directory before running the deploy command.

Also I suggest using versioned build tags rather than latest when specifying upstream base images for stability if possible.

Pinning to a date-frozen base image is highly recommended if you are running a fleet in production. This ensures that all your dependencies have a fixed version and won’t get randomly updated until you decide to pin the image to a newer release.