#save file to cache mount

1 messages · Page 1 of 1 (latest)

vital kindle
#

Is it possible to save files to paths mounted as cache mounts? I have to use cache mounts because they are shared between multiple containers.

This isn't working:

func (m *Treasury) Experiment(
    ctx context.Context,
) *dagger.Container {

    cache := dag.CacheVolume("cache")
    container := dag.Container().
        From("alpine:latest").
        WithMountedCache("/shared", cache)

    file := dag.Directory().WithNewFile("/file", "contents").File("/file")

    return container.WithFile("/shared/file", file)
}

I get:

┃ marshal: json: error calling MarshalJSON for type *dagger.Container: input: container.from.withMountedCache.wi
┃ File resolve: /shared: cannot retrieve path from cache                                                        
  ✔ Container.from(address: "alpine:latest"): Container! 0.1s
  ✘ Container.withFile(
      path: "/shared/file"
      source: ✔ Directory.file(path: "/file"): File! 0.0s
    ): Container! 0.0s
  ! /shared: cannot retrieve path from cache