I’d like to be able to seed data for my app when it’s deployed to a local Docker server. So I thought I might take advantage of Oban and create a worker to do the work. To kick the job off, I have the following in my release.ex
file:
def seed do
Application.load(@app)
Oban.insert(TestApp.Workers.ExampleWorker.new(%{}))
end
In my Dockerfile
, I have the following command:
CMD ["sh", "-c", "/app/bin/test_app eval TestApp.Release.migrate && /app/bin/test_app eval TestApp.Release.migrate && /app/bin/test_app start"]
Hoiwever, when the container starts, I see the following error:
2024-03-20 20:42:15 ** (ArgumentError) unknown registry: Oban.Registry
2024-03-20 20:42:15 (elixir 1.15.7) lib/registry.ex:1400: Registry.key_info!/1
2024-03-20 20:42:15 (elixir 1.15.7) lib/registry.ex:590: Registry.lookup/2
2024-03-20 20:42:15 lib/oban/registry.ex:59: Oban.Registry.lookup/2
2024-03-20 20:42:15 lib/oban/registry.ex:32: Oban.Registry.config/1
2024-03-20 20:42:15 lib/oban.ex:327: Oban.insert/3
2024-03-20 20:42:15 (sentient_mvp 1.6.2) lib/test_app/release.ex:56: TestApp.Release.seed/0
2024-03-20 20:42:15 nofile:1: (file)
I tried using Application.start(@app)
. But that didn’t work either. Is there something I can do to make this work?