Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2a48642
Add Dockerfile for Python application setup
karthikreddy0738 Jan 24, 2026
0b21a96
Create Dockerfile for backend service
karthikreddy0738 Jan 24, 2026
e03b7b0
Add files via upload
karthikreddy0738 Jan 24, 2026
dd4ffa1
Add files via upload
karthikreddy0738 Jan 24, 2026
b7737b8
Add files via upload
karthikreddy0738 Jan 24, 2026
4f22052
Add files via upload
karthikreddy0738 Jan 24, 2026
64a126f
Add files via upload
karthikreddy0738 Jan 24, 2026
3d3333b
Delete configuration settings from .env
karthikreddy0738 Jan 24, 2026
0248cb5
Update yaml
karthikreddy0738 Jan 24, 2026
2d0c489
Rename yaml to docker-compose.yml
karthikreddy0738 Jan 25, 2026
324605e
Add CI/CD pipeline and Docker setup
karthikreddy0738 Jan 25, 2026
086b84d
Update Docker Hub login credentials in CI/CD workflow
karthikreddy0738 Jan 25, 2026
9dec88a
Update Docker build and push commands in CI/CD
karthikreddy0738 Jan 25, 2026
cca7576
Update Docker Hub credentials in CI/CD workflow
karthikreddy0738 Jan 25, 2026
3e7fe1f
Change Docker Hub login credentials
karthikreddy0738 Jan 25, 2026
19f04b6
Change Docker Hub password in CI/CD workflow
karthikreddy0738 Jan 25, 2026
a992d6c
Update DEVOPS.md
karthikreddy0738 Jan 25, 2026
3d4f34a
Add files via upload
karthikreddy0738 Jan 25, 2026
a6117d1
Create terraform
karthikreddy0738 Jan 25, 2026
d7fccc3
Delete terraform file
karthikreddy0738 Jan 25, 2026
d37281f
Update and rename main.tf.txt to Terraform/main.tf
karthikreddy0738 Jan 25, 2026
37ec489
Update and rename outputs.tf.txt to Terraform/outputs.tf
karthikreddy0738 Jan 25, 2026
f0b1c0b
Update and rename provider.tf.txt to Terraform/provider.tf
karthikreddy0738 Jan 25, 2026
5db0838
Update and rename user_data.sh.txt to Terraform/user_data.sh
karthikreddy0738 Jan 25, 2026
f0fc7f4
Update and rename variables.tf.txt to Terraform/variables.tf
karthikreddy0738 Jan 25, 2026
0d51c01
Refactor docker-compose.yml for frontend service
karthikreddy0738 Jan 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

30 changes: 30 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI-CD Pipeline

on:
push:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: karthik0738
password: Karthik@0738

- name: Build & Push Backend
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/devops-assessment-backend ./backend
docker push ${{ secrets.DOCKERHUB_USERNAME }}/devops-assessment-backend

- name: Build & Push Frontend
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/devops-assessment-frontend ./frontend
docker push ${{ secrets.DOCKERHUB_USERNAME }}/devops-assessment-frontend
37 changes: 37 additions & 0 deletions DEVOPS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# DevOps Assessment – Full Stack Deployment

## Project Overview
This project demonstrates containerization, orchestration, and CI/CD automation
for a full-stack application.

**Backend:** Django (REST API)
**Frontend:** React (Vite + TypeScript)

---

## Phase 1: Containerization

### Backend
- Dockerized using Python slim image
- Dependencies installed via requirements.txt
- Exposed on port 8000

### Frontend
- Dockerized using Node Alpine image
- Built using npm
- Exposed on port 3000

### Orchestration
- docker-compose used to run both services
- Services communicate via internal Docker network
- Ports mapped to localhost for browser access

### Run Locally
```bash
docker compose up --build

## Infrastructure as Code (Terraform)

- Used Terraform to provision AWS EC2
- Defined Security Groups, EC2, and User Data
- Automated Docker installation via user_data
45 changes: 45 additions & 0 deletions Terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
resource "aws_instance" "devops_ec2" {
ami = var.ami_id
instance_type = var.instance_type
key_name = var.key_name
subnet_id = aws_subnet.public_subnet.id

vpc_security_group_ids = [
aws_security_group.devops_sg.id
]

tags = {
Name = "devops-ec2"
}
}
resource "aws_security_group" "devops_sg" {
name = "devops-sg"

ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

ingress {
from_port = 3000
to_port = 3000
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

ingress {
from_port = 8000
to_port = 8000
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
3 changes: 3 additions & 0 deletions Terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "ec2_public_ip" {
value = aws_instance.devops_ec2.public_ip
}
3 changes: 3 additions & 0 deletions Terraform/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "aws" {
region = "us-east-1"
}
6 changes: 6 additions & 0 deletions Terraform/user_data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
apt update -y
apt install docker.io docker-compose git -y
systemctl start docker
systemctl enable docker
usermod -aG docker ubuntu
11 changes: 11 additions & 0 deletions Terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable "key_name" {
description = "EC2 key pair name"
}

variable "instance_type" {
default = "t2.micro"
}

variable "ami" {
default = "ami-0f58b397bc5c1f2e8" # Ubuntu 22.04 (us-east-1)
}
19 changes: 19 additions & 0 deletions backend/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3.11-slim AS builder
WORKDIR /app
RUN apt-get update && apt-get install -y \
build-essential \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --upgrade pip \
&& pip install --prefix=/install -r requirements.txt

FROM python:3.11-slim
RUN useradd -m django
WORKDIR /app
COPY --from=builder /install /usr/local
COPY . .
RUN chown -R django:django /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
3 changes: 3 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Django>=4.2
djangorestframework

39 changes: 39 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "3.9"

services:
backend:
build: ./backend
container_name: backend
command: python manage.py runserver 0.0.0.0:8000
volumes:
- ./backend:/app
ports:
- "8000:8000"
env_file:
- ./backend/.env
depends_on:
- frontend

frontend:
build: ./frontend
container_name: frontend
command: npm start
volumes:
- ./frontend:/app
ports:
- "3000:3000"
build:
context: ./backend
container_name: django-backend
ports:
- "8001:8000"
volumes:
- ./backend:/app
command: python manage.py runserver 0.0.0.0:8000

frontend:
build:
context: ./frontend
container_name: react-frontend
ports:
- "3001:80"
14 changes: 14 additions & 0 deletions frontend/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

FROM nginx:alpine
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

10 changes: 10 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
server {
listen 80;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri /index.html;
}
}

1 change: 1 addition & 0 deletions terraform
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
delete this file