Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/omkar-shelke25/django-app-pipeline-jenkins


https://github.com/omkar-shelke25/django-app-pipeline-jenkins

Last synced: 24 days ago
JSON representation

Awesome Lists containing this project

README

        

# Jenkins CI Pipeline for Django App

This project demonstrates the use of Jenkins for Continuous Integration (CI) with Docker for a Django application. The pipeline automates the process of building, testing, and deploying a Dockerized Django app.

## Table of Contents
1. [Overview](#overview)
2. [Jenkins Pipeline](#jenkins-pipeline)
3. [Dockerfile](#dockerfile)
4. [Docker Compose](#docker-compose)
5. [Setup Instructions](#setup-instructions)
6. [License](#license)

## Overview

This project is set up with Jenkins to automate the process of building and deploying a Django application inside a Docker container. The pipeline is configured to run in the following stages:

1. **Checkout the Code**: The code is pulled from a GitHub repository.
2. **Testing**: Custom tests or scripts are executed.
3. **Build the Code**: Docker image is built using the `Dockerfile`.
4. **Store Image in Artifactory**: The built image is pushed to an image repository (Artifactory).
5. **Deploy the Docker Image**: The image is deployed using Docker Compose.

## Jenkins Pipeline

The Jenkins pipeline is defined in a `Jenkinsfile` and contains the following stages:

- **Checkout the Code**: This stage checks out the code from the GitHub repository (`https://github.com/omkar-shelke25/Django-App-Pipeline-Jenkins`) on the `main` branch.

- **Testing**: A testing script is executed. You can customize the `hello()` function to run any necessary tests for your application.

- **Build the Code**: This stage checks for the presence of a `Dockerfile` and builds the Docker image named `note-app`.

- **Store Image in Artifactory**: Once the image is built, it is pushed to Artifactory with the tag `latest`.

- **Deploy the Docker Image**: The pipeline checks for the presence of a `docker-compose.yml` file and deploys the Docker image using Docker Compose.

## Dockerfile

The `Dockerfile` is essential for building the Docker image. It contains the instructions on how to create the Docker image, including the base image, dependencies, and application setup. The `Dockerfile` is used in the pipeline's **Build the Code** stage to build the image.

### Importance of Dockerfile:
- It defines the environment for the Django application.
- It ensures consistency across different environments by using the same Docker image for development, testing, and production.
- It automates the process of setting up dependencies, installing packages, and running the application inside a container.

## Docker Compose

The `docker-compose.yml` file is used to define and run multi-container Docker applications. In this project, it is used to configure and deploy the Django app along with any other necessary services, such as databases or caches.

### Importance of Docker Compose:
- It allows you to define multiple services (e.g., Django app, database) in a single configuration file.
- It simplifies the process of starting, stopping, and managing containers by using a single command (`docker-compose up`).
- It provides an easy way to manage application dependencies and configurations across different environments.

## Setup Instructions

### Prerequisites
- Jenkins installed and configured.
- Docker installed and running.
- Docker Compose installed.
- GitHub repository containing the Django app.

### Steps
1. Clone the repository:
```bash
git clone https://github.com/omkar-shelke25/Django-App-Pipeline-Jenkins.git
```

2. Create a Jenkins job and configure it to use the `Jenkinsfile` in the repository.

3. Ensure the following files are present in the root directory of the project:
- `Dockerfile`
- `docker-compose.yml`

4. Configure the necessary credentials for Docker and Artifactory in Jenkins.

5. Run the Jenkins pipeline and monitor the stages for successful execution.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---