diff --git a/DockerApiServices/AuthServiceApi/Dockerfile b/DockerApiServices/AuthServiceApi/Dockerfile index 5da8984..186477a 100644 --- a/DockerApiServices/AuthServiceApi/Dockerfile +++ b/DockerApiServices/AuthServiceApi/Dockerfile @@ -2,12 +2,23 @@ FROM python:3.9-slim WORKDIR /app -# Install system dependencies -RUN apt-get update && apt-get install -y \ - gcc \ - && rm -rf /var/lib/apt/lists/* +# 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 all required directories +# 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 ApiLibrary /app/ApiLibrary COPY ApiValidations /app/ApiValidations @@ -16,15 +27,10 @@ COPY ErrorHandlers /app/ErrorHandlers COPY Schemas /app/Schemas COPY Services /app/Services -# Install Python dependencies -COPY DockerApiServices/requirements.txt /app/ -RUN pip install --upgrade pip && pip install --no-cache-dir -r /app/requirements.txt - -# Copy application code -COPY . . - # Set Python path to include app directory -ENV PYTHONPATH=/app +ENV PYTHONPATH=/app \ + PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 # Run the application using the configured uvicorn server -CMD ["python", "app.py"] +CMD ["poetry", "run", "python", "app.py"] diff --git a/DockerApiServices/EventServiceApi/Dockerfile b/DockerApiServices/EventServiceApi/Dockerfile index 147a559..186477a 100644 --- a/DockerApiServices/EventServiceApi/Dockerfile +++ b/DockerApiServices/EventServiceApi/Dockerfile @@ -2,22 +2,35 @@ FROM python:3.9-slim WORKDIR /app -# Install system dependencies -RUN apt-get update && apt-get install -y \ - gcc \ - && rm -rf /var/lib/apt/lists/* +# 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 -# Install Python dependencies -COPY pyproject.toml . -RUN pip install poetry && \ - poetry config virtualenvs.create false && \ - poetry install --no-dev +# 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 . . +COPY DockerApiServices/AllApiNeeds /app/ +COPY ApiLibrary /app/ApiLibrary +COPY ApiValidations /app/ApiValidations +COPY AllConfigs /app/AllConfigs +COPY ErrorHandlers /app/ErrorHandlers +COPY Schemas /app/Schemas +COPY Services /app/Services -# Expose port -EXPOSE 8000 +# Set Python path to include app directory +ENV PYTHONPATH=/app \ + PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 -# Run the application -CMD ["uvicorn", "EventServiceApi.main:app", "--host", "0.0.0.0", "--port", "8000"] +# Run the application using the configured uvicorn server +CMD ["poetry", "run", "python", "app.py"] diff --git a/DockerApiServices/ValidationServiceApi/Dockerfile b/DockerApiServices/ValidationServiceApi/Dockerfile index e99b8ae..186477a 100644 --- a/DockerApiServices/ValidationServiceApi/Dockerfile +++ b/DockerApiServices/ValidationServiceApi/Dockerfile @@ -2,22 +2,35 @@ FROM python:3.9-slim WORKDIR /app -# Install system dependencies -RUN apt-get update && apt-get install -y \ - gcc \ - && rm -rf /var/lib/apt/lists/* +# 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 -# Install Python dependencies -COPY pyproject.toml . -RUN pip install poetry && \ - poetry config virtualenvs.create false && \ - poetry install --no-dev +# 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 . . +COPY DockerApiServices/AllApiNeeds /app/ +COPY ApiLibrary /app/ApiLibrary +COPY ApiValidations /app/ApiValidations +COPY AllConfigs /app/AllConfigs +COPY ErrorHandlers /app/ErrorHandlers +COPY Schemas /app/Schemas +COPY Services /app/Services -# Expose port -EXPOSE 8000 +# Set Python path to include app directory +ENV PYTHONPATH=/app \ + PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 -# Run the application -CMD ["uvicorn", "ValidationServiceApi.main:app", "--host", "0.0.0.0", "--port", "8000"] +# Run the application using the configured uvicorn server +CMD ["poetry", "run", "python", "app.py"] diff --git a/DockerApiServices/pyproject.toml b/DockerApiServices/pyproject.toml index 228fa42..398238d 100644 --- a/DockerApiServices/pyproject.toml +++ b/DockerApiServices/pyproject.toml @@ -32,6 +32,10 @@ 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" + # Utilities python-dateutil = "^2.8.2" typing-extensions = "^4.8.0"