Docker deployment
The example below shows how to use moleculer-runner and Docker to deploy Moleculer services across multiple containers.
Note that moleculer-runner is capable of reading environment variables, which are heavily used in Docker deployments. More info about runner’s configuration loading logic.
The Docker files shown here are from moleculer-demo project.
For mode detailed info about Docker and Kubernetes please check the docker demo repository.
Dockerfile
Dockerfile to run Moleculer services
FROM node:current-alpine |
Docker Compose
Docker compose files to run Moleculer services with NATS & Traefik (load balancing the API Gateway)
Set the necessary environment variables.
docker-compose.env
NAMESPACE= |
Configure the containers.
docker-compose.yml
services: |
Start containers
$ docker compose up -d |
Access your app on http://<docker-host>:3000/. Traefik dashboard UI on http://<docker-host>:3001/
Kubernetes deployment
Moleculer needs no special Kubernetes integration: a Moleculer node is a plain container (like the one built from the Dockerfile above), so you deploy it as a regular Deployment and let the nodes find each other through the transporter (e.g. a NATS service in the cluster). For community examples see dkuida‘s step by step tutorial, lehno‘s code samples, tobydeh‘s deployment guide and the related discussion.