From 474303407e316399981df47fb838daa4b69b11cb Mon Sep 17 00:00:00 2001 From: itqop Date: Sat, 18 Oct 2025 16:13:59 +0300 Subject: [PATCH] add docker --- .dockerignore | 63 ++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 25 ++++++++++++++++++ docker-compose.yml | 17 +++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..91e2c47 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,63 @@ +# Git +.git +.gitignore + +# Python +__pycache__ +*.pyc +*.pyo +*.pyd +.Python +env +pip-log.txt +pip-delete-this-directory.txt +.tox +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.log +.git +.mypy_cache +.pytest_cache +.hypothesis + +# Virtual environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# IDE +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Project specific +tests/ +*.md +README.md +DEPLOYMENT.md +API_EXAMPLES.md +db.ddl + +# Docker +Dockerfile +docker-compose.yml +.dockerignore diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..43e97ea --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM python:3.11-slim + +WORKDIR /app + +RUN apt-get update && apt-get install -y \ + build-essential \ + curl \ + && rm -rf /var/lib/apt/lists/* + +RUN pip install poetry + +COPY pyproject.toml poetry.lock ./ + +RUN poetry config virtualenvs.create false + +RUN poetry install --only=main --no-dev + +COPY src/ ./src/ + +RUN useradd --create-home --shell /bin/bash app && chown -R app:app /app +USER app + +EXPOSE 8080 + +CMD ["python", "-m", "hubgw"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..20ec09e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +services: + hubgw: + build: . + ports: + - "8087:8080" + environment: + - PYTHONPATH=/app/src + volumes: + # Монтируем логи если нужно + - ./logs:/app/logs + restart: unless-stopped + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/api/v1/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s