Skip to content

Commit a855be1

Browse files
Merge pull request #7 from yashksaini-coder/update
Docker build & deploy
2 parents c28dc60 + f9ea631 commit a855be1

File tree

9 files changed

+114
-14
lines changed

9 files changed

+114
-14
lines changed

.dockerignore

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Environment files
2+
.env
3+
.env.*
4+
*.env
5+
6+
# Version control
7+
.git
8+
.gitignore
9+
.svn
10+
.hg
11+
12+
# Development files
13+
node_modules
14+
venv
15+
__pycache__
16+
*.pyc
17+
*.pyo
18+
*.pyd
19+
.Python
20+
.pytest_cache
21+
.coverage
22+
coverage
23+
.tox
24+
25+
# IDE specific files
26+
.idea
27+
.vscode
28+
*.swp
29+
*.swo
30+
.DS_Store
31+
32+
# Build and dist directories
33+
dist
34+
build
35+
*.egg-info
36+
37+
# Log files
38+
*.log
39+
logs
40+
npm-debug.log*
41+
42+
# Docker specific
43+
Dockerfile
44+
docker-compose*.yml
45+
.docker
46+
47+
# Documentation
48+
docs
49+
README.md
50+
CHANGELOG.md
51+
LICENSE
52+
53+
# Test files
54+
test
55+
tests
File renamed without changes.

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.9-alpine
2+
3+
WORKDIR /usr/src/app
4+
5+
COPY requirements.txt ./
6+
7+
ENV GROQ_API_KEY=your_api_key
8+
9+
RUN pip install -r requirements.txt
10+
11+
COPY . .
12+
13+
EXPOSE 80
14+
15+
CMD ["fastapi", "run", "app.py", "--port", "80"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[![Keep Backend Active](https://github.com/yashksaini-coder/investo-server/actions/workflows/ping.yml/badge.svg)](https://github.com/yashksaini-coder/investo-server/actions/workflows/ping.yml)
22

3-
The Web API service to fetch financial query data from users and other different aspects. Used in the **[Investo-glow](https://github.com/yashksaini-coder/investo-glow)**
3+
The Web API service to fetch financial query data from users and other different aspects. Used in the **[Investo-glow](https://github.com/yashksaini-coder/investo-glow)** project.

agents.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
from agno.tools.duckduckgo import DuckDuckGoTools
1010
from agno.agent import Agent, RunResponse
1111

12-
load_dotenv(dotenv_path=".env")
13-
GROQ_API_KEY = os.getenv("api_key")
14-
12+
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
1513
groq_client = groq.Client(api_key=GROQ_API_KEY)
1614

1715
if not GROQ_API_KEY:

app.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
from topStocks import get_top_stocks
88
from agents import multi_ai
99
from agno.agent import RunResponse
10+
import datetime
11+
import requests
1012

11-
12-
load_dotenv(dotenv_path=".env")
13-
GROQ_API_KEY = os.getenv("api_key")
14-
13+
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
1514
groq_client = groq.Client(api_key=GROQ_API_KEY)
1615

1716
if not GROQ_API_KEY:
@@ -34,8 +33,34 @@ async def read_top_stocks():
3433
return stock_info
3534

3635
@app.get("/")
37-
def read_root():
38-
return {"message": "Welcome to Investo!"}
36+
async def read_root():
37+
return {"message": "Welcome to the Investo-glow Backend API!"}
38+
39+
40+
@app.get("health/") # Changed to GET since it's retrieving status
41+
async def health_check():
42+
try:
43+
return {
44+
"status": "healthy",
45+
"timestamp": datetime.datetime.now().isoformat(),
46+
"uptime": "OK",
47+
"api": {
48+
"groq_api": "connected" if GROQ_API_KEY else "not configured",
49+
},
50+
"ip": requests.client.host,
51+
"services": {
52+
"top_stocks": app.url_path_for("read_top_stocks"),
53+
"chat": app.url_path_for("chat"),
54+
"agent": app.url_path_for("ask"),
55+
},
56+
}
57+
58+
except Exception as e:
59+
return {
60+
"status": "unhealthy",
61+
"timestamp": datetime.datetime.now().isoformat(),
62+
"error": str(e)
63+
}
3964

4065
@app.get("/chat")
4166
def chat(query: str):

ask.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import os
33
from dotenv import load_dotenv
44

5-
load_dotenv(dotenv_path=".env")
6-
GROQ_API_KEY = os.getenv("api_key")
5+
load_dotenv()
76

7+
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
88
groq_client = groq.Client(api_key=GROQ_API_KEY)
99

1010
def chat(query: str):

docker-compose.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
services:
2+
web:
3+
build: .
4+
ports:
5+
- "8000:80"
6+
volumes:
7+
- .:/app

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ markdown-it-py==3.0.0
2929
MarkupSafe==3.0.2
3030
mdurl==0.1.2
3131
multitasking==0.0.11
32-
numpy==2.2.3
33-
pandas==2.2.3
32+
numpy>=1.22.4
33+
pandas>=2.2.3
3434
peewee==3.17.9
3535
platformdirs==4.3.6
3636
primp==0.12.1

0 commit comments

Comments
 (0)