Introduction to Dockerize series

Introduction

Hey, welcome to the Dockerize series. Here, I will be discussing how to use docker with your applications during both development and production.

We’ll also use techniques like Builder pattern, multi stage builds to optimize ou…



Introduction

Hey, welcome to the Dockerize series. Here, I will be discussing how to use docker with your applications during both development and production.

We’ll also use techniques like Builder pattern, multi stage builds to optimize our production builds.

This will serve as in introduction to upcoming articles where we’ll dockerize our React, Node, Go applications!



Docker…What and Why?

Alt Text

Docker is a software platform for building applications based on containers, which are small and lightweight execution environments.

It also helps to eliminate environment specific issues since you can replicate your production environment locally, which provides consistency across our teams.



Docker compose

Alt Text

Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.

Note: It’s is not advised to use docker-compose to run your application in production environment. Use a container orchestration tools like Kubernetes, Openshift, AWS ECS etc.



Builder pattern

In Builder pattern we use a docker image (which usually contains the whole runtime) to create small build artifacts and then use those binaries/artifacts in another smaller image hence reducing size of our built image.

Let’s take Node images for example, They’re usually upwards of 850mb in general (some slim variants are bit smaller) as they contain the full runtime and other things which might not be useful to us in production. So we can use builder pattern to do the following:

  • Derive from a Node base image with the whole runtime/SDK
  • Copy your source code
  • Install dependencies
  • Produce build artifact/bundle (usually done with bundlers like webpack, parcel) etc
  • Use the built artifacts in a much smaller images like Alpine
  • Push the small image to a repository of your choice like AWS ECS, Dockerhub etc.



Multi stage builds

Multi-stage builds makes it easier to use the builder pattern without hassle of creating multiple files, copying builds to host system and other things we had to do to implement builder pattern. More info here

Alt Text

We’re good to go! See you in the next part!


Print Share Comment Cite Upload Translate
APA
Karan Pratap Singh | Sciencx (2024-03-28T13:32:31+00:00) » Introduction to Dockerize series. Retrieved from https://www.scien.cx/2021/07/08/introduction-to-dockerize-series/.
MLA
" » Introduction to Dockerize series." Karan Pratap Singh | Sciencx - Thursday July 8, 2021, https://www.scien.cx/2021/07/08/introduction-to-dockerize-series/
HARVARD
Karan Pratap Singh | Sciencx Thursday July 8, 2021 » Introduction to Dockerize series., viewed 2024-03-28T13:32:31+00:00,<https://www.scien.cx/2021/07/08/introduction-to-dockerize-series/>
VANCOUVER
Karan Pratap Singh | Sciencx - » Introduction to Dockerize series. [Internet]. [Accessed 2024-03-28T13:32:31+00:00]. Available from: https://www.scien.cx/2021/07/08/introduction-to-dockerize-series/
CHICAGO
" » Introduction to Dockerize series." Karan Pratap Singh | Sciencx - Accessed 2024-03-28T13:32:31+00:00. https://www.scien.cx/2021/07/08/introduction-to-dockerize-series/
IEEE
" » Introduction to Dockerize series." Karan Pratap Singh | Sciencx [Online]. Available: https://www.scien.cx/2021/07/08/introduction-to-dockerize-series/. [Accessed: 2024-03-28T13:32:31+00:00]
rf:citation
» Introduction to Dockerize series | Karan Pratap Singh | Sciencx | https://www.scien.cx/2021/07/08/introduction-to-dockerize-series/ | 2024-03-28T13:32:31+00:00
https://github.com/addpipe/simple-recorderjs-demo