No Dockerfile? No Problem! Let Your Code Find Its Build Path.


What is CNBs?
Buildpacks were introduced by Heroku in 2011. The CNB project was initiated by Pivotal and Heroku in January 2018 and joined the Cloud Native Computing Foundation (CNCF) as an Apache-2.0 licensed project in October 2018.
Cloud-native build packs (CNBs) transform your application source code into container images that can run on any cloud.
Cloud Native Buildpacks embrace modern container standards, such as the OCI image format.
With buildpacks, organizations can concentrate the knowledge of container build best practices within a specialized team, instead of having application developers across the organization individually maintain their Dockerfiles.
This makes it easier to know what is inside application images, enforce security and compliance requirements, and perform upgrades with minimal effort and intervention.
Why CNBs ?
Control: Balanced control between App Devs and Operators
Compliance: Ensure apps meet security and compliance requirements.
Maintainability: Perform upgrades with minimal effort and intervention.
FEATURES OF CNBs:-
Auto-Detection of your programming Language and its Version
Direct Image Building from Source without additional instructions
Buildpacks support various programming languages and advanced caching
The image contains only what is strictly necessary for running the application
Production-Ready Buildpacks Maintained by the Community
Deploy NodeJS and Django applications using Cloud Native Builpacks
prerequisites:-
Login to the AWS account
An Ubuntu EC2 machine t2.micro (t2.micro is ok if you are using a simple application)
update your machine then install Docker and give permission to the Ubuntu user to docker group
steps:-
1.
sudo apt update
2.
sudo apt install
docker.io
-y
3.
sudo usermod -aG docker $USER && newgrp docker
After that add the repo and Install the pack utility to build the image
sudo add-apt-repository ppa:cncf-buildpacks/pack-cli
sudo apt-get update
sudo apt-get install pack-cli
Clone your repo and if there is a Dockerfile and docker-compose delete it to make sure that here instead of docker file or compose we use build packs to run our applications
git clone <your repo URL>
Go inside the repo
cd node-todo-cicd
if there is a Dockerfile or docker-compose then you can delete it for more clarity that you are building here by Build-packsrm -rv Dockerfile
andrm -rv docker-compose.yaml
To get the suggested pack builder
pack build suggest
choose them, pack builder as suggested
pack build --builder=<your-builder-from-above-command> app name
After building you can check the image
docker images
Run the application and give port accordingly
docker run -itd --name nodeapp -p 8000:8000 node-js-app
Go to the security group and edit inbound rules add port 8000 and save rules for accessing your application
http://<public-ip>:8000
Imp point: Your application is now running in a lightweight and optimized container image
Amazing Job!!! 🎉 You have successfully built and deployed your application with Cloud Native Buildpacks. 🚀
Subscribe to my newsletter
Read articles from Fauzeya directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Fauzeya
Fauzeya
Hi there! I'm Fauzeya 👩💻, a passionate DevOps Engineer with a background in Computer Science Engineering🎓. I’m committed to enhancing security🔒, efficiency⚙️, and effectiveness in software development and deployment processes. With extensive knowledge in cloud computing☁️, containerization📦, and automation🤖, I aim to stay updated with the latest tools and methodologies in the DevOps field. Currently, I’m on a journey to deepen my understanding of DevOps I enjoy sharing my learning experiences and insights through my blog, 📝where I cover topics related to DevOps practices, tutorials, and challenges. I believe in continuous growth and learning and am excited to connect with fellow tech enthusiasts and professionals🤝. Let’s embark on this journey together!🚀