-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.env.example
More file actions
190 lines (150 loc) · 5.68 KB
/
.env.example
File metadata and controls
190 lines (150 loc) · 5.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Application Settings
APP_NAME=IntelliBank API
APP_VERSION=1.0.0
DEBUG=true
HOST=0.0.0.0
PORT=8000
# Database
DATABASE_URL=postgresql://intellibank:intellibank_password@localhost:5432/intellibank
DATABASE_POOL_SIZE=20
DATABASE_MAX_OVERFLOW=30
# Redis
REDIS_URL=redis://localhost:6379/0
# Security
SECRET_KEY=your-super-secret-key-here-change-this-in-production
ACCESS_TOKEN_EXPIRE_MINUTES=30
REFRESH_TOKEN_EXPIRE_DAYS=7
# CORS
BACKEND_CORS_ORIGINS=http://localhost:3000,http://localhost:8080
# Adobe PDF Services
ADOBE_CLIENT_ID=your-adobe-client-id
ADOBE_CLIENT_SECRET=your-adobe-client-secret
# Cloudinary
CLOUDINARY_CLOUD_NAME=your-cloudinary-cloud-name
CLOUDINARY_API_KEY=your-cloudinary-api-key
CLOUDINARY_API_SECRET=your-cloudinary-api-secret
# Google Gemini
GEMINI_API_KEY=your-gemini-api-key
GEMINI_MODEL=gemini-pro
# File Processing
MAX_FILE_SIZE=52428800 # 50MB
ALLOWED_FILE_TYPES=application/pdf
# Celery
CELERY_BROKER_URL=redis://localhost:6379/0
CELERY_RESULT_BACKEND=redis://localhost:6379/0
# Monitoring
SENTRY_DSN=your-sentry-dsn-here
PROMETHEUS_METRICS=true
# Rate Limiting
RATE_LIMIT_PER_MINUTE=60
name: Development Deployment Workflow
on:
push:
branches:
- dev
jobs:
dev-deployment:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Deploy To Droplet
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.DIGITALOCEAN_DROPLET_IP }}
username: root
key: ${{ secrets.DIGITALOCEAN_SSH_PRIVATE_KEY }}
script: |
set -e
echo "🔄 Starting deployment..."
# Install PM2 if not already installed
if ! command -v pm2 &> /dev/null; then
echo "Installing PM2..."
npm install -g pm2
fi
# Check if the directory exists
if [ -d "$HOME/Bank-Statment-Anaylser" ]; then
echo "Directory 'Bank-Statment-Anaylser' exists....."
fi
echo "Pulling repository changes..."
cd $HOME/Bank-Statment-Anaylser
# Create .env file on the droplet
echo "${{ secrets.ENV_FILE }}" > .env
# Ensure we're on the right branch
git reset --hard HEAD
git clean -fd
git fetch origin dev
git checkout dev
git pull origin dev
echo "✓ Git changes pulled"
# Create or reuse existing environment
if [ ! -d "venv" ]; then
python3.11 -m venv venv
echo "✓ Virtual environment created"
else
echo "✓ Using existing virtual environment"
fi
source venv/bin/activate
echo "✓ Activated virtual environment"
REQUIREMENTS_FILE="/root/.previous_requirements_hash"
if [ ! -f "requirements.txt" ]; then
echo "❌ requirements.txt not found!"
exit 1
fi
# Calculate hash of current requirements.txt
CURRENT_HASH=$(md5sum requirements.txt | cut -d' ' -f1)
# Check if hash file exists and compare hashes
if [ ! -f "$REQUIREMENTS_FILE" ] || [ "$(cat $REQUIREMENTS_FILE)" != "$CURRENT_HASH" ]; then
echo "📦 Requirements changed, installing dependencies..."
pip install -r requirements.txt
# Save new hash
echo "$CURRENT_HASH" > "$REQUIREMENTS_FILE"
else
echo "✓ Requirements unchanged, skipping installation"
fi
ALEMBIC_CWD="$PWD/venv/bin/alembic"
if [ ! -f "$ALEMBIC_CWD" ]; then
echo "Installing alembic..."
pip install alembic
fi
# Check for multiple Alembic heads and merge them if necessary
echo "Checking Alembic migrations..."
alembic_heads=$($ALEMBIC_CWD heads | grep -v '^$' | wc -l)
if [ "$alembic_heads" -gt 1 ]; then
echo "Multiple Alembic heads detected. Merging heads..."
$ALEMBIC_CWD merge heads -m "merge heads for deployment" || { echo "Failed to merge Alembic heads"; exit 1; }
fi
$ALEMBIC_CWD upgrade head || { echo "Failed to run Alembic migrations"; exit 1; }
echo "✓ Database migrations completed"
# Delete any existing pm2 processes
pm2 delete all 2>/dev/null || true
# Verify ecosystem file exists
if [ ! -f "ecosystem.config.js" ]; then
echo "❌ ecosystem.config.js not found!"
exit 1
fi
echo "Starting application with pm2"
pm2 start ecosystem.config.js || { echo "❌ PM2 failed to start application"; pm2 logs --lines 50; exit 1; }
# Save PM2 process list
pm2 save
# Ensure PM2 starts on system reboot
pm2 startup
# Check if the application is running
if pm2 show bank-statement-analyzer | grep -q "online"; then
echo "✅ Application successfully started with PM2 at $(date)"
else
echo "❌ Application failed to start"
pm2 logs bank-statement-analyzer --lines 50
exit 1
fi
if pm2 show celery-worker | grep -q "online"; then
echo "✅ Celery workers successfully started with PM2"
else
echo "❌ Celery workers failed to start"
pm2 logs celery-worker --lines 50
exit 1
fi