new api service and logic implemented
This commit is contained in:
38
DockerApiServices/AuthServiceApi/Dockerfile
Normal file
38
DockerApiServices/AuthServiceApi/Dockerfile
Normal file
@@ -0,0 +1,38 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies and Poetry
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
gcc \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& pip install --no-cache-dir poetry
|
||||
|
||||
# Copy Poetry configuration
|
||||
COPY DockerApiServices/pyproject.toml ./pyproject.toml
|
||||
|
||||
# Configure Poetry and install dependencies with optimizations
|
||||
RUN poetry config virtualenvs.create false \
|
||||
&& poetry install --no-interaction --no-ansi --no-root --only main \
|
||||
&& pip cache purge \
|
||||
&& rm -rf ~/.cache/pypoetry
|
||||
|
||||
# Copy application code
|
||||
COPY DockerApiServices/AllApiNeeds /app
|
||||
|
||||
# Copy application code
|
||||
COPY ApiLayers /app/ApiLayers
|
||||
|
||||
# Events
|
||||
COPY Events/AllEvents/auth /app/Events/AllEvents/auth
|
||||
COPY Events/base_request_model.py /app/Events/base_request_model.py
|
||||
COPY Events/abstract_class.py /app/Events/abstract_class.py
|
||||
|
||||
# Set Python path to include app directory
|
||||
ENV PYTHONPATH=/app \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
# Run the application using the configured uvicorn server
|
||||
CMD ["poetry", "run", "python", "app.py"]
|
||||
15
DockerApiServices/AuthServiceApi/requirements.txt
Normal file
15
DockerApiServices/AuthServiceApi/requirements.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
fastapi==0.104.1
|
||||
uvicorn==0.24.0.post1
|
||||
pydantic==2.10.5
|
||||
sqlalchemy==2.0.37
|
||||
psycopg2-binary==2.9.10
|
||||
python-dateutil==2.9.0.post0
|
||||
motor==3.3.2
|
||||
redis==5.2.1
|
||||
pytest==7.4.4
|
||||
pytest-asyncio==0.21.2
|
||||
pytest-cov==4.1.0
|
||||
coverage==7.6.10
|
||||
arrow==1.3.0
|
||||
redmail==0.6.0
|
||||
sqlalchemy-mixins==2.0.5
|
||||
45
DockerApiServices/EventServiceApi/Dockerfile
Normal file
45
DockerApiServices/EventServiceApi/Dockerfile
Normal file
@@ -0,0 +1,45 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies and Poetry
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
gcc \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& pip install --no-cache-dir poetry
|
||||
|
||||
# Copy Poetry configuration
|
||||
COPY DockerApiServices/pyproject.toml ./pyproject.toml
|
||||
|
||||
# Configure Poetry and install dependencies with optimizations
|
||||
RUN poetry config virtualenvs.create false \
|
||||
&& poetry install --no-interaction --no-ansi --no-root --only main \
|
||||
&& pip cache purge \
|
||||
&& rm -rf ~/.cache/pypoetry
|
||||
|
||||
# Copy application code
|
||||
COPY DockerApiServices/AllApiNeeds /app
|
||||
COPY ErrorHandlers /app/ErrorHandlers
|
||||
COPY LanguageModels /app/LanguageModels
|
||||
COPY ApiLibrary /app/ApiLibrary
|
||||
COPY ApiValidations /app/ApiValidations
|
||||
COPY AllConfigs /app/AllConfigs
|
||||
COPY ErrorHandlers /app/ErrorHandlers
|
||||
COPY Schemas /app/Schemas
|
||||
COPY Services /app/Services
|
||||
COPY ApiServices /app/ApiServices
|
||||
|
||||
# Copy Events structure with consistent naming
|
||||
COPY ApiEvents/EventServiceApi /app/ApiEvents
|
||||
COPY ApiEvents/abstract_class.py /app/ApiEvents/abstract_class.py
|
||||
COPY ApiEvents/base_request_model.py /app/ApiEvents/base_request_model.py
|
||||
|
||||
|
||||
# Set Python path to include app directory
|
||||
ENV PYTHONPATH=/app \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
# Run the application using the configured uvicorn server
|
||||
CMD ["poetry", "run", "python", "app.py"]
|
||||
57
DockerApiServices/README.md
Normal file
57
DockerApiServices/README.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# Docker Services Guide
|
||||
|
||||
This repository contains multiple microservices that can be run using Docker Compose.
|
||||
|
||||
## Quick Start (With Cache)
|
||||
For regular development when dependencies haven't changed:
|
||||
```bash
|
||||
# Build and run Auth Service
|
||||
docker compose -f docker-compose-services.yml up auth-service
|
||||
|
||||
# Build and run Event Service
|
||||
docker compose -f docker-compose-services.yml up event-service
|
||||
|
||||
# Build and run Validation Service
|
||||
docker compose -f docker-compose-services.yml up validation-service
|
||||
|
||||
# Build and run all services
|
||||
docker compose -f docker-compose-services.yml up
|
||||
```
|
||||
|
||||
## Clean Build (No Cache)
|
||||
Use these commands when changing Dockerfile or dependencies:
|
||||
```bash
|
||||
# Auth Service
|
||||
docker compose -f docker-compose-services.yml build --no-cache auth-service && docker compose -f docker-compose-services.yml up auth-service
|
||||
|
||||
# Event Service
|
||||
docker compose -f docker-compose-services.yml build --no-cache event-service && docker compose -f docker-compose-services.yml up event-service
|
||||
|
||||
# Validation Service
|
||||
docker compose -f docker-compose-services.yml build --no-cache validation-service && docker compose -f docker-compose-services.yml up validation-service
|
||||
|
||||
# All Services
|
||||
docker compose -f docker-compose-services.yml build --no-cache && docker compose -f docker-compose-services.yml up
|
||||
```
|
||||
|
||||
## Service Ports
|
||||
- Auth Service: http://localhost:41575
|
||||
- Event Service: http://localhost:41576
|
||||
- Validation Service: http://localhost:41577
|
||||
|
||||
## Development Notes
|
||||
- Use clean build (--no-cache) when:
|
||||
- Changing Dockerfile
|
||||
- Updating dependencies
|
||||
- Experiencing caching issues
|
||||
- Use regular build (with cache) when:
|
||||
- Only changing application code
|
||||
- For faster development iterations
|
||||
- Run in detached mode:
|
||||
```bash
|
||||
docker compose -f docker-compose-services.yml up -d auth-service
|
||||
```
|
||||
- Stop services:
|
||||
```bash
|
||||
docker compose -f docker-compose-services.yml down
|
||||
```
|
||||
46
DockerApiServices/ValidationServiceApi/Dockerfile
Normal file
46
DockerApiServices/ValidationServiceApi/Dockerfile
Normal file
@@ -0,0 +1,46 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies and Poetry
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
gcc \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& pip install --no-cache-dir poetry
|
||||
|
||||
# Copy Poetry configuration
|
||||
COPY DockerApiServices/pyproject.toml ./pyproject.toml
|
||||
|
||||
# Configure Poetry and install dependencies with optimizations
|
||||
RUN poetry config virtualenvs.create false \
|
||||
&& poetry install --no-interaction --no-ansi --no-root --only main \
|
||||
&& pip cache purge \
|
||||
&& rm -rf ~/.cache/pypoetry
|
||||
|
||||
# Copy application code
|
||||
COPY DockerApiServices/AllApiNeeds /app
|
||||
COPY ErrorHandlers /app/ErrorHandlers
|
||||
COPY LanguageModels /app/LanguageModels
|
||||
COPY ApiLibrary /app/ApiLibrary
|
||||
COPY ApiValidations /app/ApiValidations
|
||||
COPY AllConfigs /app/AllConfigs
|
||||
COPY ErrorHandlers /app/ErrorHandlers
|
||||
COPY Schemas /app/Schemas
|
||||
COPY Services /app/Services
|
||||
COPY ApiServices /app/ApiServices
|
||||
|
||||
# Copy Events structure with consistent naming
|
||||
COPY ApiEvents/ValidationServiceApi /app/ApiEvents
|
||||
ADD ApiEvents/AuthServiceApi/events /app/ApiEvents/events
|
||||
ADD ApiEvents/EventServiceApi/events /app/ApiEvents/events
|
||||
COPY ApiEvents/abstract_class.py /app/ApiEvents/abstract_class.py
|
||||
COPY ApiEvents/base_request_model.py /app/ApiEvents/base_request_model.py
|
||||
|
||||
# Set Python path to include app directory
|
||||
ENV PYTHONPATH=/app \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
# Run the application using the configured uvicorn server
|
||||
CMD ["poetry", "run", "python", "app.py"]
|
||||
83
DockerApiServices/pyproject.toml
Normal file
83
DockerApiServices/pyproject.toml
Normal file
@@ -0,0 +1,83 @@
|
||||
[tool.poetry]
|
||||
name = "wag-management-api-services"
|
||||
version = "0.1.1"
|
||||
description = "WAG Management API Service"
|
||||
authors = ["Karatay Berkay <karatay.berkay@evyos.com.tr>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.9"
|
||||
# FastAPI and Web
|
||||
fastapi = "^0.104.1"
|
||||
uvicorn = "^0.24.0"
|
||||
pydantic = "^2.5.2"
|
||||
|
||||
# MongoDB
|
||||
motor = "3.3.2" # Pinned version
|
||||
pymongo = "4.5.0" # Pinned version to match motor
|
||||
|
||||
# PostgreSQL
|
||||
sqlalchemy = "^2.0.23"
|
||||
sqlalchemy-mixins = "^2.0.5"
|
||||
psycopg2-binary = "^2.9.9"
|
||||
|
||||
# Redis
|
||||
redis = "^5.0.1"
|
||||
arrow = "^1.3.0"
|
||||
|
||||
# Email
|
||||
redmail = "^0.6.0"
|
||||
|
||||
# Testing
|
||||
pytest = "^7.4.3"
|
||||
pytest-asyncio = "^0.21.1"
|
||||
pytest-cov = "^4.1.0"
|
||||
|
||||
# Monitoring
|
||||
prometheus-client = "^0.19.0"
|
||||
prometheus-fastapi-instrumentator = "^6.1.0"
|
||||
|
||||
# Cryptography
|
||||
cryptography = "^43.0.3"
|
||||
|
||||
# Utilities
|
||||
python-dateutil = "^2.8.2"
|
||||
typing-extensions = "^4.8.0"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
black = "^23.11.0"
|
||||
isort = "^5.12.0"
|
||||
mypy = "^1.7.1"
|
||||
flake8 = "^6.1.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.black]
|
||||
line-length = 88
|
||||
target-version = ['py39']
|
||||
include = '\.pyi?$'
|
||||
|
||||
[tool.isort]
|
||||
profile = "black"
|
||||
multi_line_output = 3
|
||||
include_trailing_comma = true
|
||||
force_grid_wrap = 0
|
||||
use_parentheses = true
|
||||
line_length = 88
|
||||
|
||||
[tool.mypy]
|
||||
python_version = "3.9"
|
||||
warn_return_any = true
|
||||
warn_unused_configs = true
|
||||
disallow_untyped_defs = true
|
||||
check_untyped_defs = true
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
minversion = "6.0"
|
||||
addopts = "-ra -q --cov=Services"
|
||||
testpaths = [
|
||||
"Ztest",
|
||||
]
|
||||
python_files = ["test_*.py"]
|
||||
asyncio_mode = "auto"
|
||||
17
DockerApiServices/requirements.txt
Normal file
17
DockerApiServices/requirements.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
fastapi==0.104.1
|
||||
uvicorn==0.24.0.post1
|
||||
pydantic==2.10.5
|
||||
sqlalchemy==2.0.37
|
||||
psycopg2-binary==2.9.10
|
||||
python-dateutil==2.9.0.post0
|
||||
motor==3.3.2
|
||||
redis==5.2.1
|
||||
pytest==7.4.4
|
||||
pytest-asyncio==0.21.2
|
||||
pytest-cov==4.1.0
|
||||
coverage==7.6.10
|
||||
arrow==1.3.0
|
||||
redmail==0.6.0
|
||||
sqlalchemy-mixins==2.0.5
|
||||
prometheus-client==0.19.0
|
||||
prometheus-fastapi-instrumentator==6.1.0
|
||||
29
DockerApiServices/steps.txt
Normal file
29
DockerApiServices/steps.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
WAG Management API Microservices Setup
|
||||
|
||||
1. Authentication Service (Port 8000)
|
||||
- User authentication and authorization
|
||||
- JWT token management
|
||||
- Role-based access control
|
||||
- Uses PostgreSQL for user data
|
||||
|
||||
2. Event Service (Port 8001)
|
||||
- Event processing and handling
|
||||
- Message queue integration
|
||||
- Real-time notifications
|
||||
- Uses MongoDB for event storage
|
||||
|
||||
3. Validation Service (Port 8002)
|
||||
- Request validation
|
||||
- Data sanitization
|
||||
- Schema validation
|
||||
- Uses Redis for caching
|
||||
|
||||
To run the services:
|
||||
```bash
|
||||
docker compose up --build
|
||||
```
|
||||
|
||||
Access services at:
|
||||
- Auth Service: http://localhost:8000
|
||||
- Event Service: http://localhost:8001
|
||||
- Validation Service: http://localhost:8002
|
||||
Reference in New Issue
Block a user