Deploying a Django To-do App Using Jenkins Freestyle Project

Deploying a Django To-do App Using Jenkins Freestyle Project

ยท

2 min read

In the thrilling realm of DevOps, automation is the hero we all need to streamline our development and deployment adventures. Today, we embark on a quest to automate the deployment of a Docker container, using the epic Django-based Todo application as our quest item, with Jenkins Freestyle Project as our trusty sidekick. ๐ŸŒ๐Ÿ๐Ÿ•น๏ธ

Prerequisites๐Ÿ› ๏ธ

  1. Docker installed on your machine.

  2. An AWS EC2 instance configured with Docker and your Django Todo application (as outlined in this project).

Project Overview๐Ÿ“

In our previous escapade, we manually set up and deployed a Django Todo application within a Docker container on an AWS EC2 instance.

We will now automate this process using Jenkins Freestyle Project. ๐Ÿ”„

Step 1: Create a Jenkins Agent for Your App ๐Ÿ•ต๏ธโ€โ™‚๏ธ

  1. Open Jenkins and navigate to "Manage Jenkins" > "Manage Nodes and Clouds."

  2. Click "New Node" to create a new agent. Provide a name and configure necessary settings.

Step 2: Configure a Freestyle Project โš™๏ธ

  1. Click on "New Item" on the Jenkins dashboard.

  2. Enter a project name and choose "Freestyle project."

  3. Under the "General" section, check "Restrict where this project can be run" and select your created agent.

Step 3: Add Build Steps ๐Ÿšง

  1. In the project configuration, navigate to the "Build" section.

  2. Click on "Add build step" and choose "Execute shell" (for Unix-based systems) or "Execute Windows batch command" (for Windows).

  3. Enter the following commands:

    • docker build -t todo-app . to forge your Docker image.

    • docker run -d -p 8001:8001 todo-app to summon your Docker container.

Step 4: Save and Build ๐Ÿ’พ

  1. Save your project configuration.

  2. Trigger a build by clicking "Build Now" on the project dashboard.

Jenkins, our loyal companion, will now execute the specified build steps, automating the creation of your Docker image and the deployment of your Todo application.

Step 5: Manual Browser Testing ๐ŸŒ๐Ÿ‘ฉโ€๐Ÿ’ป

  1. Open your preferred web browser.

  2. Navigate to http://localhost:8080 to access your Todo App manually.

Conclusion๐ŸŽ‰

In this tutorial, we automated the deployment of a Docker container for our Django Todo application using Jenkins Freestyle Project. This streamlined approach enhances efficiency and ensures consistency in your deployment process. Remember, this automation is built upon the manual setup explained in Project 1.

Feel the power of automation, adapt this tutorial to fit your specific project needs, and share your automated Docker deployment success with Jenkins! ๐Ÿค–โœจ

ย