【问题标题】:Rails ActionText attachments lost after docker rebuild and docker-compose updocker rebuild 和 docker-compose up 后 Rails ActionText 附件丢失
【发布时间】:2023-01-24 11:33:11
【问题描述】:
我按照官方指南设置了 ActiveStorage 和 ActionText。我可以在本地环境 (localhost:3000) 中附加图像和视频。所有的东西都运行良好,即使在我重新启动服务器之后也是如此。
所以我将我的代码更改部署到暂存区。创建博客时看起来一切都很好。但是我发现如果我重新部署代码(重建docker镜像并通过docker-compose up启动服务)。 ActionText 的附件将无效,如下所示:
【问题讨论】:
标签:
ruby-on-rails
docker
docker-compose
attachment
actiontext
【解决方案2】:
我有一个类似的问题,是由于我没有正确配置 docker-compose 引起的。我有:
- 为 ActiveStorage“服务”选择了
Disk。这没关系,因为我不希望我的应用程序使用 ActiveStorage 存储大量内容——仅以非常有限的方式存储 ActionText blob。
- 我没有将 ActiveStorage
Disk 服务的卷设置为在重新启动后保持不变。每次我部署或以其他方式重新启动 docker-compose 服务时,都会重新创建卷,擦除每个 ActionText blob。
一旦我为 ActiveStorage 正确配置了持久卷,ActionText 附件就开始在部署/重新启动期间工作。