This is a very small demo of Dagger and the new Docker Model Runner feature from Docker Desktop.
This demo is an agent in which we pass any directory, and it will spin up a container with all the required tools to work on the code base. And contrary to classical dev environments, you have nothing to configure, the model will analyze the codebase for you, understand what tools are needed, and install them.
You need to have Docker Desktop 4.40 or newer installed.
Important
You need an Apple Silicon mac to run the Model Runner.
You then need to enable the model runner in the Docker Desktop settings, under "Features in development" section.
Once that's done, check the Model Runner is running:
docker model statusYou should get this output:
Docker Model Runner is running
Now, pull the model used in this demo:
docker model pull eunomie/devstral-small-2505:q4_k_m[!NOTE]
Ensure this is working:
docker model run eunomie/devstral-small-2505:q4_k_m HiHello! How can I assist you today?
Note
The demo is using Devstral model from Mistral AI.
Why this model? The goal is to run locally. So we are forced to use small models. The smaller, the more efficient you need to be. So instead of a kind of generic model, I picked one specialized in code, able to understand the context, and also good at following instructions and using tools. Tools are a critical piece when it's time to instrument a model.
I pushed several variants of this model and others on Docker Hub.
Of course, you also need Dagger to be installed.
You can follow the steps as defined in the installation guide but with a mac, the easiest way is to use brew:
brew install dagger/tap/daggerAnd check that works
dagger versiondagger v0.18.8 (docker-image://registry.dagger.io/engine:v0.18.8) darwin/arm64
Now everything is setup, you can run the demo.
I provided a ts-hello directory to play with. This is a typescript hello world example.
Clone this repository, and enter the directory.
Then ask dagger to run the dev-environment and pass the ts-hello directory to it. It will create the environment and return a container.
The | terminal will then open a terminal in the returned container.
Ensure everything is working, meaning you can run yarn test inside the container.
dagger -c 'dev-environment ts-hello | terminal'● Attaching terminal:
container: Container!
.from(address: "docker.io/library/alpine:3@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c"): Container!
.withDirectory(
│ │ directory: Host.directory(path: "/Users/yves/dev/src/github.com/eunomie/local-agent/ts-hello"): Directory!
│ │ path: "/workspace"
│ ): Container!
.withWorkdir(path: "/workspace"): Container!
.withExec(args: ["apk", "add", "--no-cache", "nodejs", "yarn"], expect: ANY): Container!
.withExec(args: ["yarn", "install"], expect: ANY): Container!
dagger /workspace $ yarn test
yarn run v1.22.22
$ yarn lint:types && jest --no-cache
$ yarn tsc --noEmit -p .
$ /workspace/node_modules/.bin/tsc --noEmit -p .
(node:40) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
PASS ./hello-world.test.ts
Hello World
✓ says hello world with no name (1ms)
✓ says hello to bob
✓ says hello to sally
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 0.603s
Ran all test suites.
Done in 1.82s.
dagger /workspace $
This small Dagger project is composed of two modules. The main one you can find in the .dagger directory, will basically do the following:
- get the llm object based on the configuration (available in the
.envfile) - pass an environment defining the input (an alpine workspace) and the output (the modified workspace with the dev environment ready) to the model
- ask the model to follow a very basic prompt:
do what you need to do- this prompt is very basic and generic. Especially if you compare it to this previous version of the prompt.
- this works because of the descriptions on input and output of the environment
- those descriptions and objects create the environment of the model, and the model knows what needs to be done
The "alpine workspace" is another Dagger module you can find in alpine-workspace.
This one is written in Java, but no worries, you don't need java on your machine :-)
This workspace is simply:
- an alpine container with the source directory mounted
- a set of commands to install packages, read files, and run commands
This workspace is a crucial piece, as by restricting the available commands we help the model to pick the right ones.
And, that's it!