Fullstack Dockerized Template on Typescript.

Fullstack Dockerized Template on Typescript.

We've heard developers voice the same pain points time and again: it's hard to integrate your app's frontend with your backend, you need to tackle an ever-expanding technical scope in your daily workload, and it's tough to navigate the breadth of cloud offerings.While backend-as-a-service offerings provide an easy onramp, they often require developers to migrate away from them as their company scales.

“Winning isn’t everything, but wanting to win is.” — Vince Lombardi


We start our implementation with plan of actions.(Express->React->Nginx->MongoDB)

Dockerized MERN

We are start with mkdir commands to create follow folders: client, backend, nginx.


Folders creation

The Dockerfiles for Client, Server and NginX services as seen bellow:

Server Dockerfile
Client Dockerfile
Nginx Dockerfile

Let's install some dependencies and devDependencies in server directory:

by passing to server own directory:

package.json of server directory with script enter-points

Next step is the creation of json file dependencies for client module. The module consists the nessary files to client developments and scripts to run by the client service:

package.json of client directory with script enter-points

By pass to the next action we are create the nginx configuration file. The file configurated due to passing requests beetwen the client and server services.

Nginx configuration

So there are last and an important issue it's to create the docker compose file that define all services and configutaions for it.The file situated outside of folders, in upper level of folders.

version: '3'
services: 
  server:
    build: 
      dockerfile: Dockerfile
      context: ./server
    container_name: server-Express
    volumes:
      - '/app/node_modules'
      - './server:/app'
    command: npm run dev
    ports: 
      - "3005:3005"
    depends_on:
      - mongo
    environment:
      - MONGO_URL=mongodb://mongo:27017/mydb
  client:
    build: 
      dockerfile: Dockerfile
      context: ./client
    container_name: client-React
    volumes:
      - '/app/node_modules'
      - './client:/app'
    command: npm run dev
    ports: 
      - "6001:6001"
    tty: true
  nginx:
    restart: always
    container_name: Nginx
    build:
      dockerfile: Dockerfile
      context: ./nginx
    ports: 
      - "3050:3051"
    depends_on:
       - server
       - client
  mongo:
    restart: always
    image: mongo
    container_name: mongoDB
    volumes:
      - mongo-data:/data/db
    ports:
      - "27017:27017"

volumes:
  mongo-data:
        

The volume in the end of defenition is persists volume.That saved for all time that project exists.

The frontend reac vite server configuration has been corrected to the following expectations:

The configuration situated in vite.config.ts file on the backend side of application.

vite.config.ts

So the final step to run out the docker compose file with a regular command:

  • docker compose up --build

Frontend Service in action
Backend Service in action.

So the task has been complited succesfully. The backend and frontend services in up condition.

The plan










要查看或添加评论,请登录

David Furman的更多文章

  • Authentication with Fastapi

    Authentication with Fastapi

    For our project we need a following packages: pip install pyjwt[crypto] - PyJWT is a library for encoding and decoding…

  • FastAPI is the fast way for building APIs?

    FastAPI is the fast way for building APIs?

    "If anyone is looking to build a production Python API, I would highly recommend FastAPI. It is beautifully designed…

  • Easy Backend development with Nest.js (1/5)

    Easy Backend development with Nest.js (1/5)

    Before we begin, ensure you have the following tools and technologies installed on your system: Prerequisites steps:…

  • Profile Lookup Application

    Profile Lookup Application

    Welcome to adventures of framework Django that provide all necessary technics and possibilities to develop any kind of…

  • Data Visualization with Matplotlib

    Data Visualization with Matplotlib

    One of the ways to visualize the data the Matplotlib library are used. Let's start our deep journey with Single-Line…

  • Http Authentication and Authorization with Spring Security

    Http Authentication and Authorization with Spring Security

    First of all it's important to understand difference between Authentication and Authorization!By this simple tutorial…

  • Automation Sport News Scrapped and Implemented

    Automation Sport News Scrapped and Implemented

    Tutorial for scrapped content: 1.Now create simple pattern by qt Designer and convert it to python code.

社区洞察

其他会员也浏览了