#Capturing state from a service into an image layer

1 messages · Page 1 of 1 (latest)

hoary sable
#

Perhaps I could...

  1. mount a volume while running it as a service
  2. copy this volume in to the same path afterwards
steep crown
#

@hoary sable why not just using a WithExec to run whatever you need to run and persist that in the image layers?

hoary sable
#

It requires an API call, so the server has to be running first, hence the service thought

steep crown
#

Yes, correct. You can have the service running and let the overlayfs handle the data persistence

#

Now I have some doubts if stopping the service will effectively write the content in the overlayfs

#

I'd assume it'll do so but I can't recall precisely how the service stopping mechanics work

#

@hoary sable LMK if you give it a try. If not, I have another option that will surely work

hoary sable
#

I found a less ideal solution on my end that got me unblocked, basically restore the data from a snapshot on container startup. Ideally it's ready to go, being prewarmed during build time

#

I'm not using functions yet, can I call them from the dagger run paradigm somehow?

steep crown
steep crown
#

It's also more clear about what the pipeline is actually doing since the code to restore from the snapshot is actually there

hoary sable
#

I don't want people to have to think about volumes and extra commands, just a docker run and they are good to go

#

It's not a lot of data, far less than node_modules or similar

#

It's mainly for testing & demo purposes

steep crown
hoary sable
#

I'm currently saving the file in the image and then running it with the necessary extra flags

hoary sable
#

yes

#

in the running image, I then have both the snapshot file and the restored data

steep crown
#

Cool, yep, that works

hoary sable
#

In the docker world, I would run the image, run the restore, then commit to create a new layer

#

It works, but it means I have 2 copies of the data in the running image

#

Ideally I could just mount the snapshot in Dagger, run restore, and then keep just the actual data layer

steep crown
hoary sable
#

Can I distribute cache volumes?

steep crown
#

I wouldn't rely on distributed cache volumes for this though

#

Cache volumes are just a cache. It's a best effort storage system designed to speed up pipelines