Loading .env.example 0 → 100644 +7 −0 Original line number Diff line number Diff line APP_NAME="Service Resource Manager" APP_DESCRIPTION="Service Resource Manager is the brains of the ETSI SDG Open Operator Platform - OpenOP" APP_VERSION="1.5.0" POSTGRES_SETTINGS__URL = "postgresql+asyncpg://postgres:postgres@localhost:5432/srm" POSTGRES_SETTINGS__ECHO = true POSTGRES_SETTINGS__CREATE_SCHEMA_ON_STARTUP = true .gitignore 0 → 100644 +31 −0 Original line number Diff line number Diff line # Python-generated files __pycache__/ *.py[oc] build/ dist/ wheels/ *.egg-info # Virtual environments .venv # environment .env # code editors .vscode/ # AI software tools .claude CLAUDE.md .tox/ htmlcov/ .mypy_cache/ .pytest_cache/ .ruff_cache/ .idea/ .coverage .python_version coverage.xml .cache .gitlab-ci.yml 0 → 100644 +84 −0 Original line number Diff line number Diff line default: tags: - docker image: python:3.12-slim cache: paths: - .cache/uv before_script: - cd "$CI_PROJECT_DIR/${BACKEND_DIR:-.}" - pip install uv - export UV_SYSTEM_CERTS=1 - uv sync --locked --extra dev - . .venv/bin/activate stages: - type - architecture - lint - format - test - build - push variables: UV_CACHE_DIR: "$CI_PROJECT_DIR/.cache/uv" type: stage: type script: - mypy src/ tests/ architecture: stage: architecture script: - lint-imports lint: stage: lint script: - ruff check src/ tests/ format: stage: format script: - ruff format --check src/ tests/ test: stage: test variables: DOCKER_HOST: tcp://docker:2375 DOCKER_TLS_CERTDIR: "" services: - docker:dind script: - pytest tests/unit tests/integration tests/api --cov=src/srm --cov-branch --cov-report=term-missing || [ $? -eq 5 ] #bypass no tests found error. coverage: '/TOTAL.+ ([0-9]{1,3}(?:\.[0-9]+)?%)/' build: stage: build tags: - shell before_script: - docker info script: - export TEST_IMAGE_TAG="ci-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" - docker build --network=host -t "$CI_REGISTRY_IMAGE:$TEST_IMAGE_TAG" . rules: - if: '$CI_COMMIT_BRANCH' push: stage: push tags: - shell needs: - build before_script: - docker info script: - export TEST_IMAGE_TAG="ci-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin - docker push "$CI_REGISTRY_IMAGE:$TEST_IMAGE_TAG" - docker logout "$CI_REGISTRY" rules: - if: '$CI_COMMIT_BRANCH' .pre-commit-config.yaml 0 → 100644 +36 −0 Original line number Diff line number Diff line repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: - id: check-yaml - id: check-toml - id: end-of-file-fixer - id: trailing-whitespace args: [--markdown-linebreak-ext=md] - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. rev: v0.15.6 hooks: # Run the linter. - id: ruff-check # Run the formatter. - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.19.1 # Use the sha / tag you want to point at hooks: - id: mypy files: ^src/srm/|^tests/ additional_dependencies: - "asgi-lifespan>=2.1.0" - "docker>=7.0.0" - "fastapi[standard]>=0.135.1" - "httpx>=0.27.0" - "pydantic-settings>=2.13.1" - "pytest>=9.0.2" - "pytest-asyncio>=0.24" - "python-dotenv>=1.2.2" - "sqlalchemy>=2.0.48" - "structlog>=25.5.0" - "testcontainers[postgres]>=4.13.2" Dockerfile 0 → 100644 +33 −0 Original line number Diff line number Diff line # syntax=docker/dockerfile:1 FROM python:3.12-slim AS builder COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ WORKDIR /app ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ PIP_DEFAULT_TIMEOUT=120 COPY pyproject.toml ./ COPY uv.lock ./ RUN uv sync --locked FROM python:3.12-slim AS runtime WORKDIR /app COPY --from=builder /app/.venv /app/.venv COPY src/ ./src/ COPY .env ./ ENV PATH="/app/.venv/bin:$PATH" ENV PYTHONPATH="/app/src" ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 EXPOSE 8080 CMD ["uvicorn", "srm.main:create_app", "--host", "0.0.0.0", "--port", "8080"] Loading
.env.example 0 → 100644 +7 −0 Original line number Diff line number Diff line APP_NAME="Service Resource Manager" APP_DESCRIPTION="Service Resource Manager is the brains of the ETSI SDG Open Operator Platform - OpenOP" APP_VERSION="1.5.0" POSTGRES_SETTINGS__URL = "postgresql+asyncpg://postgres:postgres@localhost:5432/srm" POSTGRES_SETTINGS__ECHO = true POSTGRES_SETTINGS__CREATE_SCHEMA_ON_STARTUP = true
.gitignore 0 → 100644 +31 −0 Original line number Diff line number Diff line # Python-generated files __pycache__/ *.py[oc] build/ dist/ wheels/ *.egg-info # Virtual environments .venv # environment .env # code editors .vscode/ # AI software tools .claude CLAUDE.md .tox/ htmlcov/ .mypy_cache/ .pytest_cache/ .ruff_cache/ .idea/ .coverage .python_version coverage.xml .cache
.gitlab-ci.yml 0 → 100644 +84 −0 Original line number Diff line number Diff line default: tags: - docker image: python:3.12-slim cache: paths: - .cache/uv before_script: - cd "$CI_PROJECT_DIR/${BACKEND_DIR:-.}" - pip install uv - export UV_SYSTEM_CERTS=1 - uv sync --locked --extra dev - . .venv/bin/activate stages: - type - architecture - lint - format - test - build - push variables: UV_CACHE_DIR: "$CI_PROJECT_DIR/.cache/uv" type: stage: type script: - mypy src/ tests/ architecture: stage: architecture script: - lint-imports lint: stage: lint script: - ruff check src/ tests/ format: stage: format script: - ruff format --check src/ tests/ test: stage: test variables: DOCKER_HOST: tcp://docker:2375 DOCKER_TLS_CERTDIR: "" services: - docker:dind script: - pytest tests/unit tests/integration tests/api --cov=src/srm --cov-branch --cov-report=term-missing || [ $? -eq 5 ] #bypass no tests found error. coverage: '/TOTAL.+ ([0-9]{1,3}(?:\.[0-9]+)?%)/' build: stage: build tags: - shell before_script: - docker info script: - export TEST_IMAGE_TAG="ci-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" - docker build --network=host -t "$CI_REGISTRY_IMAGE:$TEST_IMAGE_TAG" . rules: - if: '$CI_COMMIT_BRANCH' push: stage: push tags: - shell needs: - build before_script: - docker info script: - export TEST_IMAGE_TAG="ci-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin - docker push "$CI_REGISTRY_IMAGE:$TEST_IMAGE_TAG" - docker logout "$CI_REGISTRY" rules: - if: '$CI_COMMIT_BRANCH'
.pre-commit-config.yaml 0 → 100644 +36 −0 Original line number Diff line number Diff line repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: - id: check-yaml - id: check-toml - id: end-of-file-fixer - id: trailing-whitespace args: [--markdown-linebreak-ext=md] - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. rev: v0.15.6 hooks: # Run the linter. - id: ruff-check # Run the formatter. - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.19.1 # Use the sha / tag you want to point at hooks: - id: mypy files: ^src/srm/|^tests/ additional_dependencies: - "asgi-lifespan>=2.1.0" - "docker>=7.0.0" - "fastapi[standard]>=0.135.1" - "httpx>=0.27.0" - "pydantic-settings>=2.13.1" - "pytest>=9.0.2" - "pytest-asyncio>=0.24" - "python-dotenv>=1.2.2" - "sqlalchemy>=2.0.48" - "structlog>=25.5.0" - "testcontainers[postgres]>=4.13.2"
Dockerfile 0 → 100644 +33 −0 Original line number Diff line number Diff line # syntax=docker/dockerfile:1 FROM python:3.12-slim AS builder COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ WORKDIR /app ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ PIP_DEFAULT_TIMEOUT=120 COPY pyproject.toml ./ COPY uv.lock ./ RUN uv sync --locked FROM python:3.12-slim AS runtime WORKDIR /app COPY --from=builder /app/.venv /app/.venv COPY src/ ./src/ COPY .env ./ ENV PATH="/app/.venv/bin:$PATH" ENV PYTHONPATH="/app/src" ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 EXPOSE 8080 CMD ["uvicorn", "srm.main:create_app", "--host", "0.0.0.0", "--port", "8080"]