Skip to content

Commit d5e6883

Browse files
committed
feat : docker-compose and dockerfile added
1 parent 184d097 commit d5e6883

File tree

9 files changed

+65
-19
lines changed

9 files changed

+65
-19
lines changed

Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM python:3.10-alpine
2+
3+
WORKDIR /Ookla
4+
5+
COPY requirements.txt .
6+
RUN pip install --no-cache-dir -r requirements.txt
7+
8+
COPY . .
9+
10+
ENV DEBUG=True
11+
12+
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]

api/models.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
class Users(Base):
77
__tablename__= "users"
88
id = Column(Integer, primary_key=True)
9-
username = Column(String(50), nullable=False, min_length=4 , max_length=100)
9+
username = Column(String(50), nullable=False)
1010
email = Column(String(100), nullable=False, unique=True)
11-
password = Column(String(128), nullable=False, min_length = 5)
11+
password = Column(String(255), nullable=False)
1212
is_admin = Column(Boolean, default=False)
1313

1414

@@ -21,9 +21,9 @@ def check_password(self, password):
2121
class Event(Base):
2222
__tablename__ = "events"
2323
id = Column(Integer, primary_key=True, index=True)
24-
name = Column(String, index=True)
24+
name = Column(String(250), index=True)
2525
date = Column(DateTime)
26-
location = Column(String)
26+
location = Column(String(250))
2727
latitude = Column(Float)
2828
longitude = Column(Float)
2929
available_tickets = Column(Integer)
@@ -47,7 +47,7 @@ class Booking(Base):
4747
user_id = Column(Integer, ForeignKey("users.id"))
4848
number_of_tickets = Column(Integer)
4949
total_price = Column(Integer)
50-
order_status = Column(String)
50+
order_status = Column(String(150))
5151
event = relationship("Event")
5252

5353
# class Payments(Base)

api/routes/auth.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def register(request : UserSchema, db: Session = Depends(get_db)):
4848
db.add(user)
4949
db.commit()
5050
db.refresh(user)
51-
return {'id':user.id, 'name':user.name,'email':user.email}
51+
return {'id':user.id, 'name':user.username,'email':user.email}
5252

5353
except IntegrityError:
5454
db.rollback()

api/routes/events.py

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'''
22
Written By : Faizmohammad Nandoliya
3-
Last Updated : 14-08-2024
3+
Last Updated : 15-08-2024
44
55
66
NOTE : In function 'geocode_address' I have handled "else" block manually kindly change that in production.
@@ -23,12 +23,13 @@
2323

2424

2525
paypalrestsdk.configure({
26-
"mode": PAYPAL_ENV, # sandbox or live
26+
"mode": PAYPAL_ENV,
2727
"client_id": PAYPAL_CLIENT_ID,
2828
"client_secret": PAYPAL_SECRET_KEY })
2929

3030
router = APIRouter()
3131

32+
# function that returns coordinates from raw text address
3233
def geocode_address(address: str):
3334
url = f"https://maps.googleapis.com/maps/api/geocode/json"
3435
params = {
@@ -42,7 +43,7 @@ def geocode_address(address: str):
4243
location = data['results'][0]['geometry']['location']
4344
return location['lat'], location['lng']
4445
else:
45-
# raise error here TEMPORARY returning Oolka office cordinates
46+
# NOTE :raise error here TEMPORARY returning Oolka office cordinates
4647
return 12.925738470141543, 77.67473271259571
4748

4849
# get the current loggedIn user from token decoding and model
@@ -333,14 +334,7 @@ async def cancel(request: Request,booking_id : str, jwt_token: str, db: Session
333334

334335

335336

336-
"""
337-
1. Accept book request - Done
338-
2. Check tickets avaibale - Done
339-
3. Check event exisit - Done
340-
4. Create and reserve tickets until the payment has been made 1 minutes // Enhancement
341-
5. If payment is succesfull - remove reserved tickets
342-
6. If payment is failed - remove reserved tickets and add it in total tickets
343-
"""
337+
344338

345339

346340
""""
@@ -349,4 +343,5 @@ async def cancel(request: Request,booking_id : str, jwt_token: str, db: Session
349343
2. When user land on cancel or success with expire token
350344
3. If same user has pending orders with same event or new event - take care of this so total tickets stays accurate
351345
4. Limit the booking tickets so not single person can buy each ticket at a time
346+
5. Encrypt and decrypt the parameters we passing to paypal url
352347
"""

api/routes/index.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from fastapi import APIRouter
2-
2+
import os
33

44
router = APIRouter()
55

66
@router.get("/")
77
def index():
8-
return {"message":"API's are live on web!!!"}
8+
return {"message":"API's are live on web!!!"+ str(os.getenv('DATABASE_URL'))}

docker-compose.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: '3.10'
2+
services:
3+
app:
4+
build: .
5+
command: uvicorn api.main:app --host 0.0.0.0
6+
ports:
7+
- "8000:8000"
8+
9+

events.db

0 Bytes
Binary file not shown.

pip

Whitespace-only changes.

requirements.txt

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
annotated-types==0.7.0
2+
anyio==4.4.0
3+
certifi==2024.7.4
4+
cffi==1.17.0
5+
charset-normalizer==3.3.2
6+
click==8.1.7
7+
cryptography==43.0.0
8+
dnspython==2.6.1
9+
email_validator==2.2.0
10+
fastapi==0.112.0
11+
h11==0.14.0
12+
idna==3.7
13+
MarkupSafe==2.1.5
14+
paypalrestsdk==1.13.3
15+
pycparser==2.22
16+
pydantic==2.8.2
17+
pydantic_core==2.20.1
18+
PyJWT==2.9.0
19+
pyOpenSSL==24.2.1
20+
python-dotenv==1.0.1
21+
requests==2.32.3
22+
six==1.16.0
23+
sniffio==1.3.1
24+
SQLAlchemy==2.0.32
25+
starlette==0.37.2
26+
typing_extensions==4.12.2
27+
urllib3==2.2.2
28+
uvicorn==0.30.6
29+
Werkzeug==3.0.3
30+
pymysql

0 commit comments

Comments
 (0)