Spaces:
Sleeping
Sleeping
Commit ·
ff7d784
1
Parent(s): 830a2d0
env changes
Browse files- .env +5 -1
- Dockerfile +30 -0
- app/__pycache__/app.cpython-311.pyc +0 -0
- app/__pycache__/sql.cpython-311.pyc +0 -0
- app/controllers/__pycache__/appointment_controller.cpython-311.pyc +0 -0
- app/models/__pycache__/appointment_model.cpython-311.pyc +0 -0
- app/models/appointment_model.py +1 -1
- app/repositories/__pycache__/appointment_repository.cpython-311.pyc +0 -0
- app/repositories/appointment_repository.py +1 -1
- app/services/__pycache__/appointment_service.cpython-311.pyc +0 -0
- app/sql.py +5 -0
- app/views/__pycache__/appointment_view.cpython-311.pyc +0 -0
- requirements.txt +19 -0
.env
CHANGED
|
@@ -1,5 +1,9 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
CACHE_URI=redis-13158.c212.ap-south-1-1.ec2.redns.redis-cloud.com:13158
|
| 4 |
|
| 5 |
CACHE_K=Mi5bLjJHt5KFlGjnx04K269Dt2w7hdup
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
DB_NAME=make-my-service
|
| 3 |
+
|
| 4 |
+
DATABASE_URI=postgresql+asyncpg://trans_owner:BookMyService7@ep-sweet-surf-a1qeduoy.ap-southeast-1.aws.neon.tech/bookmyservice?options=-csearch_path%3Dtrans
|
| 5 |
|
| 6 |
CACHE_URI=redis-13158.c212.ap-south-1-1.ec2.redns.redis-cloud.com:13158
|
| 7 |
|
| 8 |
CACHE_K=Mi5bLjJHt5KFlGjnx04K269Dt2w7hdup
|
| 9 |
+
|
Dockerfile
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a lightweight and stable Python 3.11 base image
|
| 2 |
+
FROM python:3.11-slim-buster AS base
|
| 3 |
+
|
| 4 |
+
# Set environment variables for production
|
| 5 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 6 |
+
PYTHONDONTWRITEBYTECODE=1 \
|
| 7 |
+
PATH="/home/user/.local/bin:$PATH"
|
| 8 |
+
|
| 9 |
+
# Add a non-root user for security
|
| 10 |
+
RUN useradd -m -u 1000 user
|
| 11 |
+
|
| 12 |
+
# Switch to non-root user
|
| 13 |
+
USER user
|
| 14 |
+
|
| 15 |
+
# Set working directory
|
| 16 |
+
WORKDIR /app
|
| 17 |
+
|
| 18 |
+
# Install dependencies
|
| 19 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
| 20 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 21 |
+
pip install --no-cache-dir --upgrade -r requirements.txt
|
| 22 |
+
|
| 23 |
+
# Copy application files
|
| 24 |
+
COPY --chown=user . /app
|
| 25 |
+
|
| 26 |
+
# Expose the application port
|
| 27 |
+
EXPOSE 7860
|
| 28 |
+
|
| 29 |
+
# Command to run the application
|
| 30 |
+
CMD ["uvicorn", "app.app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "4", "--log-level", "info"]
|
app/__pycache__/app.cpython-311.pyc
ADDED
|
Binary file (1.21 kB). View file
|
|
|
app/__pycache__/sql.cpython-311.pyc
ADDED
|
Binary file (3.13 kB). View file
|
|
|
app/controllers/__pycache__/appointment_controller.cpython-311.pyc
ADDED
|
Binary file (1.33 kB). View file
|
|
|
app/models/__pycache__/appointment_model.cpython-311.pyc
ADDED
|
Binary file (3 kB). View file
|
|
|
app/models/appointment_model.py
CHANGED
|
@@ -3,7 +3,7 @@ from datetime import date, time, datetime
|
|
| 3 |
from typing import List
|
| 4 |
from enum import Enum
|
| 5 |
import sqlalchemy
|
| 6 |
-
from app.
|
| 7 |
|
| 8 |
class AppointmentStatus(str, Enum):
|
| 9 |
confirmed = "confirmed"
|
|
|
|
| 3 |
from typing import List
|
| 4 |
from enum import Enum
|
| 5 |
import sqlalchemy
|
| 6 |
+
from app.sql import metadata
|
| 7 |
|
| 8 |
class AppointmentStatus(str, Enum):
|
| 9 |
confirmed = "confirmed"
|
app/repositories/__pycache__/appointment_repository.cpython-311.pyc
ADDED
|
Binary file (2.6 kB). View file
|
|
|
app/repositories/appointment_repository.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
from app.models.appointment_model import appointment_table
|
| 2 |
-
from app.
|
| 3 |
|
| 4 |
async def create_appointment(appointment_data: dict):
|
| 5 |
query = appointment_table.insert().values(**appointment_data)
|
|
|
|
| 1 |
from app.models.appointment_model import appointment_table
|
| 2 |
+
from app.sql import database
|
| 3 |
|
| 4 |
async def create_appointment(appointment_data: dict):
|
| 5 |
query = appointment_table.insert().values(**appointment_data)
|
app/services/__pycache__/appointment_service.cpython-311.pyc
ADDED
|
Binary file (2.41 kB). View file
|
|
|
app/sql.py
CHANGED
|
@@ -15,6 +15,11 @@ logging.basicConfig(
|
|
| 15 |
logger = logging.getLogger(__name__)
|
| 16 |
|
| 17 |
# Load the DATABASE_URL from environment variables
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
DATABASE_URL = os.getenv("DATABASE_URI")
|
| 19 |
|
| 20 |
if not DATABASE_URL:
|
|
|
|
| 15 |
logger = logging.getLogger(__name__)
|
| 16 |
|
| 17 |
# Load the DATABASE_URL from environment variables
|
| 18 |
+
|
| 19 |
+
# Explicitly load the .env file from the current project directory
|
| 20 |
+
ENV_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../.env")
|
| 21 |
+
load_dotenv(dotenv_path=ENV_PATH)
|
| 22 |
+
|
| 23 |
DATABASE_URL = os.getenv("DATABASE_URI")
|
| 24 |
|
| 25 |
if not DATABASE_URL:
|
app/views/__pycache__/appointment_view.cpython-311.pyc
ADDED
|
Binary file (566 Bytes). View file
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi==0.100.0
|
| 2 |
+
uvicorn==0.23.2
|
| 3 |
+
pymongo==4.7.0
|
| 4 |
+
motor==3.1.1
|
| 5 |
+
redis==4.6.0
|
| 6 |
+
python-jose==3.3.0
|
| 7 |
+
bcrypt==4.0.1
|
| 8 |
+
python-dotenv==1.0.0
|
| 9 |
+
bloom-filter2==2.0.0
|
| 10 |
+
phonenumbers==8.13.18
|
| 11 |
+
requests==2.31.0
|
| 12 |
+
pydantic[email]==1.10.9
|
| 13 |
+
email-validator==1.3.1
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
starlette==0.27.0
|
| 17 |
+
httpx==0.24.1
|
| 18 |
+
pytest==7.4.0
|
| 19 |
+
pytest-asyncio==0.21.0
|