Table of contents
- What is CI/CD❓
- What Is a Build Job❓
- What is Freestyle Projects ❓ 🤔
- Task-1
- create an agent for your app. ( which you deployed from docker in the earlier task)
- Create a new Jenkins freestyle project for your app.
- In the "Build" section of the project, add a build step to run the "docker build" command to build the image for the container.
- Add a second step to run the "docker run" command to start a container using the image created in step 3.
- lets complete task-1:-
- Task-02
- Create Jenkins project to run "docker-compose up -d" command to start the multiple containers defined in the compose file (Hint- use day-19 Application & Database docker-compose file)
- Set up a cleanup step in the Jenkins project to run "docker-compose down" command to stop and remove the containers defined in the compose file.
What is CI/CD❓
CI or Continuous Integration is the practice of automating the integration of code changes from multiple developers into a single codebase. It is a software development practice where the developers commit their work frequently to the central code repository (Github or Stash). Then there are automated tools that build the newly committed code and do a code review, etc as required upon integration. The key goals of Continuous Integration are to find and address bugs quicker, make the process of integrating code across a team of developers easier, improve software quality and reduce the time it takes to release new feature updates.
CD or Continuous Delivery is carried out after Continuous Integration to make sure that we can release new changes to our customers quickly in an error-free way. This includes running integration and regression tests in the staging area (similar to the production environment) so that the final release is not broken in production. It ensures to automate the release process so that we have a release-ready product at all times and we can deploy our application at any point in time.
What Is a Build Job❓
A Jenkins build job contains the configuration for automating a specific task or step in the application building process. These tasks include gathering dependencies, compiling, archiving, or transforming code, and testing and deploying code in different environments.
Jenkins supports several types of build jobs, such as freestyle projects, pipelines, multi-configuration projects, folders, multibranch pipelines, and organization folders.
What is Freestyle Projects ❓ 🤔
A freestyle project in Jenkins is a type of project that allows you to build, test, and deploy software using a variety of different options and configurations. Here are a few tasks that you could complete when working with a freestyle project in Jenkins:
Task-1
create an agent for your app. ( which you deployed from docker in the earlier task)
Create a new Jenkins freestyle project for your app.
In the "Build" section of the project, add a build step to run the "docker build" command to build the image for the container.
Add a second step to run the "docker run" command to start a container using the image created in step 3.
Before doing the docker run, and docker build we install docker in our system
sudo apt-get install docker.io && sudo apt-get install docker-compose
sudo usermod -aG docker jenkins
sudo reboot
lets complete task-1:-
open your Jenkins server (for this see previous blog)
Then after clicking on Create a job
Enter an item like "todo-app-dev" click on the freestyle project and click on OK and your configure will open
Then after writing the description "the node is for todo-dev application" click on the GitHub project and past the URL of the project https://github.com/nallabellisriparthu/django-todo-cicd
In Source Code Management click on Git and past the Repository URL https://github.com/nallabellisriparthu/django-todo-cicd.git and check your git branch and the Jenkins branch should be the same if it is not the same then edit it
Then after going to the build steps selecting execute shell write these commands and click on save
echo "code build..."
docker build . -t django-app
echo "code run..."
docker run -d -p 8000:8000 django-app
Then after clicking on Build now your build was Finished: SUCCESS
after that open your port no 8000 in the AWS console and in a new tab copy your ipv4 address with port no like this ipv4:8080
Task-02
Create Jenkins project to run "docker-compose up -d" command to start the multiple containers defined in the compose file (Hint- use day-19 Application & Database docker-compose file)
Set up a cleanup step in the Jenkins project to run "docker-compose down" command to stop and remove the containers defined in the compose file.
Let's do the same with this application:
- remove your old command and write this command to compose your application and click on save
docker-compose down
docker-compose up -d
echo "code build and deployed..."
- before that, you kill and remove your previous container using these commands
docker ps
docker kill <container id> && docker rm <container id>
Then after clicking on Build now your build was Finished: SUCCESS
After that refresh your page and see your application will run
Happy Learning
Thanks For Reading! :)
-Sriparthu💝