Skip to content

Commit 19b62f5

Browse files
update-requirement
1 parent 55e1a26 commit 19b62f5

7 files changed

Lines changed: 244 additions & 201 deletions

File tree

.do/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.do/app.yaml

Lines changed: 0 additions & 93 deletions
This file was deleted.

.do/deploy.template.yaml

Lines changed: 160 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,167 @@
1+
# DigitalOcean App Platform Specification
2+
# Task Manager Application Deployment Configuration
13

2-
name: task-manager-app-autodev-37
4+
name: task-manager-app-${ENVIRONMENT}
5+
region: nyc
36

4-
databases:
5-
- engine: PG
6-
name: db
7-
version: "14"
8-
production: false
9-
size: db-s-dev-database
7+
services:
8+
- name: web
9+
source_dir: /
10+
github:
11+
repo: RithishRamesh-dev/task-manager-app-autodev
12+
branch: ${BRANCH}
13+
deploy_on_push: true
14+
15+
# Build configuration
16+
build_command: |
17+
pip install --upgrade pip
18+
pip install -r requirements.txt
19+
# Run database migrations
20+
flask db upgrade
21+
22+
# Runtime configuration
23+
run_command: |
24+
if [ "$ENVIRONMENT" = "production" ]; then
25+
gunicorn --worker-class eventlet -w 1 --bind 0.0.0.0:$PORT app_socketio:app
26+
else
27+
gunicorn --worker-class eventlet -w 1 --bind 0.0.0.0:$PORT app_socketio:app --log-level debug
28+
fi
29+
30+
# Service configuration
31+
instance_count: 1
32+
instance_size_slug: basic-xxs
33+
http_port: 8080
34+
35+
# Health check configuration
36+
health_check:
37+
http_path: /health
38+
initial_delay_seconds: 30
39+
period_seconds: 10
40+
timeout_seconds: 5
41+
success_threshold: 1
42+
failure_threshold: 3
43+
44+
# Environment variables
45+
envs:
46+
- key: FLASK_APP
47+
value: app_socketio.py
48+
- key: FLASK_ENV
49+
value: ${ENVIRONMENT}
50+
- key: DATABASE_URL
51+
value: ${db.DATABASE_URL}
52+
- key: SECRET_KEY
53+
value: ${SECRET_KEY}
54+
type: SECRET
55+
- key: JWT_SECRET_KEY
56+
value: ${JWT_SECRET_KEY}
57+
type: SECRET
58+
- key: REDIS_URL
59+
value: ${REDIS_URL}
60+
- key: ENVIRONMENT
61+
value: ${ENVIRONMENT}
62+
- key: PORT
63+
value: "8080"
64+
- key: CORS_ALLOWED_ORIGINS
65+
value: ${CORS_ALLOWED_ORIGINS}
66+
- key: MAIL_SERVER
67+
value: ${MAIL_SERVER}
68+
- key: MAIL_PORT
69+
value: ${MAIL_PORT}
70+
- key: MAIL_USERNAME
71+
value: ${MAIL_USERNAME}
72+
- key: MAIL_PASSWORD
73+
value: ${MAIL_PASSWORD}
74+
type: SECRET
75+
- key: MAIL_USE_TLS
76+
value: "true"
77+
78+
# CORS configuration
79+
cors:
80+
allow_origins:
81+
- exact: https://${APP_DOMAIN}
82+
- regex: https://.*\.ondigitalocean\.app
83+
allow_methods:
84+
- GET
85+
- POST
86+
- PUT
87+
- DELETE
88+
- PATCH
89+
- OPTIONS
90+
allow_headers:
91+
- Content-Type
92+
- Authorization
93+
- X-Requested-With
94+
allow_credentials: true
95+
- name: redis
96+
image:
97+
registry_type: DOCKER_HUB
98+
repository: redis
99+
tag: "7-alpine"
100+
instance_count: 1
101+
instance_size_slug: basic-xxs
102+
103+
envs:
104+
- key: REDIS_PASSWORD
105+
value: ${REDIS_PASSWORD}
106+
type: SECRET
10107

11-
ingress:
12-
rules:
13-
- component:
14-
name: web
15-
match:
16-
path:
17-
prefix: /
108+
# Database configuration
109+
databases:
110+
- name: db
111+
engine: PG
112+
version: "14"
113+
production: ${DB_PRODUCTION}
114+
size: db-s-dev-database
18115

19-
jobs:
20-
- name: db-migrate
21-
environment_slug: python
22-
envs:
23-
- key: FLASK_APP
24-
value: app.py
25-
- key: DATABASE_URL
26-
scope: RUN_AND_BUILD_TIME
27-
value: ${db.DATABASE_URL}
28-
- key: SECRET_KEY
29-
value: ${SECRET_KEY}
30-
type: SECRET
31-
git:
32-
branch: main
33-
repo_clone_url: https://github.com/digitalocean-labs/task-manager-app-autodev.git
34-
source_dir: /
35-
run_command: flask db upgrade
116+
# Redis cache configuration
36117

