From 03b528a2e78b3d20a6853948a7afe1fc44ff16f9 Mon Sep 17 00:00:00 2001 From: NDH60152 Date: Wed, 5 Nov 2025 11:58:49 +0530 Subject: [PATCH] Auto: add missing CI/CD prerequisites (sonar & Dockerfile) --- Dockerfile | 41 ++++++++++++++++++++++++++++++++++++++++ sonar-project.properties | 20 ++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 Dockerfile create mode 100644 sonar-project.properties diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..495301a8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,41 @@ +# Multi-stage Dockerfile for ECS Deployment +# Auto-generated by Repository Readiness Analyzer + +# Build stage +FROM python:3.11-slim AS builder + +WORKDIR /app + +# Install dependencies +COPY requirements.txt . +RUN pip install --no-cache-dir --user -r requirements.txt + +# Runtime stage +FROM python:3.11-slim + +WORKDIR /app + +# Copy installed dependencies from builder +COPY --from=builder /root/.local /root/.local + +# Copy application code +COPY . . + +# Create non-root user +RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app + +# Switch to non-root user +USER appuser + +# Make sure scripts in .local are usable +ENV PATH=/root/.local/bin:$PATH + +# Expose port (adjust as needed) +EXPOSE 8080 + +# Health check +HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \ + CMD python -c "import requests; requests.get('http://localhost:8080/health', timeout=2)" || exit 1 + +# Run application (adjust CMD to your entry point) +CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"] diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..9c93800e --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,20 @@ +# SonarQube Configuration for Node.js Projects +# Auto-generated by Repository Readiness Analyzer + +sonar.projectKey={{PROJECT_KEY}} +sonar.projectName={{PROJECT_NAME}} +sonar.projectVersion=1.0 + +# Source code directory +sonar.sources=src +sonar.sourceEncoding=UTF-8 + +# JavaScript/TypeScript settings +sonar.javascript.lcov.reportPaths=coverage/lcov.info + +# Exclude common directories +sonar.exclusions=**/node_modules/**,**/dist/**,**/build/**,**/coverage/**,**/.git/**,**/tests/**,**/*.spec.js,**/*.test.js + +# Test files +sonar.tests=tests,src/**/*.test.js,src/**/*.spec.js +sonar.test.inclusions=**/*.test.js,**/*.spec.js