Merge pull request '[TC-837] Update base template configs' (#5) from feature/tc837-update-base-template into master

Reviewed-on: https://git.avroid.tech/Templates/template-backend-service/pulls/5
Reviewed-by: Victor Stratov <victor.stratov@avroid.team>
Reviewed-by: Azamat Valitov <azamat.valitov@avroid.team>
Reviewed-by: Nadezhda Lavrentieva <nadezhda.lavrentieva@avroid.team>
This commit is contained in:
Elizaveta Nikolaeva
2025-01-31 13:29:09 +03:00
13 changed files with 630 additions and 424 deletions

8
.dockerignore Normal file
View File

@@ -0,0 +1,8 @@
.git
local.env
.helm
docker-compose.yml
Makefile
Dockerfile
local.env.example
README.md

View File

@@ -1,12 +1,36 @@
podAnnotations:
vault.security.banzaicloud.io/vault-addr: https://vault.avroid.tech
vault.security.banzaicloud.io/vault-path: avroid-office
vault.security.banzaicloud.io/vault-role: tavro-cloud-dev
vault.security.banzaicloud.io/vault-skip-verify: "true"
replicaCount: 1
extraEnv:
POSTGRES_DSN:
value: "postgresql://test:test@postgresql:5432/messenger"
PORT:
- name: POSTGRES_DSN
value: "vault:path/to/service/secrets/svc-template-backend-service#POSTGRES_DSN"
- name: PORT
value: "8000"
ENVIRONMENT:
- name: ENVIRONMENT
value: "dev"
service:
port: 8000
imagePullSecrets:
- name: harbor-registry-secret
ingress:
enabled: true
hosts:
- host: s-template-backend-service-dev.avroid.tech
paths:
- path: /
pathType: ImplementationSpecific
tls:
- secretName: avroid-tech-tls
hosts:
- s-template-backend-service-dev.avroid.tech
paths:
- path: /
pathType: ImplementationSpecific

View File

@@ -1,11 +1,17 @@
podAnnotations:
vault.security.banzaicloud.io/vault-addr: https://vault.avroid.tech
vault.security.banzaicloud.io/vault-path:
vault.security.banzaicloud.io/vault-role: tavro-cloud
vault.security.banzaicloud.io/vault-skip-verify: "true"
replicaCount: 1
extraEnv:
POSTGRES_DSN:
value: "postgresql://test:test@postgresql:5432/messenger"
PORT:
- name: POSTGRES_DSN
value: "vault:path/to/service/secrets/svc-template-backend-service#POSTGRES_DSN"
- name: PORT
value: "8000"
ENVIRONMENT:
- name: ENVIRONMENT
value: "prod"
service:

View File

@@ -1,11 +1,17 @@
podAnnotations:
vault.security.banzaicloud.io/vault-addr: https://vault.avroid.tech
vault.security.banzaicloud.io/vault-path: avroid-office
vault.security.banzaicloud.io/vault-role: tavro-cloud-stage
vault.security.banzaicloud.io/vault-skip-verify: "true"
replicaCount: 1
extraEnv:
POSTGRES_DSN:
value: "postgresql://test:test@postgresql:5432/messenger"
PORT:
- name: POSTGRES_DSN
value: "vault:path/to/service/secrets/svc-template-backend-service#POSTGRES_DSN"
- name: PORT
value: "8000"
ENVIRONMENT:
- name: ENVIRONMENT
value: "stage"
service:

View File

@@ -1,12 +1,36 @@
podAnnotations:
vault.security.banzaicloud.io/vault-addr: https://vault.avroid.tech
vault.security.banzaicloud.io/vault-path: avroid-office
vault.security.banzaicloud.io/vault-role: tavro-cloud-test
vault.security.banzaicloud.io/vault-skip-verify: "true"
replicaCount: 1
extraEnv:
POSTGRES_DSN:
value: "postgresql://test:test@postgresql:5432/messenger"
PORT:
- name: POSTGRES_DSN
value: "vault:path/to/service/secrets/svc-template-backend-service#POSTGRES_DSN"
- name: PORT
value: "8000"
ENVIRONMENT:
- name: ENVIRONMENT
value: "test"
service:
port: 8000
imagePullSecrets:
- name: harbor-registry-secret
ingress:
enabled: true
hosts:
- host: s-template-backend-service-test.avroid.tech
paths:
- path: /
pathType: ImplementationSpecific
tls:
- secretName: avroid-tech-tls
hosts:
- s-template-backend-service-test.avroid.tech
paths:
- path: /
pathType: ImplementationSpecific

View File

@@ -3,18 +3,23 @@ FROM harbor.avroid.tech/docker-hub-proxy/python:3.12
ARG PIP_INDEX_URL
ENV PIP_INDEX_URL=${PIP_INDEX_URL}
ENV UID=999
ENV GID=999
ENV USER_NAME=app
ENV USER_GROUP=${USER_NAME}
ENV USER_HOME=/${USER_NAME}
WORKDIR /app
RUN groupadd -g ${GID} ${USER_GROUP} \
&& useradd -r -g ${GID} -u ${UID} -d ${USER_HOME} ${USER_NAME} \
&& pip --no-cache-dir install poetry==2.0.1
USER ${USER_NAME}
WORKDIR ${USER_HOME}
COPY pyproject.toml poetry.lock ./
RUN pip --no-cache-dir install poetry \
&& poetry export \
--with=dev,tests,format \
--without-hashes \
-f requirements.txt \
-o requirements.txt \
&& pip install --no-cache-dir -r requirements.txt
RUN poetry install --with=dev --no-root --no-cache
COPY . .

View File

@@ -1,5 +1,5 @@
networks:
cloud-messenger:
tavro-cloud:
driver: bridge
volumes:
@@ -7,9 +7,13 @@ volumes:
services:
template-backend-service:
build: .
build:
context: .
args:
PIP_INDEX_URL: "https://nexus.avroid.tech/repository/all-pypi-proxy/simple"
env_file: "local.env"
container_name: template-backend-service
restart: always
volumes:
- ./:/app
environment:
@@ -18,14 +22,14 @@ services:
LOGGING: '{"json_enabled": true, "level": "INFO"}'
POSTGRES_DSN: postgresql://messenger:messenger@postgresql:5432/messenger
networks:
- cloud-messenger
- tavro-cloud
ports:
- "8000:8000"
depends_on:
- postgresql
postgresql:
image: postgres:14.0
image: postgres:17.0
container_name: template-backend-service-db
restart: always
volumes:
@@ -35,7 +39,7 @@ services:
POSTGRES_PASSWORD: messenger
POSTGRES_DB: messenger
networks:
- cloud-messenger
- tavro-cloud
ports:
- "5432:5432"
healthcheck:

View File

@@ -9,4 +9,4 @@ alembic upgrade head
# alembic --name specific_scheme upgrade head
# Start application
python -m src.api_app
poetry run python -m src.api_app

View File

@@ -1,2 +1,3 @@
POSTGRES_DSN=postgresql://postgres_user:postgres_password@postgres_host:5432/db
PORT=8000
HOST=0.0.0.0

897
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "template-backend-service"
version = "0.1.1"
version = "0.1.2"
description = ""
authors = ["Nadezhda Lavrenteva <nadezhda.lavrentieva@avroid.team>"]
readme = "README.md"
@@ -8,7 +8,7 @@ readme = "README.md"
[tool.poetry.dependencies]
python = ">=3.12 <3.13"
coverage = "^7.6.1"
avroid-service-lib = "^0.0.3"
avroid-service-lib = "^0.0.6"
[[tool.poetry.source]]
name = "nexus"
@@ -40,9 +40,9 @@ ruff = "^0.6.8"
pre-commit = "^3.8.0"
[tool.poetry.group.tests.dependencies]
pytest-mock = "^3.14.0"
pytest-asyncio = "^0.24.0"
pytest-cov = "^5.0.0"
pytest-mock = "^3.14.0"
[tool.pytest.ini_options]
asyncio_mode = "auto"
@@ -64,7 +64,7 @@ warn_unused_ignores = true
warn_return_any = true
strict_equality = true
ignore_missing_imports = true
plugins = ['pydantic.mypy']
plugins = ["pydantic.mypy"]
[[tool.mypy.overrides]]
module = "tests.*,migrations.*"
@@ -73,11 +73,13 @@ ignore_errors = true
[tool.ruff]
line-length = 120
[tool.ruff.lint]
select = ["E", "F", "W", "C90", "I", "N", "UP", "YTT", "ASYNC", "S", "B", "C4", "DTZ", "T10", "ISC", "ICN",
[tool.ruff.lint]
select = [
"E", "F", "W", "C90", "I", "N", "UP", "YTT", "ASYNC", "S", "B", "C4", "DTZ", "T10", "ISC", "ICN",
"PIE", "T20", "PT", "Q", "RET", "SLF", "SIM", "ERA", "PLE", "TRY", "PYI", "PERF", "LOG", "RUF008",
"RUF009", "RUF012", "RUF013", "RUF015", "RUF019", "RUF100", "RUF200"]
"RUF009", "RUF012", "RUF013", "RUF015", "RUF019", "RUF100", "RUF200"
]
unfixable = [
"ERA", # do not autoremove commented out code
]

View File

@@ -6,7 +6,7 @@ from src.settings import WebAppSettings
class PGConnector:
def __init__(self, settings: WebAppSettings) -> None:
self.pg_engine = create_engine(settings.postgres_dsn)
self.pg_engine = create_engine(str(settings.postgres_dsn))
self.pg_session = sessionmaker(self.pg_engine, class_=Session)

View File

@@ -3,6 +3,7 @@ from avroid_service_lib import BaseAppSettings
class WebAppSettings(BaseAppSettings):
postgres_dsn: str
host: str = "0.0.0.0"
class Config:
env_file = "local.env"