Giter Club home page Giter Club logo

express-docker's Introduction

A Simple dockerized REST API with Express.JS

This is a dockerized sample to build a very simple CRUD Rest API using NodeJs, ExpressJs & MongoDB (using mongoose) & mongo-express (Web-based MongoDB admin interface, written with Node.js and express) & Nginxas a proxy web server.

Create your services in docker-compose.yml file:

version: "3"
services:
  mongodb:
    image: mongo:4.2
    container_name: mongodb
    networks:
      - api-net
    env_file: ./mongo_env
    volumes:
      - ./mongo-data:/data/db
  backend:
    image: backend-express
    container_name: backend-container
    build: 
      context: .
    depends_on:
      - mongodb
    networks: 
      - api-net
  mongo-express:
    image: mongo-express:0.54.0
    container_name: mongo-express
    depends_on:
      - mongodb
    networks:
      - api-net
    env_file: ./mongo-express_env
  nginx: 
    image: nginx:1.21
    container_name: nginx_proxy
    restart: on-failure
    depends_on:
      - backend
    networks: 
      - api-net
    ports:
      - "8080:8080"
      - "8081:8081"
    volumes:
      - ./conf.d/:/etc/nginx/conf.d/
networks:
  api-net:

Create environments files for mongodb and mongo-express:

mongo_env file:

MONGO_INITDB_ROOT_USERNAME=root
MONGO_INITDB_ROOT_PASSWORD=root

mongo-express_env file:

ME_CONFIG_MONGODB_SERVER=mongodb
ME_CONFIG_MONGODB_URL=mongodb://root:root@mongodb:27017/mytestdb
ME_CONFIG_MONGODB_ADMINUSERNAME=root
ME_CONFIG_MONGODB_ADMINPASSWORD=root
ME_CONFIG_BASICAUTH_USERNAME=admin
ME_CONFIG_BASICAUTH_PASSWORD=admin
ME_CONFIG_MONGODB_ENABLE_ADMIN=true

Note: By default backend service listens on TCP/8080 port and mongo-express is available on TCP/8081.

express-docker's People

Contributors

azita-abdollahi avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.