37-
services:
38-
- name: web
39-
environment_slug: python
40-
git:
41-
branch: main
42-
repo_clone_url: https://github.com/digitalocean-labs/task-manager-app-autodev.git
43-
source_dir: /
44-
build_command: |
45-
pip install --upgrade pip
46-
pip install -r requirements.txt
47-
run_command: |
48-
gunicorn --worker-class gevent -w 1 --bind 0.0.0.0:$PORT "app:create_app()"
49-
http_port: 8080
50-
instance_count: 1
51-
instance_size_slug: basic-xxs
52-
health_check:
53-
http_path: /health
54-
envs:
55-
- key: FLASK_APP
56-
value: app.py
57-
- key: FLASK_ENV
58-
value: production
59-
- key: PORT
60-
value: "8080"
61-
- key: DATABASE_URL
62-
scope: RUN_AND_BUILD_TIME
63-
value: ${db.DATABASE_URL}
64-
- key: REDIS_URL
65-
value: redis://redis:6379
66-
- key: SECRET_KEY
67-
value: ${SECRET_KEY}
68-
type: SECRET
69-
- key: JWT_SECRET_KEY
70-
value: ${JWT_SECRET_KEY}
71-
type: SECRET
72-
- key: MAIL_PASSWORD
73-
value: ${MAIL_PASSWORD}
74-
type: SECRET
75-
- key: MAIL_SERVER
76-
value: ${MAIL_SERVER}
77-
- key: MAIL_PORT
78-
value: ${MAIL_PORT}
79-
- key: MAIL_USERNAME
80-
value: ${MAIL_USERNAME}
81-
- key: DO_API_TOKEN
82-
value: ${DO_API_TOKEN}
83-
type: SECRET
118+
# Static files (if needed for future enhancements)
119+
static_sites: []
84120

85-
workers:
86-
- name: redis
87-
image:
88-
registry_type: DOCKER_HUB
89-
repository: redis
90-
tag: "7-alpine"
91-
instance_count: 1
92-
instance_size_slug: basic-xxs
121+
# Worker services (for background tasks)
122+
workers: []
93123

94-
alerts:
95-
- rule: DEPLOYMENT_FAILED
96-
- rule: DEPLOYMENT_LIVE
124+
# Job services (for one-time tasks)
125+
jobs:
126+
- name: db-migrate
127+
source_dir: /
128+
github:
129+
repo: RithishRamesh-dev/task-manager-app-autodev
130+
branch: ${BRANCH}
131+
132+
build_command: |
133+
pip install --upgrade pip
134+
pip install -r requirements.txt
135+
136+
run_command: |
137+
flask db upgrade
138+
139+
instance_count: 1
140+
instance_size_slug: basic-xxs
141+
kind: PRE_DEPLOY
142+
143+
envs:
144+
- key: FLASK_APP
145+
value: app_socketio.py
146+
- key: DATABASE_URL
147+
value: ${db.DATABASE_URL}
148+
- key: SECRET_KEY
149+
value: ${SECRET_KEY}
150+
type: SECRET
151+
152+
# Alerts configuration
153+
alerts:
154+
- rule: DEPLOYMENT_FAILED
155+
disabled: false
156+
- rule: DEPLOYMENT_LIVE
157+
disabled: false
158+
- rule: CPU_UTILIZATION
159+
value: 80
160+
operator: GREATER_THAN
161+
window: FIVE_MINUTES
162+
disabled: false
163+
- rule: MEM_UTILIZATION
164+
value: 80
165+
operator: GREATER_THAN
166+
window: FIVE_MINUTES
167+
disabled: false

app/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414

1515
db = SQLAlchemy()
1616
migrate = Migrate()
17-
socketio = SocketIO(
18-
cors_allowed_origins="*",
19-
async_mode="gevent"
20-
)
17+
socketio = SocketIO()
2118
jwt = JWTManager()
2219

2320

@@ -28,7 +25,7 @@ def create_app(config_name='default'):
2825
# Initialize extensions
2926
db.init_app(app)
3027
migrate.init_app(app, db)
31-
socketio.init_app(app)
28+
socketio.init_app(app, cors_allowed_origins="*", async_mode='threading')
3229
jwt.init_app(app)
3330
CORS(app)
3431

app/websocket/events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from app.models.user import User
1111
from app.models.task import Task
1212
from app.models.project import Project
13-
from app.models.comment import TaskComment
13+
from app.models.comment import Comment
1414
from app.models.project_member import ProjectMember
1515
import logging
1616
from datetime import datetime
@@ -376,7 +376,7 @@ def on_comment_added(data):
376376
return
377377

378378
# Get comment and task details
379-
comment = TaskComment.query.get(comment_id)
379+
comment = Comment.query.get(comment_id)
380380
task = Task.query.get(task_id)
381381

382382
if not comment or not task:

0 commit comments

Comments
 (0)