Skip to content

Commit

Permalink
CI pipeline code added
Browse files Browse the repository at this point in the history
  • Loading branch information
SrikanthReddy12271 committed Jun 26, 2024
1 parent 99cf402 commit 526d916
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 1 deletion.
71 changes: 71 additions & 0 deletions .github/workflows/continuos-integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: CI Pipeline

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'

- name: Install dependencies
run: pip install -r requirements.txt

- name: Build application
run: |
python app.py # Command to build/run your application
test:
needs: build
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'

- name: Install dependencies
run: pip install -r requirements.txt

- name: Run tests
run: |
pytest test_app.py # Run your tests
push:
needs: test
runs-on: ubuntu-latest

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/my-web-app:latest .
- name: Push Docker image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/my-web-app:latest
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"remote.autoForwardPortsFallback": 0
}
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use an official Python runtime as a parent image
FROM python:3.9-slim-buster

# Set the working directory in the container
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install any needed dependencies specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Make port 80 available to the world outside this container
EXPOSE 80

# Define environment variable
ENV NAME World

# Run app.py when the container launches
CMD ["python", "app.py"]
3 changes: 2 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def divide():
return render_template('result.html', result=result)
return render_template('index.html')


if __name__ == '__main__':
app.run()
app.run(host='0.0.0.0', port=8080)

2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flask>=2.0.0
requests==2.25.1

0 comments on commit 526d916

Please sign in to comment.