GithubHelp home page GithubHelp logo

containerization-docker-aws's Introduction

What is containerization

Containerization is the process of encapsulating your application into a container.

It involves bundling an application together with all of its related configuration files, libraries and dependencies required for it to run in an efficient and bug-free way across different computing environments.

In the area of software development, containerization is the encapsulation of an application with its own operating environment which can be run on any host machine without installing any more dependencies. It is a uniform structure in which an application can be stored.

The most popular containerization ecosystems are Docker and Kubernetes.

What is Docker

Docker is a tool that makes it easy to create, deploy, and run any application by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package.

What is Kubernetes

Kubernetes is an open source container orchestration system that is used to automate application deployment, scaling, and managing containers. It is also a platform for managing containerized workloads and service across a collection of cluster host.

How we dockerize our application on Travela

At Travela we have different Docker files which we use to build the docker images that runs our application. In Development, we have a docker file that builds our frontend and backend docker images . For the backend, we use a docker compose file to run the application. This docker compose file create two containers, one is the app container this runs the backend image that holds the api functionalities of the application. Another one is the Database container This runs a postgres image which holds the application database.

Backend Docker

dockerfile

FROM node:10.13.0-alpine

The first line in our Docker file is the node image we are using. We are making use of the node alpine image, the reason why we are using this the node alpine image is because it is light weight as a result, our overall image size will be smaller

WORKDIR /usr/app

Here we are setting the working directory to /usr/app inside the container

RUN apk update && apk upgrade &&
npm install -g [email protected] && rm -rf package-lock.json

The above lines, we are updating our packages in the image and installing yarn globally

COPY package.json /usr/app COPY yarn.lock /usr/app

Here we are copying the package.json and yarn.lock file into the app folder inside the container.

RUN yarn install

The last stage here we are running the yarn install command. This command installs all the dependencies in our application.

Frontend Docker file

dockerfile

FROM node:carbon

We are using a node carbon image as our base image.

WORKDIR /usr/app

HHere we are setting the working directory to /usr/app inside the container

RUN apk update && apk upgrade &&
npm install -g [email protected] && rm -rf package-lock.json

The above lines, we are updating our packages in the image and installing yarn globally

COPY package.json /usr/app

COPY yarn.lock /usr/app

Here we are copying the package.json and yarn.lock file into the app folder inside the container.

RUN yarn install

The last stage here we are running the yarn install command. This command installs all the dependencies in our application.

Frontend Docker file

FROM node:carbon

We are using a node carbon image as our base image.

WORKDIR /usr/app

Here we are setting the working directory to /usr/app inside the container

RUN apk update && apk upgrade &&
npm install -g [email protected] && rm -rf package-lock.json

The above lines, we are updating our packages in the image and installing yarn globally

COPY build /usr/src/app

Here we are copying the build into the app folder inside the container.

RUN npm install -g [email protected]

The last stage here we install serve globally, this is what we are using to serve the app

Backend Docker compose file

The Docker compose file runs two services, The app service which runs the backend application using the backend docker file and the database service which runs a postgres database. The app container exposes port 5000 to the host machine The database container exposes Port 5432 to the host machine

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.