semanser / codel

✨ Fully autonomous AI Agent that can perform complicated tasks and projects using terminal, browser, and editor.
https://discord.gg/uMaGSHNjzc
GNU Affero General Public License v3.0
2.09k stars 156 forks source link

Fix docker spawning issues #12

Closed semanser closed 6 months ago

semanser commented 6 months ago

Closes #11, Closes #2

2024/03/25 12:14:52 Image node:latest found: false
2024/03/25 12:14:52 Pulling image node:latest...
2024/03/25 12:14:53 Creating container exec-test...
2024/03/25 12:14:53 failed to spawn container: %!w(*fmt.wrapError=&{Error creating container: Error response from daemon: No such image: node:latest {0xc000240120}})

The problem is due to the fact that ImagePull is an async function and according to the docs:

// ImagePull requests the docker host to pull an image from a remote registry.
// It executes the privileged function if the operation is unauthorized
// and it tries one more time.
// It's up to the caller to handle the io.ReadCloser and close it properly.

This means that we never actually wait for the image to be downloaded and simply continue with the flow even if the container is still downloading. https://github.com/semanser/codel/blob/7a7ba36a9511f9dc31549112cfab0f1fb44e459f/backend/executor/executor.go#L58-L62

semanser commented 6 months ago
Screenshot 2024-03-25 at 13 27 47