#How to disable cache while testing builds locally?
1 messages Β· Page 1 of 1 (latest)
Hi π
Which SDK are you using ? The way I do it ATM is by adding an env variable to the container, whose value is random
I have a go function to generate this value, everytime I run it.
GO sdk. Would you share this function?
Yes, please give me 5 min π
Ehy, take your time. Not stressing anyone π
package main
import (
"context"
"fmt"
"dagger.io/dagger"
"github.com/dchest/uniuri"
)
func main() {
ctx := context.Background()
client, err := dagger.Connect(ctx)
if err != nil {
panic(err)
}
defer client.Close()
// New returns a new random string of the standard length, consisting of standard characters.
s := uniuri.New()
// Create a new ctr with inherent bursted cache
// by relying on env var with generated string to burst cache
ctr := client.Container().From("alpine:3.17").WithEnvVariable("BURST_CACHE", s)
stdout, err := ctr.WithExec([]string{"ls", "-la"}).Stdout(ctx)
if err != nil {
panic(err)
}
fmt.Println("output:", stdout)
}
Ahah no worries, I don't like making you wait while trying out Dagger π
π instead of using uniuri.New() you can just use time.Now().String(). That doesn't require any external libs