This commit is contained in:
Norvicdev 2026-08-04 16:39:49 +03:00
parent 43985b8fe1
commit ae54f81717
5 changed files with 151 additions and 130 deletions

204
.gitignore vendored
View file

@ -1,11 +1,8 @@
# ---> Python # Bytecode
# Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/
*.py[cod] *.py[cod]
*$py.class *.pyc
*.pyo
# C extensions
*.so
# Distribution / packaging # Distribution / packaging
.Python .Python
@ -21,144 +18,93 @@ parts/
sdist/ sdist/
var/ var/
wheels/ wheels/
share/python-wheels/
*.egg-info/ *.egg-info/
.installed.cfg .installed.cfg
*.egg *.egg
MANIFEST
# PyInstaller # Virtual environments
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/ venv/
env/
ENV/ ENV/
env.bak/ env.bak/
venv.bak/ venv.bak/
.venv/
virtualenv/
# Spyder project settings # PyCharm / IDE
.spyderproject .idea/
.spyproject *.iml
.vscode/
*.swp
*.swo
.DS_Store
# Rope project settings # Testing
.ropeproject .pytest_cache/
.coverage
# mkdocs documentation htmlcov/
/site .tox/
# mypy
.mypy_cache/ .mypy_cache/
.dmypy.json .dmypy.json
dmypy.json dmypy.json
*.cover
*.log
# Pyre type checker # Documentation
.pyre/ docs/_build/
site/
# pytype static type analyzer # Database
.pytype/ *.db
*.sqlite
*.sqlite3
# Cython debug symbols # Environment variables
cython_debug/ .env
.venv
.env.local
.env.*.local
# PyCharm # Jupyter Notebooks
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can .ipynb_checkpoints/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Logs
logs/
*.log
# OS
Thumbs.db
.DS_Store
Desktop.ini
# MyPy
.mypy_cache/
.ruff_cache/
# Python version
.python-version
# pyenv
.python-version
# Poetry
poetry.lock # если используете poetry, обычно poetry.lock добавляют в git, но можно и игнорировать
# PDM
.pdm.toml
__pypackages__/
# Coverage
.coverage.*
coverage.xml
*.py,cover
# Profiling
*.prof
# Secrets
secrets.yaml
config.local.yaml
*.pem
*.key
*.crt

59
Dockerfile Normal file
View file

@ -0,0 +1,59 @@
# Stage 1: Builder
FROM python:3.12-slim AS builder
# Аргументы для сборки
ARG PIP_INDEX_URL=https://pypi.org/simple
ARG BUILD_ENV=production
WORKDIR /app
# Оптимизация слоев: сначала копируем только зависимости
COPY requirements.txt .
# Кэширование зависимостей
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --no-cache-dir \
--index-url ${PIP_INDEX_URL} \
-r requirements.txt
# Stage 2: Final
FROM python:3.12-slim
# Метки для трекинга
LABEL maintainer="Vic Sergeev" \
version="1.0.0" \
build-date="${BUILD_DATE}" \
git-commit="${GIT_COMMIT}"
# Создание пользователя
RUN groupadd -r appuser && useradd -r -g appuser appuser
# Установка системных пакетов
RUN apt-get update && apt-get install -y \
curl \
tini \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Копирование зависимостей
COPY --from=builder --chown=appuser:appuser \
/usr/local/lib/python3.12/site-packages \
/usr/local/lib/python3.12/site-packages
COPY --from=builder --chown=appuser:appuser \
/usr/local/bin \
/usr/local/bin
# Копирование приложения
COPY --chown=appuser:appuser . .
# Переключение на пользователя
USER appuser
# Healthcheck
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Использование tini для правильной обработки сигналов
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["python", "main.py"]

View file

@ -1,3 +1,6 @@
# DummyApp # DummyApp
Dummy app for dockerfile training Dummy app for dockerfile training
### Dockerfile
is created with AI, used as best practices example

12
main.py Normal file
View file

@ -0,0 +1,12 @@
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world(): # put application's code here
return 'Hello World!'
if __name__ == '__main__':
app.run()

1
requirements.txt Normal file
View file

@ -0,0 +1 @@
Flask==3.0.3