hiveer
hiveer

Reputation: 749

Rails ActionText attachments lost after docker rebuild and docker-compose up

I've setup ActiveStorage and ActionText by following the official guides. I can attach images and videos in local environment(localhost:3000). All the things are working well, even after I restart the server. enter image description here

So I deploy my code change to staging. It looks all good when creating the blog. But I found if I redeploy the code(rebuild the docker image and start service by docker-compose up). The attachments for ActionText will just been invalid, which looks like this: enter image description here

Upvotes: 0

Views: 112

Answers (2)

Ed Ruder
Ed Ruder

Reputation: 608

I had a similar problem that was caused by me not configuring docker-compose correctly. I had:

  1. Selected Disk for the ActiveStorage "service". This is OK because I don't expect that my app will store tons of stuff using ActiveStorage–just ActionText blobs in a very limited way.
  2. I didn't set up the volume for the ActiveStorage Disk service to be persistent across restarts. Every time I deployed or otherwise restarted the docker-compose services, the volume was recreated, erasing every ActionText blob.

Once I properly configured a persistent volume for ActiveStorage, the ActionText attachments started working across deploys/restarts.

Upvotes: 0

hiveer
hiveer

Reputation: 749

Finally I found the root case is: https://github.com/rails/rails/issues/37405

It's a Rails bug, when we are using rich_text_area_tag, here will be the problem.

If you use rich_text_area instead this problem will not be there any more.

Upvotes: 0

Related Questions