#--network
1 messages · Page 1 of 1 (latest)
What kind of architecture are you trying to achieve?
If you want to bind a docker container as a service to a dagger container, you can follow this approach: https://docs.dagger.io/api/services/#expose-host-services-to-functions
I try to use dagger to build (jar), pack (docker) and execute some java spring boot/cloud app. I already have some infrastructure services (like kafka for the service discovery) in existing container on an existing network. The app i pack and run should access this kafka instance and I wanted to access the app from the host like 127.0.0.1:8102 (each app with its port).
By launching a custom engine with '--network' it seems the other containers are reached. My last try is to start my apps in the same dagger container by binding services, i now see ' INF tunnel started port=8101 protocol=tcp http_url=http://localhost:8101 description="tunnel 0.0.0.0:8101 -> d968j8t8m115s.01607ovtsbqhe.dagger.local:8101" ' that i doesn't see when trying to launch multiple containers
The browser is loading for ever with no valid response but before it was completly not reachable
thanks for the link, i've seen it multiple time but this time it's clearer
ok i understand that i have an error when starting the service that prevent the container to start and share its port correctly
It seems that the port is shared but there's no service behind
I can't see if m'y service is started and listening in the logs
ts functions here https://gist.github.com/tokazio/787cf83946dba403f6f8280049955b03
calling with: dagger call -i boot-all --source-root-dir=backend --shared-dir=dagger/shared up --ports=8101:8101 --ports=8102:8102
@lean walrus is it possible to run this Kafka as part of your Dagger pipeline? That'd be the best setup so you can start paving the path towards a fully reproducible and self contained pipeline
If you hardly need to use the Kafka that has been started in your local docker container, the link that Jeremy posted above would be the right approach
What you need to do in this case is add a Service argument to your function
Even without the Kafka problem, i can't connect to my service
Yes
Can you change the withExec here https://gist.github.com/tokazio/787cf83946dba403f6f8280049955b03#file-gistfile1-txt-L14 to withDefaultArgs?
done, always unreachable. Like i'm running a 'custom' engine i can see this log when i've refreshed the browser page: failed to dial tcp cu83r952grjv4.76d6la8n7ch1q.dagger.local:8102: dial tcp: lookup cu83r952grjv4.76d6la8n7ch1q.dagger.local on 10.87.0.1:53: no such host" client_hostname="Macbook de romain" client_id=yuvne6dywv93ar1otas4ahhcv session_id=qvxajh68mbm7zbnlqyikq9e1y spanID=e157928d9d83b049 traceID=83881a3d95cc85f11bc6b4c01f107417
✔ .bootAll(
│ │ sharedDir: ✔ ModuleSource.resolveDirectoryFromCaller(path: "dagger/shared"): Directory! 0.0s
│ │ sourceRootDir: ✔ ModuleSource.resolveDirectoryFromCaller(path: "backend"): Directory! 0.0s
│ ): Container! 4.5s
● .up(ports: [{frontend: null, backend: 8101, protocol: TCP}, {frontend: null, backend: 8102, protocol: TCP}]): Void 2m48s
┃ 16:24:45 INF tunnel started port=8101 protocol=tcp http_url=http://localhost:8101 description="tunnel 0.0.0.0:8101 -> cu83r952grjv4.76d6la8n7ch1q.dagger.local:8101"
┃ 16:24:45 INF tunnel started port=8102 protocol=tcp http_url=http://localhost:8102 description="tunnel 0.0.0.0:8102 -> cu83r952grjv4.76d6la8n7ch1q.dagger.local:8102"
@lean walrus you're sure your app starts in 8101, right?
Do you see your app starting in the service logs?
i've just connected to dagger cloud and got readable traces
i see traces for bootAll, the container from the image but no log on the installApp or boot steps
In your TUI if you press the + key you should see more info
withMountedDirectory seems to be the last action before 'up'
@lean walrus there's something I don't see
Your boot function returns a service
But the asService call returns a Promise to a servixe
In the gist you shared above that brings my attention
Also, when you call the bootAll function in the CLI, the ports that you map will only be mapped to the alpaquita container
So your alpaquita container needs to be listening on those ports
If your intention is to map different ports to different Dagger services, the current way to do that is via the proxy module (https://daggerverse.dev/mod/github.com/kpenfound/dagger-modules/proxy@3e9985dde6f408e05e7d45e8abbae75c206af4e1)
This is because your functions can currently return a single service
So all the ports that you set via the --ports flag will map against the returned container/service
ok, i've updated the gist to return the container after the service binding. Now i see in TUI that the service is running, it's better ! but still not reachable
Check my last comment about the service proxy
ok, i've tried .withExposedPort(8102) just before asService (exposing 8102 from the service ?) and .withExposedPort(8102) just after alpaquita (exposing 8102 from the container ?). In the browser the error has changed to ERR_CONNECTION_REFUSED. Im' looking for the proxy
It's what I mentioned above. Your functions can currently return a single service, so all the ports that you map via the CLI can only be mapped against that service
Seems like you need to map ports to different Dagger services
That's what the proxy module enables
@lean walrus here's an example of me using proxy in a typescript module
https://github.com/jpadams/legend-daggerize-minimal-maven/blob/main/dagger/src/index.ts#L26-L31
of course I installed https://daggerverse.dev/mod/github.com/kpenfound/dagger-modules/proxy
Nice! Thanks
I've got one service working using ...withEntryPoint(["java..."]).withEsposedPort(8102).asService({useEntrypoint:true})
i then see in the log: INF tunnel started port=8102 protocol=tcp http_url=http://localhost:8102 description="tunnel 0.0.0.0:8102 -> mb6fkodt1bsmq.0eblbucgf955u.dagger.local:8102"
i've updated the gists https://gist.github.com/tokazio/787cf83946dba403f6f8280049955b03
dagger call -i cloud-utils-service --conf-dir=conf --backend-dir=backend up --ports=8102:8102 -> work
dagger call -i boot-all --conf-dir=conf --backend-dir=backend up --ports=8101:8101 --ports=8102:8102 -> does not work
@lean walrus is cloud-utils a TCP o httpservice?
if it's a TCP service, you need to use the isTcp flag here: https://daggerverse.dev/mod/github.com/kpenfound/dagger-modules/proxy@3e9985dde6f408e05e7d45e8abbae75c206af4e1#Proxy.withService
http://localhost:8102/admin/applications should serve an http page
(spring boot actuator)
ok thanks, it's working through the proxy if i only use cloud-utils. (see the updated gists) When i add the api-gateway it's not working anymore
in the log, when it's working (cloud utils alone) i see tunnel started port=8102 protocol=tcp and tunnel started port=8101 protocol=tcp after some delay (maybe the delay of the cloud-utils service to expose its port). When adding the apigateway that never log 'tunnel' creation...
what happens if you only have the api-gateway through the proxy? does that work?
i've put the services in debug mode and i see that the gateway can't connect to cloud-utils and i think it's the reason why it's blocking
I've tried with another service called 'demo' that expose the 8080 port. cloud-utils only in the proxy work, demo only in the proxy work, both at same time in the proxy block (no INF tunnel started)
that's quite strange.. 🤔. Let me try a quick example
@lean walrus here's a very simple example with the proxy module using two services that works for me
// Returns a container that echoes whatever string argument is provided
func (m *Lala) Test() *dagger.Service {
n1 := dag.Container().From("nginx").
WithExposedPort(80).
AsService(dagger.ContainerAsServiceOpts{UseEntrypoint: true})
n2 := dag.Container().From("nginx").
WithExposedPort(80).
AsService(dagger.ContainerAsServiceOpts{UseEntrypoint: true})
return dag.Proxy().WithService(n1, "n1", 8080, 80).
WithService(n2, "n2", 8081, 80).Service()
}
^ if I run dagger call test up I can then curl localhost:8081 and curl localhost:8080 without issues