This project showcases the complete DevOps lifecycle for a Flask-based multilingual text translator. The application is containerized using Docker, deployed on AWS EC2, and managed via a CI/CD pipeline using Jenkins.
Before you begin, ensure you have the following installed:
- Git: For version control.
- GitHub Account: To access and clone the repository.
LangSha: Text Translator is a web-based application built with the following tech stack:
- Backend: Flask
- Translation Engine:
googletrans==4.0.0-rc1
- Frontend: HTML templates (Jinja2)
- GitHub Repo: LangSha--Text-Translator
The application detects the input text language and translates it into a user-selected target language.
git clone https://github.com/Shristi-17/LangSha--Text-Translator.git
cd LangSha--Text-Translator
The application is containerized for portability and consistent deployment.
Key Components
- Dockerfile: Builds the container with Flask and dependencies.
- requirements.txt: Flask, googletrans==4.0.0-rc1
Build the Docker Image
docker build -t langsha-translator .
Run the Docker Container
docker run -d -p 5000:5000 langsha-translator
Step 4.1: Launch EC2 Instance
- AMI: Ubuntu 20.04
- Instance Type: t2.micro (Free tier eligible)
- Ports Opened:
22: SSH (your IP only)
5000: App access (from anywhere)
EC2 Instances created will look like this:
Step 4.2: Install Docker & Jenkins SSH into the instance:
ssh -i your-key.pem ubuntu@<EC2-IP>
Install Docker:
sudo apt update
sudo apt install -y docker.io
sudo systemctl start docker
sudo systemctl enable docker
Install Jenkins
sudo apt install -y openjdk-11-jdk
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install -y jenkins
sudo systemctl start jenkins
Access Jenkins at:
http://<EC2-IP>:8080
Step 5.1: Plugin Setup Install the following plugins in Jenkins:
- Git Plugin
- Docker Pipeline
- Pipeline
Step 5.2: Jenkinsfile Add a Jenkinsfile to the GitHub repo with the following structure:
pipeline {
agent any
stages {
stage('Clone Repo') {
steps {
git 'https://github.com/Shristi-17/LangSha--Text-Translator.git'
}
}
stage('Build Docker Image') {
steps {
script {
docker.build('langsha-translator')
}
}
}
stage('Run Docker Container') {
steps {
sh 'docker run -d -p 5000:5000 langsha-translator'
}
}
}
}
Step 5.3: Create Jenkins Pipeline Job
- Create a new pipeline job in Jenkins. Be careful when adding the file name, it is case sensitive.
- Point it to the GitHub repo containing the
Jenkinsfile
. - After creation, build the pipeline. It will look like this:
Once the container is running:
- Open your browser
- Navigate to:
http://<EC2-Public-IP>:5000
You should see the LangSha Translator UI, ready to detect and translate text in real time.
To stop the running container:
docker ps
docker stop <container-id>
To remove AWS EC2 instance:
- Go to AWS EC2 Console → Instances → Terminate
Hope it helped :)