Commit
·
e85ed70
1
Parent(s):
cb4a732
deplyment phase
Browse files- frontend/src/services/api.js +4 -17
- render.yaml +18 -16
frontend/src/services/api.js
CHANGED
|
@@ -23,28 +23,15 @@
|
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
-
|
| 27 |
import axios from 'axios';
|
| 28 |
|
| 29 |
-
// this line will use the production URL when deployed,
|
| 30 |
-
// and the local URL when you're running it on your machine.
|
| 31 |
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000';
|
| 32 |
|
| 33 |
const apiClient = axios.create({
|
| 34 |
baseURL: API_URL,
|
| 35 |
-
headers: {
|
| 36 |
-
'Content-Type': 'application/json',
|
| 37 |
-
},
|
| 38 |
});
|
| 39 |
|
| 40 |
-
export const createJob = (ticker) => {
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
export const getJob = (jobId) => {
|
| 45 |
-
return apiClient.get(`/jobs/${jobId}`);
|
| 46 |
-
};
|
| 47 |
-
|
| 48 |
-
export const getJobsHistory = () => {
|
| 49 |
-
return apiClient.get('/jobs');
|
| 50 |
-
};
|
|
|
|
| 23 |
|
| 24 |
|
| 25 |
|
|
|
|
| 26 |
import axios from 'axios';
|
| 27 |
|
|
|
|
|
|
|
| 28 |
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000';
|
| 29 |
|
| 30 |
const apiClient = axios.create({
|
| 31 |
baseURL: API_URL,
|
| 32 |
+
headers: { 'Content-Type': 'application/json' },
|
|
|
|
|
|
|
| 33 |
});
|
| 34 |
|
| 35 |
+
export const createJob = (ticker) => apiClient.post('/jobs', { ticker });
|
| 36 |
+
export const getJob = (jobId) => apiClient.get(`/jobs/${jobId}`);
|
| 37 |
+
export const getJobsHistory = () => apiClient.get('/jobs');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render.yaml
CHANGED
|
@@ -1,59 +1,61 @@
|
|
| 1 |
services:
|
| 2 |
-
# The Redis
|
| 3 |
- type: redis
|
| 4 |
-
name: redis
|
| 5 |
plan: free
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
# The Backend
|
| 8 |
- type: web
|
| 9 |
-
name: backend
|
| 10 |
plan: free
|
| 11 |
env: docker
|
| 12 |
dockerfilePath: ./backend/Dockerfile
|
| 13 |
dockerContext: .
|
| 14 |
-
#
|
| 15 |
healthCheckPath: /
|
| 16 |
envVars:
|
| 17 |
- key: DATABASE_URL
|
| 18 |
fromDatabase:
|
| 19 |
-
name:
|
| 20 |
property: connectionString
|
| 21 |
- key: CELERY_BROKER_URL
|
| 22 |
fromService:
|
| 23 |
type: redis
|
| 24 |
-
name: redis
|
| 25 |
property: connectionString
|
| 26 |
- key: CELERY_RESULT_BACKEND
|
| 27 |
fromService:
|
| 28 |
type: redis
|
| 29 |
-
name: redis
|
| 30 |
property: connectionString
|
| 31 |
- key: GOOGLE_API_KEY
|
| 32 |
-
sync: false # We will set this secret manually
|
| 33 |
|
| 34 |
-
# The Celery Worker
|
| 35 |
- type: worker
|
| 36 |
-
name: worker
|
| 37 |
plan: free
|
| 38 |
env: docker
|
| 39 |
dockerfilePath: ./backend/Dockerfile
|
| 40 |
dockerContext: .
|
| 41 |
-
#
|
| 42 |
-
|
| 43 |
envVars:
|
| 44 |
- key: DATABASE_URL
|
| 45 |
fromDatabase:
|
| 46 |
-
name:
|
| 47 |
property: connectionString
|
| 48 |
- key: CELERY_BROKER_URL
|
| 49 |
fromService:
|
| 50 |
type: redis
|
| 51 |
-
name: redis
|
| 52 |
property: connectionString
|
| 53 |
- key: CELERY_RESULT_BACKEND
|
| 54 |
fromService:
|
| 55 |
type: redis
|
| 56 |
-
name: redis
|
| 57 |
property: connectionString
|
| 58 |
- key: GOOGLE_API_KEY
|
| 59 |
sync: false
|
|
|
|
| 1 |
services:
|
| 2 |
+
# Service 1: The Redis instance for Celery
|
| 3 |
- type: redis
|
| 4 |
+
name: redis-cache
|
| 5 |
plan: free
|
| 6 |
+
# This is required for security on Render's free plan
|
| 7 |
+
ipAllowList: []
|
| 8 |
|
| 9 |
+
# Service 2: The Backend FastAPI Web Server
|
| 10 |
- type: web
|
| 11 |
+
name: backend-api
|
| 12 |
plan: free
|
| 13 |
env: docker
|
| 14 |
dockerfilePath: ./backend/Dockerfile
|
| 15 |
dockerContext: .
|
| 16 |
+
# Render's free web services listen on port 10000
|
| 17 |
healthCheckPath: /
|
| 18 |
envVars:
|
| 19 |
- key: DATABASE_URL
|
| 20 |
fromDatabase:
|
| 21 |
+
name: neon-database # We will create this name in the next step
|
| 22 |
property: connectionString
|
| 23 |
- key: CELERY_BROKER_URL
|
| 24 |
fromService:
|
| 25 |
type: redis
|
| 26 |
+
name: redis-cache
|
| 27 |
property: connectionString
|
| 28 |
- key: CELERY_RESULT_BACKEND
|
| 29 |
fromService:
|
| 30 |
type: redis
|
| 31 |
+
name: redis-cache
|
| 32 |
property: connectionString
|
| 33 |
- key: GOOGLE_API_KEY
|
| 34 |
+
sync: false # We will set this secret manually in the UI
|
| 35 |
|
| 36 |
+
# Service 3: The Celery Background Worker
|
| 37 |
- type: worker
|
| 38 |
+
name: celery-worker
|
| 39 |
plan: free
|
| 40 |
env: docker
|
| 41 |
dockerfilePath: ./backend/Dockerfile
|
| 42 |
dockerContext: .
|
| 43 |
+
# This command overrides the CMD in the Dockerfile to start the worker
|
| 44 |
+
dockerCommand: "python -m celery -A celery_worker.celery worker --loglevel=info"
|
| 45 |
envVars:
|
| 46 |
- key: DATABASE_URL
|
| 47 |
fromDatabase:
|
| 48 |
+
name: neon-database # We will create this name in the next step
|
| 49 |
property: connectionString
|
| 50 |
- key: CELERY_BROKER_URL
|
| 51 |
fromService:
|
| 52 |
type: redis
|
| 53 |
+
name: redis-cache
|
| 54 |
property: connectionString
|
| 55 |
- key: CELERY_RESULT_BACKEND
|
| 56 |
fromService:
|
| 57 |
type: redis
|
| 58 |
+
name: redis-cache
|
| 59 |
property: connectionString
|
| 60 |
- key: GOOGLE_API_KEY
|
| 61 |
sync: false
|