New release is coming soon! If you want to try out the latest features, simply run npm i -s moleculer@next. The docs for the latest version are available here.
Deploy
Implementação do Docker
O exemplo abaixo mostra como usar moleculer-runner e Docker para implantar serviços Moleculer em vários contêineres.
Os arquivos Docker exibidos aqui são do projeto moleculer-demo.
Para informações detalhadas sobre o modo Docker e Kubernetes por favor, verifique o repositório docker demo.
Dockerfile
Dockerfile para executar os serviços do Moleculer
FROM node:current-alpine
ENV NODE_ENV=production
RUN mkdir /app WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install --production
COPY . .
CMD ["npm", "start"]
Docker Compose
Arquivos Docker Compose para executar serviços Moleculer com NATS & Traefik (Balanceamento de carga na API Gateway)
Defina as variáveis de ambiente necessárias. docker-compose.env
NAMESPACE= LOGGER=true LOGLEVEL=info SERVICEDIR=services # Inform moleculer runner about the location of service files
TRANSPORTER=nats://nats:4222 # Set transporter in all containers MONGO_URI=mongodb://mongo/project-demo # Set MongoDB URI
Configurar os contêineres. docker-compose.yml
version:"3.3"
services:
api: build: context:. image:project-demo env_file:docker-compose.env environment: SERVICES:api# Moleculer Runner will start only the 'api' service in this container PORT:3000# Port of API gateway depends_on: -nats labels: -"traefik.enable=true" -"traefik.http.routers.api-gw.rule=PathPrefix(`/`)" -"traefik.http.services.api-gw.loadbalancer.server.port=3000" networks: -internal
greeter: build: context:. image:project-demo env_file:docker-compose.env environment: SERVICES:greeter# Moleculer Runner will start only the 'greeter' service in this container depends_on: -nats networks: -internal
products: build: context:. image:project-demo env_file:docker-compose.env environment: SERVICES:products# Moleculer Runner will start only the 'products' service in this container depends_on: -mongo -nats networks: -internal