Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

docker-compose microservices

version: '3'
services:
  #######################################
  # APPLICATION USERS SERVICE ENVIRONMENT
  #######################################
  users:
    build:
      context: .
      dockerfile: Dockerfile.users
    restart: always
    ports:
      - 3000:3000
    env_file: ./services/users/.env
    depends_on:
      - database
    volumes:
      - /usr/share/app/services/users
      - /usr/share/app/services/users/node_modules
    networks:
      - node-service
  #######################################
  # APPLICATION ROLES SERVICE ENVIRONMENT
  #######################################
  roles:
    build:
      context: .
      dockerfile: Dockerfile.roles
    restart: always
    ports:
      - 3001:3001
    env_file: ./services/roles/.env
    depends_on:
      - database
    volumes:
      - /usr/share/app/services/roles
      - /usr/share/app/services/roles/node_modules
    networks:
      - node-service
  ##############################
  # DATABASE SERVICE ENVIRONMENT
  ##############################
  database:
    image: mongo:latest
    restart: always
    ports:
      - 27017:27017
    volumes:
      - database:/var/lib/mongodb/data
    networks:
      - node-service
  #############################
  # PROXY SERVICES ENVIRONMENT
  #############################
  proxy:
    build:
      context: .
      dockerfile: Dockerfile.nginx
    restart: always
    ports:
      - 80:80
      - 443:443
    depends_on:
      - users
      - roles
    volumes:
      - ${PWD}/nginx.conf:/etc/nginx/nginx.conf
    networks:
      - node-service
# #############################
# # VOLUME PERSISTENT DATA
# #############################
volumes:
  database:
#############################
# NETWORKS SHARING GROUP
#############################
networks:
  node-service:
 
PREVIOUS NEXT
Tagged: #microservices
ADD COMMENT
Topic
Name
1+5 =