Skip to content

Commit

Permalink
Updated package.json and added new files
Browse files Browse the repository at this point in the history
  • Loading branch information
MaceScott committed Feb 24, 2025
1 parent 2af264c commit 8595517
Show file tree
Hide file tree
Showing 373 changed files with 40,604 additions and 2,786 deletions.
9 changes: 9 additions & 0 deletions .cursor/rules/project-rules.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
description:
globs:
---

# Your rule content

- You can @ files here
- You can use markdown but dont have to
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
.next
out
build
.git
.env*
.DS_Store
README.md
31 changes: 31 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Database Configuration
DB_USER=cernoid
DB_PASSWORD=your_secure_password
DB_NAME=cernoid_db
DB_HOST=localhost

# Security
JWT_SECRET=your_jwt_secret_key
JWT_ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30

# Server Configuration
PORT=8000
ENVIRONMENT=development
LOG_LEVEL=INFO

# Feature Flags
ENABLE_METRICS=true
ENABLE_SWAGGER=true

# Cloud Storage (if needed)
STORAGE_BUCKET=your_bucket_name
STORAGE_REGION=your_region

# AWS Configuration
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key

# WebSocket Configuration
NEXT_PUBLIC_WS_URL=ws://localhost:5000/ws
REDIS_PASSWORD=your_redis_password_here
50 changes: 50 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Application
NODE_ENV=production
PORT=3000

# Database
DATABASE_URL=postgresql://user:password@localhost:5432/cernoid

# Security
JWT_SECRET=your-secret-key
ENCRYPTION_KEY=your-encryption-key

# External Services
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=your-email
SMTP_PASS=your-password

# Monitoring
ENABLE_METRICS=true
METRICS_PORT=9090

# Database Configuration
DB_USER=cernoid
DB_PASSWORD=your_secure_password
DB_NAME=cernoid_db
DB_HOST=localhost

# Server Configuration
ENVIRONMENT=development
LOG_LEVEL=INFO

# Feature Flags
ENABLE_SWAGGER=true

# Cloud Storage (if needed)
STORAGE_BUCKET=your_bucket_name
STORAGE_REGION=your_region

## Troubleshooting

Check the logs at:
- Windows: `logs\startup.log`
- Linux/Mac: `logs/startup.log`

Common issues:
1. Port 3000 in use: The startup script will prompt to kill the existing process
2. Missing dependencies: Run `npm install` manually
3. Build errors: Check the logs and run `npm run build` manually

## Cloud Deployment
46 changes: 46 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Deploy

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20'
- run: npm ci
- run: npm test

build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
push: true
tags: ghcr.io/${{ github.repository }}:latest

deploy:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Deploy to Digital Ocean
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- run: doctl kubernetes cluster kubeconfig save ${{ secrets.CLUSTER_NAME }}
- run: kubectl apply -f k8s/
123 changes: 123 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: CI/CD Pipeline

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_password
POSTGRES_DB: test_db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:7
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Run linting
run: |
flake8 src tests
black --check src tests
isort --check-only src tests
mypy src
- name: Run tests
env:
DATABASE_URL: postgresql+asyncpg://test_user:test_password@localhost:5432/test_db
REDIS_URL: redis://localhost:6379/0
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
pytest tests/ --cov=src --cov-report=xml
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml

build:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'

steps:
- uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

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

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/cernoid:latest
${{ secrets.DOCKERHUB_USERNAME }}/cernoid:${{ github.sha }}
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/cernoid:buildcache
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/cernoid:buildcache,mode=max

deploy:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'

steps:
- uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Update ECS service
run: |
aws ecs update-service --cluster cernoid-cluster \
--service cernoid-service \
--force-new-deployment
39 changes: 39 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy to Production

on:
push:
tags:
- 'v*'

jobs:
deploy:
runs-on: ubuntu-latest
environment: production

steps:
- uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build and push image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.ref_name }}
run: |
docker build -t $ECR_REGISTRY/surveillance-system:$IMAGE_TAG .
docker push $ECR_REGISTRY/surveillance-system:$IMAGE_TAG
- name: Update ECS service
run: |
aws ecs update-service --cluster production-cluster \
--service surveillance-system \
--force-new-deployment
42 changes: 42 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Security Checks

on:
schedule:
- cron: '0 0 * * *' # Run daily
workflow_dispatch:

jobs:
security:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install safety bandit
- name: Run dependency check
run: safety check

- name: Run security scan
run: bandit -r src/ -f json -o security-report.json

- name: Upload security report
uses: actions/upload-artifact@v3
with:
name: security-report
path: security-report.json

- name: Check for vulnerabilities
run: |
if [ -s security-report.json ]; then
echo "Security vulnerabilities found"
exit 1
fi
Loading

0 comments on commit 8595517

Please sign in to comment.