Skip to content

Commit e9d185f

Browse files
Add deployment configurations and public documentation
Co-authored-by: xploitoverload <184857390+xploitoverload@users.noreply.github.com>
1 parent 11cb712 commit e9d185f

10 files changed

Lines changed: 1486 additions & 32 deletions

File tree

.dockerignore

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.gitattributes
5+
6+
# CI/CD
7+
.github
8+
9+
# Documentation
10+
*.md
11+
docs/
12+
13+
# Python
14+
__pycache__
15+
*.py[cod]
16+
*$py.class
17+
*.so
18+
.Python
19+
*.egg-info/
20+
dist/
21+
build/
22+
*.egg
23+
24+
# Virtual Environments
25+
venv/
26+
env/
27+
ENV/
28+
.venv/
29+
.virtualenv/
30+
31+
# IDE
32+
.idea/
33+
.vscode/
34+
*.swp
35+
*.swo
36+
*~
37+
.spyproject
38+
.spyderproject
39+
40+
# Testing
41+
.pytest_cache/
42+
.coverage
43+
coverage.xml
44+
*.cover
45+
htmlcov/
46+
.tox/
47+
.nox/
48+
49+
# Database (will be created in container or use external)
50+
*.db
51+
*.sqlite3
52+
instance/
53+
54+
# Logs (will be created in container)
55+
logs/
56+
*.log
57+
58+
# Environment files (use Docker secrets/env vars instead)
59+
.env
60+
.env.*
61+
*.env
62+
63+
# OS
64+
.DS_Store
65+
Thumbs.db
66+
67+
# Uploads (use volumes or external storage)
68+
uploads/
69+
media/
70+
71+
# Temporary files
72+
*.tmp
73+
*.temp
74+
tmp/
75+
temp/
76+
77+
# Security
78+
*.pem
79+
*.key
80+
*.crt
81+
82+
# Docker
83+
Dockerfile
84+
docker-compose.yml
85+
.dockerignore
86+
87+
# Backup files
88+
*.backup
89+
*.bak
90+
*.old

.github/workflows/ci-cd.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
# Job 1: Lint and Test
11+
test:
12+
name: Lint and Test
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
python-version: ['3.9', '3.10', '3.11']
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
cache: 'pip'
28+
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install -r requirements.txt
33+
pip install pytest pytest-cov flake8
34+
35+
- name: Lint with flake8
36+
run: |
37+
# Stop the build if there are Python syntax errors or undefined names
38+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=venv,env,.venv,.git,__pycache__
39+
# Exit-zero treats all errors as warnings
40+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=venv,env,.venv,.git,__pycache__
41+
42+
- name: Run tests
43+
run: |
44+
pytest tests/ -v --cov=app --cov-report=xml --cov-report=term
45+
env:
46+
FLASK_ENV: testing
47+
SECRET_KEY: test-secret-key
48+
49+
- name: Upload coverage to Codecov
50+
uses: codecov/codecov-action@v3
51+
with:
52+
file: ./coverage.xml
53+
fail_ci_if_error: false
54+
55+
# Job 2: Security Scan
56+
security:
57+
name: Security Scan
58+
runs-on: ubuntu-latest
59+
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v4
63+
64+
- name: Set up Python
65+
uses: actions/setup-python@v4
66+
with:
67+
python-version: '3.11'
68+
69+
- name: Install safety
70+
run: pip install safety
71+
72+
- name: Run safety check
73+
run: safety check --json || true
74+
75+
- name: Run Bandit security scan
76+
run: |
77+
pip install bandit
78+
bandit -r . -f json -o bandit-report.json || true
79+
80+
- name: Upload security reports
81+
uses: actions/upload-artifact@v3
82+
if: always()
83+
with:
84+
name: security-reports
85+
path: |
86+
bandit-report.json
87+
88+
# Job 3: Build Docker Image
89+
build:
90+
name: Build Docker Image
91+
runs-on: ubuntu-latest
92+
needs: [test, security]
93+
if: github.event_name == 'push'
94+
95+
steps:
96+
- name: Checkout code
97+
uses: actions/checkout@v4
98+
99+
- name: Set up Docker Buildx
100+
uses: docker/setup-buildx-action@v3
101+
102+
- name: Login to Docker Hub
103+
if: github.ref == 'refs/heads/main'
104+
uses: docker/login-action@v3
105+
with:
106+
username: ${{ secrets.DOCKER_USERNAME }}
107+
password: ${{ secrets.DOCKER_PASSWORD }}
108+
109+
- name: Build and push Docker image
110+
uses: docker/build-push-action@v5
111+
with:
112+
context: .
113+
push: ${{ github.ref == 'refs/heads/main' }}
114+
tags: |
115+
${{ secrets.DOCKER_USERNAME }}/project-management:latest
116+
${{ secrets.DOCKER_USERNAME }}/project-management:${{ github.sha }}
117+
cache-from: type=gha
118+
cache-to: type=gha,mode=max
119+
120+
- name: Test Docker image
121+
run: |
122+
docker build -t project-management:test .
123+
docker run -d -p 8000:8000 --name test-container project-management:test
124+
sleep 10
125+
curl http://localhost:8000/health || exit 1
126+
docker stop test-container
127+
128+
# Job 4: Deploy to Render (optional)
129+
deploy-render:
130+
name: Deploy to Render
131+
runs-on: ubuntu-latest
132+
needs: build
133+
if: github.ref == 'refs/heads/main'
134+
135+
steps:
136+
- name: Trigger Render Deployment
137+
if: secrets.RENDER_DEPLOY_HOOK_URL != ''
138+
run: |
139+
curl -X POST "${{ secrets.RENDER_DEPLOY_HOOK_URL }}"
140+
141+
- name: Deployment notification
142+
run: echo "Deployment triggered to Render"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Docker Build and Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
docker:
10+
name: Build and Push Docker Image
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up QEMU
18+
uses: docker/setup-qemu-action@v3
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Login to Docker Hub
24+
uses: docker/login-action@v3
25+
with:
26+
username: ${{ secrets.DOCKER_USERNAME }}
27+
password: ${{ secrets.DOCKER_PASSWORD }}
28+
29+
- name: Extract metadata
30+
id: meta
31+
uses: docker/metadata-action@v5
32+
with:
33+
images: ${{ secrets.DOCKER_USERNAME }}/project-management
34+
tags: |
35+
type=ref,event=branch
36+
type=ref,event=pr
37+
type=semver,pattern={{version}}
38+
type=semver,pattern={{major}}.{{minor}}
39+
type=semver,pattern={{major}}
40+
type=sha
41+
42+
- name: Build and push
43+
uses: docker/build-push-action@v5
44+
with:
45+
context: .
46+
platforms: linux/amd64,linux/arm64
47+
push: true
48+
tags: ${{ steps.meta.outputs.tags }}
49+
labels: ${{ steps.meta.outputs.labels }}
50+
cache-from: type=gha
51+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)