#```go
1 messages ยท Page 1 of 1 (latest)
Well, in my example, it does use buildkit (via buildx) to do the docker build if you invoke it.
// Build a Docker image from a Dockerfile
package main
import (
"context"
"dagger/nrs/internal/dagger"
)
type Nrs struct{}
// Returns a container that echoes whatever string argument is provided
func (m *Nrs) Build(ctx context.Context, source *dagger.Directory) (*dagger.Container, error) {
return dag.Container().
From("alpine").
WithDirectory("/app", source).
WithWorkdir("/app").
WithExec([]string{"apk", "add", "docker-cli"}).
WithExec([]string{"apk", "add", "docker-cli-buildx"}).
WithEnvVariable("DOCKER_HOST", "tcp://docker:2375").
WithServiceBinding("docker", dag.Docker().Engine()).
// could use --ssh option here, right?
WithExec([]string{"docker", "build", "-t", "ttl.sh/nrs:latest", "."}).
WithExec([]string{"docker", "push", "ttl.sh/nrs:latest"}).
Sync(ctx) // force execution right now, otherwise Dagger is lazy
}
You can also def pass in your docker socket as you talked about before.
https://docs.dagger.io/api/arguments/#unix-sockets
https://github.com/sipsma/daggerverse/blob/main/docker-client/main.go
Basically you can create whatever environments you need for whatever workflows you neeed to run given your desired inputs and outputs. If you do it all within dagger there are a lot of conveniences, but you can certainly prepare good environments for developer's Dockerfiles/contexts to be built. What started this current path was to get ability to run docker --ssh due to the requirement you have in your dev's Dockerfiles.
So with key loaded in SSH agent on host, you could pass in your SSH_AUTH_SOCKET to your Build function as a *dagger.Socket, mount it, create an env var maybe, and then docker build --ssh default="$SSH_AUTH_SOCK" . maybe ๐
๐ FWIW I've just synced with @elfin fossil and he'll be soon working in a better way to perform Dockerfile builds in Dagger which should unlock this faster ๐
NRS coming back to some unread messages. Have you found a workaround for this? The image won't end up in your local engine given that in this case you're spawning a docker engine withing Dagger which doesn't share anything with the Docker engine running in your machine ๐