Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Application Configuration
DATABASE_URL=sqlite:///./data/app.db
GRAFANA_PASSWORD=admin123

# Update these after deployment
FRONTEND_URL=http://your-ec2-ip
BACKEND_URL=http://your-ec2-ip:8000
91 changes: 91 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: CI/CD Pipeline
on:
push:
branches: [ main, master, Precious-project ]
pull_request:
branches: [ main, master, Precious-project ]
workflow_dispatch:

env:
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
IMAGE_TAG: ${{ github.sha }}
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

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

- name: Run backend tests
run: |
cd backend
python -m pytest || echo "No tests found - skipping"
build-and-push:
name: Build and Push Docker Images
needs: test
runs-on: ubuntu-latest

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

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push backend image
run: |
cd backend
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/fusionpact-backend:${{ env.IMAGE_TAG }} .
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/fusionpact-backend:latest .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/fusionpact-backend:${{ env.IMAGE_TAG }}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/fusionpact-backend:latest

- name: Build and push frontend image
run: |
cd frontend
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/fusionpact-frontend:${{ env.IMAGE_TAG }} .
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/fusionpact-frontend:latest .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/fusionpact-frontend:${{ env.IMAGE_TAG }}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/fusionpact-frontend:latest
deploy:
name: Deploy to Production
needs: build-and-push
runs-on: ubuntu-latest

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

- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /home/ubuntu/app
git pull origin main || git pull origin master
docker-compose pull
docker-compose up -d --force-recreate
docker system prune -af

- name: Verify deployment
run: |
sleep 10
curl -f https://fusionpact.servehttp.com || exit 1
echo "✅ Deployment successful!"
16 changes: 12 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
node_modules
.env
.env.local
dist
build

# Terraform
*.tfstate
*.tfstate.*
*.tfstate.backup
.terraform/
.terraform.lock.hcl
terraform.tfvars

# macOS
.DS_Store

Loading