diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..4b5c4300af03b2c03c18dfcf283e5838ad31eba9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +version: '3' + +services: + bikes_service: + build: ./bikes_service + ports: + - "8001:8001" + + admins_service: + build: ./admins_service + ports: + - "8002:8002" + + rentals_service: + build: ./rentals_service + ports: + - "8003:8003" + + reviews_service: + build: ./bikes_service + ports: + - "8001:8001" + + users_service: + build: ./admins_service + ports: + - "8002:8002" + diff --git a/microservices/admins_service/DockerFIle b/microservices/admins_service/DockerFIle new file mode 100644 index 0000000000000000000000000000000000000000..1b85985223631643774e3b43b48bf6b4c3ab2d28 --- /dev/null +++ b/microservices/admins_service/DockerFIle @@ -0,0 +1,19 @@ +# Use the official Python image as the base image +FROM python:3.9-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy the dependencies file to the working directory +COPY requirements.txt . + +# Install any dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application code to the working directory +COPY . . + +EXPOSE 8002 + +# Command to run the application +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8002"] diff --git a/microservices/admins_service/requirements.txt b/microservices/admins_service/requirements.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6c5d0fd629eb8d43f287e646dcef2a1d9fb7a8f4 100644 --- a/microservices/admins_service/requirements.txt +++ b/microservices/admins_service/requirements.txt @@ -0,0 +1,34 @@ +annotated-types==0.6.0 +anyio==4.3.0 +certifi==2024.2.2 +click==8.1.7 +dnspython==2.6.1 +email_validator==2.1.1 +exceptiongroup==1.2.0 +fastapi==0.110.0 +greenlet==3.0.3 +h11==0.14.0 +httpcore==1.0.5 +httptools==0.6.1 +httpx==0.27.0 +idna==3.6 +itsdangerous==2.1.2 +Jinja2==3.1.3 +MarkupSafe==2.1.5 +orjson==3.10.0 +pydantic==2.6.4 +pydantic-extra-types==2.6.0 +pydantic-settings==2.2.1 +pydantic_core==2.16.3 +python-dotenv==1.0.1 +python-multipart==0.0.9 +PyYAML==6.0.1 +sniffio==1.3.1 +SQLAlchemy==2.0.29 +starlette==0.36.3 +typing_extensions==4.10.0 +ujson==5.9.0 +uvicorn==0.29.0 +uvloop==0.19.0 +watchfiles==0.21.0 +websockets==12.0 diff --git a/microservices/bikes_service/Dockerfile b/microservices/bikes_service/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6780237e514fd945a9339050820bea3a3e2b2ebe --- /dev/null +++ b/microservices/bikes_service/Dockerfile @@ -0,0 +1,18 @@ +# Use the official Python image as the base image +FROM python:3.9-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy the dependencies file to the working directory +COPY requirements.txt . + +# Install any dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application code to the working directory +COPY . . +EXPOSE 8001 + +# Command to run the application +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8001"] diff --git a/microservices/bikes_service/local_bike.db b/microservices/bikes_service/local_bike.db new file mode 100644 index 0000000000000000000000000000000000000000..865b2b7182c807dfa9118534660eb75e09466302 Binary files /dev/null and b/microservices/bikes_service/local_bike.db differ diff --git a/microservices/bikes_service/main.py b/microservices/bikes_service/main.py index 4fd56d754a03dc5bd47f4e09a4bb7222dc4d2f57..3db395418c860a6feb104a7c5549a9903c5d40ce 100644 --- a/microservices/bikes_service/main.py +++ b/microservices/bikes_service/main.py @@ -25,6 +25,13 @@ parent_directory = Path(__file__).resolve().parent.parent # Specify the path to the SQLite database file in the data directory db_file_path = parent_directory / "my_ride.db" + +# Check if the database file exists +if not db_file_path.exists(): + # If the database file doesn't exist, use a local database file from the same location + local_db_file_path = Path(__file__).resolve().parent / "local_bike.db" + db_file_path = local_db_file_path + # print(db_file_path) conn = sqlite3.connect(db_file_path) diff --git a/microservices/bikes_service/requirements.txt b/microservices/bikes_service/requirements.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6c5d0fd629eb8d43f287e646dcef2a1d9fb7a8f4 100644 --- a/microservices/bikes_service/requirements.txt +++ b/microservices/bikes_service/requirements.txt @@ -0,0 +1,34 @@ +annotated-types==0.6.0 +anyio==4.3.0 +certifi==2024.2.2 +click==8.1.7 +dnspython==2.6.1 +email_validator==2.1.1 +exceptiongroup==1.2.0 +fastapi==0.110.0 +greenlet==3.0.3 +h11==0.14.0 +httpcore==1.0.5 +httptools==0.6.1 +httpx==0.27.0 +idna==3.6 +itsdangerous==2.1.2 +Jinja2==3.1.3 +MarkupSafe==2.1.5 +orjson==3.10.0 +pydantic==2.6.4 +pydantic-extra-types==2.6.0 +pydantic-settings==2.2.1 +pydantic_core==2.16.3 +python-dotenv==1.0.1 +python-multipart==0.0.9 +PyYAML==6.0.1 +sniffio==1.3.1 +SQLAlchemy==2.0.29 +starlette==0.36.3 +typing_extensions==4.10.0 +ujson==5.9.0 +uvicorn==0.29.0 +uvloop==0.19.0 +watchfiles==0.21.0 +websockets==12.0 diff --git a/microservices/rentals_service/DockerFIle b/microservices/rentals_service/DockerFIle new file mode 100644 index 0000000000000000000000000000000000000000..4314cb6383888fb96dfe6fcc8a20b207a8b770a9 --- /dev/null +++ b/microservices/rentals_service/DockerFIle @@ -0,0 +1,17 @@ +# Use the official Python image as the base image +FROM python:3.9-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy the dependencies file to the working directory +COPY requirements.txt . + +# Install any dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application code to the working directory +COPY . . + +# Command to run the application +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8003"] diff --git a/microservices/rentals_service/rentals.db b/microservices/rentals_service/rentals.db deleted file mode 100644 index b9e3d839ec0a26d0ceca6587137ffe766d990c68..0000000000000000000000000000000000000000 Binary files a/microservices/rentals_service/rentals.db and /dev/null differ diff --git a/microservices/rentals_service/requirements.txt b/microservices/rentals_service/requirements.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6c5d0fd629eb8d43f287e646dcef2a1d9fb7a8f4 100644 --- a/microservices/rentals_service/requirements.txt +++ b/microservices/rentals_service/requirements.txt @@ -0,0 +1,34 @@ +annotated-types==0.6.0 +anyio==4.3.0 +certifi==2024.2.2 +click==8.1.7 +dnspython==2.6.1 +email_validator==2.1.1 +exceptiongroup==1.2.0 +fastapi==0.110.0 +greenlet==3.0.3 +h11==0.14.0 +httpcore==1.0.5 +httptools==0.6.1 +httpx==0.27.0 +idna==3.6 +itsdangerous==2.1.2 +Jinja2==3.1.3 +MarkupSafe==2.1.5 +orjson==3.10.0 +pydantic==2.6.4 +pydantic-extra-types==2.6.0 +pydantic-settings==2.2.1 +pydantic_core==2.16.3 +python-dotenv==1.0.1 +python-multipart==0.0.9 +PyYAML==6.0.1 +sniffio==1.3.1 +SQLAlchemy==2.0.29 +starlette==0.36.3 +typing_extensions==4.10.0 +ujson==5.9.0 +uvicorn==0.29.0 +uvloop==0.19.0 +watchfiles==0.21.0 +websockets==12.0 diff --git a/microservices/reviews_service/DockerFIle b/microservices/reviews_service/DockerFIle new file mode 100644 index 0000000000000000000000000000000000000000..b34fe12f481f9fb25193dd7a52f88bcf0ce9d5ce --- /dev/null +++ b/microservices/reviews_service/DockerFIle @@ -0,0 +1,19 @@ +# Use the official Python image as the base image +FROM python:3.9-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy the dependencies file to the working directory +COPY requirements.txt . + +# Install any dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application code to the working directory +COPY . . + +EXPOSE 8004 + +# Command to run the application +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8004"] diff --git a/microservices/reviews_service/requirements.txt b/microservices/reviews_service/requirements.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6c5d0fd629eb8d43f287e646dcef2a1d9fb7a8f4 100644 --- a/microservices/reviews_service/requirements.txt +++ b/microservices/reviews_service/requirements.txt @@ -0,0 +1,34 @@ +annotated-types==0.6.0 +anyio==4.3.0 +certifi==2024.2.2 +click==8.1.7 +dnspython==2.6.1 +email_validator==2.1.1 +exceptiongroup==1.2.0 +fastapi==0.110.0 +greenlet==3.0.3 +h11==0.14.0 +httpcore==1.0.5 +httptools==0.6.1 +httpx==0.27.0 +idna==3.6 +itsdangerous==2.1.2 +Jinja2==3.1.3 +MarkupSafe==2.1.5 +orjson==3.10.0 +pydantic==2.6.4 +pydantic-extra-types==2.6.0 +pydantic-settings==2.2.1 +pydantic_core==2.16.3 +python-dotenv==1.0.1 +python-multipart==0.0.9 +PyYAML==6.0.1 +sniffio==1.3.1 +SQLAlchemy==2.0.29 +starlette==0.36.3 +typing_extensions==4.10.0 +ujson==5.9.0 +uvicorn==0.29.0 +uvloop==0.19.0 +watchfiles==0.21.0 +websockets==12.0 diff --git a/microservices/reviews_service/review.db b/microservices/reviews_service/review.db deleted file mode 100644 index 2d07e1bc5127de7eeaae96265f68529a2dc32ee0..0000000000000000000000000000000000000000 Binary files a/microservices/reviews_service/review.db and /dev/null differ diff --git a/microservices/users_service/DockerFIle b/microservices/users_service/DockerFIle new file mode 100644 index 0000000000000000000000000000000000000000..0ec1be9d080265daa252683be7273c95435bccbf --- /dev/null +++ b/microservices/users_service/DockerFIle @@ -0,0 +1,19 @@ +# Use the official Python image as the base image +FROM python:3.9-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy the dependencies file to the working directory +COPY requirements.txt . + +# Install any dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application code to the working directory +COPY . . + +EXPOSE 8005 + +# Command to run the application +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8005"] diff --git a/microservices/users_service/main.py b/microservices/users_service/main.py index 4ab60bea97d77134b61a3c5d90a5eeeafd9158ea..7d9f1f03939eff65241ba59640ad0823640ae20c 100644 --- a/microservices/users_service/main.py +++ b/microservices/users_service/main.py @@ -123,58 +123,6 @@ async def create_user(user: User): return user -# # Routes -# @app.post("/users/", response_model=User) -# async def create_user(user: User): -# print('hit') -# cursor.execute(''' -# INSERT INTO Users -# (username, password, email, phone_number, credit_card_info, registration_date, last_login) -# VALUES (?, ?, Optional[str]?, ?, ?, ?, ?) -# ''', ( -# user.username, user.password, user.email, user.phone_number, -# user.credit_card_info, user.registration_date, user.last_login -# )) -# conn.commit() -# return user - - -# @app.get("/users/", response_model=List[User]) -# async def read_users(): -# cursor.execute('SELECT * FROM Users') -# print("got record") -# users = cursor.fetchall() -# return users - -# @app.get("/users/", response_model=List[User]) -# async def read_users(): -# cursor.execute('SELECT * FROM Users') -# print("got record") -# users = cursor.fetchall() -# # Convert each row into a dictionary -# user_dicts = [] -# for user in users: -# # user_dict = { -# # "user_id": user[0], -# # "username": user[1], -# # # "password": user[2], -# # "email": user[3], -# # "phone_number": user[4], -# # # "credit_card_info": user[5], -# # "registration_date": user[6], -# # # "last_login": user[7] -# # } -# user_dict = { -# "user_id": user[0], -# "username": user[1], -# "email": user[2], -# "phone_number": user[3], -# "registration_date": user[4], -# # "last_login": user[7] -# } -# user_dicts.append(user_dict) -# return user_dicts - @app.get("/users/{user_id}", response_model=User) async def read_user(user_id: int): diff --git a/microservices/users_service/requirements.txt b/microservices/users_service/requirements.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6c5d0fd629eb8d43f287e646dcef2a1d9fb7a8f4 100644 --- a/microservices/users_service/requirements.txt +++ b/microservices/users_service/requirements.txt @@ -0,0 +1,34 @@ +annotated-types==0.6.0 +anyio==4.3.0 +certifi==2024.2.2 +click==8.1.7 +dnspython==2.6.1 +email_validator==2.1.1 +exceptiongroup==1.2.0 +fastapi==0.110.0 +greenlet==3.0.3 +h11==0.14.0 +httpcore==1.0.5 +httptools==0.6.1 +httpx==0.27.0 +idna==3.6 +itsdangerous==2.1.2 +Jinja2==3.1.3 +MarkupSafe==2.1.5 +orjson==3.10.0 +pydantic==2.6.4 +pydantic-extra-types==2.6.0 +pydantic-settings==2.2.1 +pydantic_core==2.16.3 +python-dotenv==1.0.1 +python-multipart==0.0.9 +PyYAML==6.0.1 +sniffio==1.3.1 +SQLAlchemy==2.0.29 +starlette==0.36.3 +typing_extensions==4.10.0 +ujson==5.9.0 +uvicorn==0.29.0 +uvloop==0.19.0 +watchfiles==0.21.0 +websockets==12.0