Easiest way to deploy a server + X workers architecture?
I have a single Dockerfile that builds an image for a Node.js app. The image has 2 possible entry points: server.ts and worker.ts.
I'm looking to deploy a single instance of server and a predefined number of workers all within a single server managed by Dokploy.
- Only the server should be publicly accessible. Workers should remain private.
- The server should know how many workers are there and have their names/ip address to be able to connect to them via the internal network.
I guess Docker Compose would be the easiest? I have used Docker Compose in the past, but only for local development. Not sure what is required to get this working on Dokploy.
Any guides or tutorials?
I'm looking at this one https://docs.dokploy.com/docs/core/docker-compose/example, but the whole Traefik stuff is confusing me.
Do I only need to setup Traefik for my server since that's the only thing that's going to be exposed to the public internet?
How do I get the available workers and their network names from the server at runtime? Are there any environment variables set by Dokploy that I can use to discover the workers?
Say I want 8 workers, do I just copy and paste the workers service in my compose file 8 times and simply use their names from within the server (i.e worker1, worker2, worker3... etc)
Welcome to Dokploy | Dokploy
Dokploy is a open source alternative to Heroku, Vercel, and Netlify.
10 Replies
Many ways to Rome here. I get what you want to do, but I would advise something a bit different. I would use Docker stack and set number of replicas on the number of workers I would need. The server doesn't know how many worker there is, but the requests to the workers are load balanced by Docker. If I'm way off, you would have to create N workers compose services.
Also only the server needs any Traefik configuration done with it. The workers only need to be attached to the
dokploy-network
Thanks for the quick reply. I have never used Docker Stack so I'm not sure about it. Also, the server needs to know how many workers are there (this is fixed) and need to communicate to each one of them individually. It's not a regular case of "just send this to any available worker". The server is responsible for splitting a workload into X equal parts and offload each part to a worker. Server connects to each worker via socket.io and wait for all of them to finish and then process each chunk to produce the final output.
If I simply create 8 workers in my compose file with names worker1, worker2, etc. Can I simply connect to them from the server via their names, just like it works when using Docker Compose for development? Are there any specific configuration I need to make to allow for this?
Yup. That will work. Maybe set
hostname
label for good measure. Do not set container_name
. Also attach each of the workers to dokploy-network
Okay I think I've managed to get this part working. I'm now facing issues with the server domain and Let's Encrypt SSL.
I've created a domain with a Traefik autogenerated for my server and enabled HTTPS with Let's Encrypt. Is that enough to get a working HTTPS public endpoint?
It looks like the certificate is not valid. It doesn't look like it's a Let's Encrypt one, just a regular TRAEFIK default

I've set the domain via the UI as shown in the Attention here: https://docs.dokploy.com/docs/core/docker-compose/domains#important-considerations
My compose file doesn't have any traefik labels or anything.
The domain is indeed working, but there's no Let's Encrypt certificate.
Domains | Dokploy
Configure domains for your Docker Compose application.
Oh, Let's Encrypt certificates are not available for free traefik domains?
In some weird situations it works with SSL, but I have never understood when. Use your own domain. Traefik domains usually just gives me headaches
Can I use a subdomain? If so, can I use auto Let's Encrypt SSL with it?
Yup. As long as the subdomain A record points to your VPS you'll be able to use it. If you're using cloudflare, just use a wildcard A record.
That sound like something with your code. Check logs on the troublesome containers and server. Can't really help you there.
Nevermind, I missed the network setting for the workers 5, 6, 7 and 8. All good.