#Chaining Services

1 messages · Page 1 of 1 (latest)

scenic rose
#

Is it possible to ...

psqlSvc = psqlImg.asService().start()
apiSvc = apiImg.withServiceBinding("psql", psqlSvc).asService().start()
webSVc = webImg.withServiceBinding("api", apiSvc).asService().start()

done = testImg.withServiceBinding("web", webSvc).sync()

I am having trouble getting this pattern to start up

sage lagoon
#

Yes that should work. You don't need to start() explicitly by the way, the engine will do it lazily as bindings are resolved

scenic rose
#

I cannot get it to work, either early or lazy starting

#

do I need await in all the right places?

#

whoa, I might have really borked the engine, was trying to run playwright in dagger and now I cannot docker rm -f this container...

#

ok, kill finally returned

#

I keep getting (aliased as ts-api): service exited before healthcheck

#

but this is the same container I can export or publish and run, just as a service

scenic rose
#

Ah, I think I figured out my issue?

response: {
89
    errors: [
90
      {
91
        message: 'resolve: container: from: pipeline: withWorkdir: withExec: withEnvVariable: withDirectory: withExposedPort: withEntrypoint: pipeline: withoutEntrypoint: withExec: pipeline: withServiceBinding: withEnvVariable: withExec: withExec: sync: start abdlqs40c8b50 (aliased as ts-api): service container must be result of withExec (expected exec op, got *pb.Op_Merge)'
#

Why is withEntrypoint an issue with Services?

#

The tl;dr of my DX pains...

  1. build a node server with exec(db:gen) followed by entry(yarn serve)
  2. container runs fine everywhere
  3. running as a service had cryptic output, I think it was service exited unexpectedly, no log
  4. Not sure what changed so I got the error above, but that was the breadcrumb
  5. Add a .withExec(), that is the same as the entrypoint, just before calling .asService()

Now things work as "expected", but I would expect this container to work as a service without the need for an extra .withExec()

sage lagoon
#

cc @ruby moss the services expert

ruby moss
#

huh that's a strange one. It's supposed to auto-detect the need for a withExec and add it on its own, but it seems to have gotten confused in this case. Do you have code I can try running to repro?

scenic rose
#

this project is closed source, but I'd be happy to show you the actual code and help work towards a reproducer. It's a Postgres + Prisma + Express setup, but I would imagine there is probably a more minimal reporducer out there

ruby moss
scenic rose
#

that would be fun, I'm wide open tomorrow & friday