{"id":373559,"date":"2024-05-21T05:39:06","date_gmt":"2024-05-21T05:39:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=373559"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=373559","title":{"rendered":"<span>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u043d\u043e\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0432 Docker \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043c\u043e\u043d\u043e\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u0431\u0435\u0437 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0430\u043c\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 &#8230;<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0441\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u043f\u0430\u043f\u043a\u043e\u0439 <code>common<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u044d\u0442\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445\u00a0<\/p>\n<pre><code>. \u251c\u2500\u2500 apps \u2502\u00a0\u00a0 \u251c\u2500\u2500 app1 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 cfg \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.py \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 core \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.py \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 docker-compose.yml \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 manage.py \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 tests \u2502\u00a0\u00a0 \u2502\u00a0\u00a0     \u2514\u2500\u2500 __init__.py \u2502\u00a0\u00a0 \u251c\u2500\u2500 app2 \u2502\u00a0\u00a0 \u2514\u2500\u2500 app3 \u251c\u2500\u2500 common \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.py \u251c\u2500\u2500 requirements-dev.txt \u2514\u2500\u2500 requirements.txt <\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ul>\n<li>\n<p>\u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u0444\u0438\u0447 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 python<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0432 <code>common<\/code> \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438 \u043c\u0430\u043b\u0435\u0439\u0448\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0432 <code>requirements.txt<\/code> \u0438\u043b\u0438 <code>requirements-dev.txt<\/code> \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438 \u0442\u0430\u043a \u0436\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>tox<\/code>, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0444\u0430\u0439\u043b <code>.\/tox.ini<\/code> (\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f <code>tox==3.27.1<\/code>):<\/p>\n<pre><code class=\"yaml\">[main] current_python_env_dir = {toxworkdir}{\/}current_python_env_dir next_python_env_dir = {toxworkdir}{\/}next_python_env_dir report_temp_dir = test{\/}temp{\/} pytest_flags = --tb=no  [tox] skipsdist = True envlist =     {next_python, current_python}-{app1, app2, app3}  [testenv] recreate = False sitepackages = False passenv =     FORCE_COLOR commands =     next_python-app1: {env:TOXBUILD:py.test apps{\/}app1{\/}tests --junitxml={[main]report_temp_dir}test_{envname}.xml {[main]pytest_flags}}     current_python-app1: {env:TOXBUILD:py.test apps{\/}app1{\/}tests{\/}smoke --junitxml={[main]report_temp_dir}test_{envname}.xml {[main]pytest_flags}}      next_python-app2: {env:TOXBUILD:py.test apps{\/}app2{\/}tests --junitxml={[main]report_temp_dir}test_{envname}.xml {[main]pytest_flags}}     current_python-app2: {env:TOXBUILD:py.test apps{\/}app2{\/}tests{\/}smoke --junitxml={[main]report_temp_dir}test_{envname}.xml {[main]pytest_flags}}      next_python-app3: {env:TOXBUILD:py.test apps{\/}app3{\/}tests --junitxml={[main]report_temp_dir}test_{envname}.xml {[main]pytest_flags}}     current_python-app3: {env:TOXBUILD:py.test apps{\/}app3{\/}tests{\/}smoke --junitxml={[main]report_temp_dir}test_{envname}.xml {[main]pytest_flags}}  [testenv:next_python-{app1, app2, app3}] basepython = python3.7 envdir = {[main]next_python_env_dir} deps =     -Urrequirements-dev.txt  [testenv:current_python-{app1, app2, app3}] basepython = python3.8 envdir = {[main]next_python_env_dir} deps =     -Urrequirements-dev.txt<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u043e\u043a\u0435\u0440\u0444\u0430\u0439\u043b \u043e\u0431\u0440\u0430\u0437\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 <code>.\/test\/test_tox.Dockerfile<\/code>:<\/p>\n<pre><code class=\"powershell\">FROM python3.7  WORKDIR \/tox_workdir COPY requirements*.txt tox.ini \/tox_workdir\/  #================================================================================== # \u0421\u0442\u0430\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 #================================================================================== RUN apt-get update &amp;&amp; apt-get -y --no-install-recommends install \\     cabextract \\     curl \\     ......     &amp;&amp; apt-get clean  #================================================================================== # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f webui \u0438 \u0434\u0430\u043b\u0435\u0435 \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0441\u0435 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e #================================================================================== RUN addgroup --gid 1000 --system web &amp;&amp; adduser --system --gid 1000 --uid 1000 web RUN chown -R web \/tox_workdir USER web  #================================================================================== # \u0421\u0442\u0430\u0432\u0438\u043c pyenv, \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 python #  \u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0442\u0438 #================================================================================== RUN curl https:\/\/pyenv.run | bash \\     &amp;&amp; echo 'export PYENV_ROOT=\"\/home\/web\/.pyenv\"' >> ~\/.bashrc \\     &amp;&amp; echo 'export PATH=\"\/home\/web\/.local\/bin:$PATH\"' >> ~\/.bashrc \\     &amp;&amp; echo 'export PATH=\"$PYENV_ROOT\/shims:$PATH\"' >> ~\/.bashrc \\ &amp;&amp; echo 'export PATH=\"$PYENV_ROOT\/bin:$PATH\"' >> ~\/.bashrc  RUN . ~\/.bashrc &amp;&amp; pyenv install 3.8 RUN . ~\/.bashrc &amp;&amp; pyenv global 3.8 RUN . ~\/.bashrc &amp;&amp; pip3.8 install --upgrade cython #================================================================================== # \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 tox \u0438 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0439 #==================================================================================  RUN pip3 install tox==3.27.1 &amp;&amp; pip3 install --upgrade cython RUN . ~\/.bashrc &amp;&amp; bash -c \"export TOXBUILD=true &amp;&amp; tox\" <\/code><\/pre>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430 <code>.\/test\/build.sh<\/code>:<\/p>\n<pre><code class=\"bash\">#!\/bin\/bash docker build -f test_tox.Dockerfile -t test_tox:latest .<\/code><\/pre>\n<p>\u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430 \u0443 \u043d\u0430\u0441 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0431\u0443\u0434\u0443\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b 2 \u0432\u0435\u0440\u0441\u0438\u0438 python \u0438 2 \u043f\u0430\u043f\u043a\u0438 \u0441 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\u043c\u0438 (\u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 python) \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432\u0441\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u0438\u0437 <code>requirements-dev.txt<\/code> \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0443\u0442<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>.\/test\/docker-compose.yaml<\/code> :<\/p>\n<pre><code class=\"yaml\">version: \"2\"  services:   db:     image: postgres     environment:       - POSTGRES_USER=root       - POSTGRES_HOST_AUTH_METHOD=trust     volumes:       # \u0438\u043d\u0438\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c       # \u0440\u044f\u0434\u043e\u043c, \u0432 .\/test\/create_databases.sql       - .\/create_databases.sql:\/docker-entrypoint-initdb.d\/init.sql   cache:     image: memcached:alpine   test_tox:     image: test_tox     volumes:       - ..\/:\/test       # \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0430\u043c\u0438,       # \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435, \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c        # \u0440\u044f\u0434\u043e\u043c \u0432 .\/test\/container_cfg       - .\/container_cfg:\/test\/apps\/app1\/cfg       - .\/container_cfg:\/test\/apps\/app2\/cfg       - .\/container_cfg:\/test\/apps\/app3\/cfg volumes:   media: <\/code><\/pre>\n<p>\u0444\u0430\u0439\u043b <code>.\/test\/create_databases.sql<\/code> :<\/p>\n<pre><code class=\"sql\">CREATE DATABASE app1_test; CREATE DATABASE app2_test; CREATE DATABASE app3_test;<\/code><\/pre>\n<p>\u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 <code>docker-compose<\/code>, \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>.\/test\/Makefile<\/code> :<\/p>\n<pre><code class=\"powershell\"># You can set these variables from the command line. TOX_WORK_DIR=\/tox_workdir\/.tox APP1_ENV=-e current_python-app1,next_python-app1 APP2_ENV=-e current_python-app2,next_python-app2 APP3_ENV=-e current_python-app3,next_python-app3 ALL_ENVS=$(APP1_ENV) $(APP2_ENV) $(APP3_ENV)  define run-test docker-compose rm --all docker-compose up -d db docker-compose up -d cache docker-compose run --rm test_tox \/bin\/bash -c \". ~\/.bashrc &amp;&amp; cd \/test\/ &amp;&amp; tox $1 --workdir $(TOX_WORK_DIR) -q --result-json .tox-result.json\" || : docker-compose down docker-compose rm --all endef  build: .\/build_local.sh  app1_test: $(call run-test, $(APP1_ENV))  app2_test: $(call run-test, $(APP2_ENV))  app3_test: $(call run-test, $(APP3_ENV))  tests: $(call run-test, $(ALL_ENVS))  all: build tests  .DEFAULT_GOAL := all <\/code><\/pre>\n<p>\u0447\u0435\u0440\u0435\u0437 <code>Makefile<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u043d\u0430\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"bash\">cd test make build make app1_test make tests<\/code><\/pre>\n<p>\u0414\u0435\u0440\u0435\u0432\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>. \u251c\u2500\u2500 apps \u2502\u00a0\u00a0 \u251c\u2500\u2500 app1 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 cfg \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.py \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 core \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.py \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 docker-compose.yml \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 manage.py \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 tests \u2502\u00a0\u00a0 \u2502\u00a0\u00a0     \u2514\u2500\u2500 __init__.py \u2502\u00a0\u00a0 \u251c\u2500\u2500 app2 \u2502\u00a0\u00a0 \u2514\u2500\u2500 app3 \u251c\u2500\u2500 common \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.py \u251c\u2500\u2500 requirements-dev.txt \u251c\u2500\u2500 requirements.txt \u2514\u2500\u2500 test     \u251c\u2500\u2500 Makefile     \u251c\u2500\u2500 build.sh     \u251c\u2500\u2500 container_cfg     \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.py     \u251c\u2500\u2500 create_databases.sql     \u251c\u2500\u2500 docker-compose.yaml     \u2514\u2500\u2500 test_tox.Dockerfile<\/code><\/pre>\n<p>\u041f\u043b\u044e\u0441\u044b \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>\u0412\u0441\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 <code>common<\/code>, \u043d\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u0432 \u043f\u0430\u043f\u043a\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\u043c\u0438 (\u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432)<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 <code>.\/test\/<\/code> \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0432 CI\/CD \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u0438\u043d\u0443\u0441\u044b:<\/p>\n<ul>\n<li>\n<p>\u041a\u043e\u0441\u0442\u044b\u043b\u044c\u043d\u043e\u0435 \u0432\u043a\u043e\u0440\u044f\u0447\u0438\u0432\u0430\u043d\u0438\u0435 2 \u0432\u0435\u0440\u0441\u0438\u0438 python \u0432 \u043e\u0434\u0438\u043d \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u043b\u0433\u0430\u044f \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438  python<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0444\u043b\u0430\u0433\u0430\u043c\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 &#8212;pdb)<\/p>\n<\/li>\n<\/ul>\n<p>P.S. \u041f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u0435\u0437\u043b\u0438\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u043d\u0435\u0441\u0442\u0438 \u0441\u0443\u0442\u044c.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/807549\/\"> https:\/\/habr.com\/ru\/articles\/807549\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043c\u043e\u043d\u043e\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u0431\u0435\u0437 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0430\u043c\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 &#8230;<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0441\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u043f\u0430\u043f\u043a\u043e\u0439 <code>common<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u044d\u0442\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445\u00a0<\/p>\n<pre><code>. \u251c\u2500\u2500 apps \u2502\u00a0\u00a0 \u251c\u2500\u2500 app1 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 cfg \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.py \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 core \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.py \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 docker-compose.yml \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 manage.py \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 tests \u2502\u00a0\u00a0 \u2502\u00a0\u00a0     \u2514\u2500\u2500 __init__.py \u2502\u00a0\u00a0 \u251c\u2500\u2500 app2 \u2502\u00a0\u00a0 \u2514\u2500\u2500 app3 \u251c\u2500\u2500 common \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.py \u251c\u2500\u2500 requirements-dev.txt \u2514\u2500\u2500 requirements.txt <\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ul>\n<li>\n<p>\u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u0444\u0438\u0447 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 python<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0432 <code>common<\/code> \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438 \u043c\u0430\u043b\u0435\u0439\u0448\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0432 <code>requirements.txt<\/code> \u0438\u043b\u0438 <code>requirements-dev.txt<\/code> \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438 \u0442\u0430\u043a \u0436\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>tox<\/code>, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0444\u0430\u0439\u043b <code>.\/tox.ini<\/code> (\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f <code>tox==3.27.1<\/code>):<\/p>\n<pre><code class=\"yaml\">[main] current_python_env_dir = {toxworkdir}{\/}current_python_env_dir next_python_env_dir = {toxworkdir}{\/}next_python_env_dir report_temp_dir = test{\/}temp{\/} pytest_flags = --tb=no  [tox] skipsdist = True envlist =     {next_python, current_python}-{app1, app2, app3}  [testenv] recreate = False sitepackages = False passenv =     FORCE_COLOR commands =     next_python-app1: {env:TOXBUILD:py.test apps{\/}app1{\/}tests --junitxml={[main]report_temp_dir}test_{envname}.xml {[main]pytest_flags}}     current_python-app1: {env:TOXBUILD:py.test apps{\/}app1{\/}tests{\/}smoke --junitxml={[main]report_temp_dir}test_{envname}.xml {[main]pytest_flags}}      next_python-app2: {env:TOXBUILD:py.test apps{\/}app2{\/}tests --junitxml={[main]report_temp_dir}test_{envname}.xml {[main]pytest_flags}}     current_python-app2: {env:TOXBUILD:py.test apps{\/}app2{\/}tests{\/}smoke --junitxml={[main]report_temp_dir}test_{envname}.xml {[main]pytest_flags}}      next_python-app3: {env:TOXBUILD:py.test apps{\/}app3{\/}tests --junitxml={[main]report_temp_dir}test_{envname}.xml {[main]pytest_flags}}     current_python-app3: {env:TOXBUILD:py.test apps{\/}app3{\/}tests{\/}smoke --junitxml={[main]report_temp_dir}test_{envname}.xml {[main]pytest_flags}}  [testenv:next_python-{app1, app2, app3}] basepython = python3.7 envdir = {[main]next_python_env_dir} deps =     -Urrequirements-dev.txt  [testenv:current_python-{app1, app2, app3}] basepython = python3.8 envdir = {[main]next_python_env_dir} deps =     -Urrequirements-dev.txt<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u043e\u043a\u0435\u0440\u0444\u0430\u0439\u043b \u043e\u0431\u0440\u0430\u0437\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 <code>.\/test\/test_tox.Dockerfile<\/code>:<\/p>\n<pre><code class=\"powershell\">FROM python3.7  WORKDIR \/tox_workdir COPY requirements*.txt tox.ini \/tox_workdir\/  #================================================================================== # \u0421\u0442\u0430\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 #================================================================================== RUN apt-get update &amp;&amp; apt-get -y --no-install-recommends install \\     cabextract \\     curl \\     ......     &amp;&amp; apt-get clean  #================================================================================== # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f webui \u0438 \u0434\u0430\u043b\u0435\u0435 \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0441\u0435 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e #================================================================================== RUN addgroup --gid 1000 --system web &amp;&amp; adduser --system --gid 1000 --uid 1000 web RUN chown -R web \/tox_workdir USER web  #================================================================================== # \u0421\u0442\u0430\u0432\u0438\u043c pyenv, \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 python #  \u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0442\u0438 #================================================================================== RUN curl https:\/\/pyenv.run | bash \\     &amp;&amp; echo 'export PYENV_ROOT=\"\/home\/web\/.pyenv\"' >> ~\/.bashrc \\     &amp;&amp; echo 'export PATH=\"\/home\/web\/.local\/bin:$PATH\"' >> ~\/.bashrc \\     &amp;&amp; echo 'export PATH=\"$PYENV_ROOT\/shims:$PATH\"' >> ~\/.bashrc \\ &amp;&amp; echo 'export PATH=\"$PYENV_ROOT\/bin:$PATH\"' >> ~\/.bashrc  RUN . ~\/.bashrc &amp;&amp; pyenv install 3.8 RUN . ~\/.bashrc &amp;&amp; pyenv global 3.8 RUN . ~\/.bashrc &amp;&amp; pip3.8 install --upgrade cython #================================================================================== # \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 tox \u0438 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0439 #==================================================================================  RUN pip3 install tox==3.27.1 &amp;&amp; pip3 install --upgrade cython RUN . ~\/.bashrc &amp;&amp; bash -c \"export TOXBUILD=true &amp;&amp; tox\" <\/code><\/pre>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430 <code>.\/test\/build.sh<\/code>:<\/p>\n<pre><code class=\"bash\">#!\/bin\/bash docker build -f test_tox.Dockerfile -t test_tox:latest .<\/code><\/pre>\n<p>\u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430 \u0443 \u043d\u0430\u0441 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0431\u0443\u0434\u0443\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b 2 \u0432\u0435\u0440\u0441\u0438\u0438 python \u0438 2 \u043f\u0430\u043f\u043a\u0438 \u0441 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\u043c\u0438 (\u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 python) \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432\u0441\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u0438\u0437 <code>requirements-dev.txt<\/code> \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0443\u0442<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>.\/test\/docker-compose.yaml<\/code> :<\/p>\n<pre><code class=\"yaml\">version: \"2\"  services:   db:     image: postgres     environment:       - POSTGRES_USER=root       - POSTGRES_HOST_AUTH_METHOD=trust     volumes:       # \u0438\u043d\u0438\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c       # \u0440\u044f\u0434\u043e\u043c, \u0432 .\/test\/create_databases.sql       - .\/create_databases.sql:\/docker-entrypoint-initdb.d\/init.sql   cache:     image: memcached:alpine   test_tox:     image: test_tox     volumes:       - ..\/:\/test       # \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0430\u043c\u0438,       # \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435, \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c        # \u0440\u044f\u0434\u043e\u043c \u0432 .\/test\/container_cfg       - .\/container_cfg:\/test\/apps\/app1\/cfg       - .\/container_cfg:\/test\/apps\/app2\/cfg       - .\/container_cfg:\/test\/apps\/app3\/cfg volumes:   media: <\/code><\/pre>\n<p>\u0444\u0430\u0439\u043b <code>.\/test\/create_databases.sql<\/code> :<\/p>\n<pre><code class=\"sql\">CREATE DATABASE app1_test; CREATE DATABASE app2_test; CREATE DATABASE app3_test;<\/code><\/pre>\n<p>\u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 <code>docker-compose<\/code>, \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>.\/test\/Makefile<\/code> :<\/p>\n<pre><code class=\"powershell\"># You can set these variables from the command line. TOX_WORK_DIR=\/tox_workdir\/.tox APP1_ENV=-e current_python-app1,next_python-app1 APP2_ENV=-e current_python-app2,next_python-app2 APP3_ENV=-e current_python-app3,next_python-app3 ALL_ENVS=$(APP1_ENV) $(APP2_ENV) $(APP3_ENV)  define run-test docker-compose rm --all docker-compose up -d db docker-compose up -d cache docker-compose run --rm test_tox \/bin\/bash -c \". ~\/.bashrc &amp;&amp; cd \/test\/ &amp;&amp; tox $1 --workdir $(TOX_WORK_DIR) -q --result-json .tox-result.json\" || : docker-compose down docker-compose rm --all endef  build: .\/build_local.sh  app1_test: $(call run-test, $(APP1_ENV))  app2_test: $(call run-test, $(APP2_ENV))  app3_test: $(call run-test, $(APP3_ENV))  tests: $(call run-test, $(ALL_ENVS))  all: build tests  .DEFAULT_GOAL := all <\/code><\/pre>\n<p>\u0447\u0435\u0440\u0435\u0437 <code>Makefile<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u043d\u0430\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"bash\">cd test make build make app1_test make tests<\/code><\/pre>\n<p>\u0414\u0435\u0440\u0435\u0432\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>. \u251c\u2500\u2500 apps \u2502\u00a0\u00a0 \u251c\u2500\u2500 app1 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 cfg \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.py \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 core \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.py \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 docker-compose.yml \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 manage.py \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 tests \u2502\u00a0\u00a0 \u2502\u00a0\u00a0     \u2514\u2500\u2500 __init__.py \u2502\u00a0\u00a0 \u251c\u2500\u2500 app2 \u2502\u00a0\u00a0 \u2514\u2500\u2500 app3 \u251c\u2500\u2500 common \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.py \u251c\u2500\u2500 requirements-dev.txt \u251c\u2500\u2500 requirements.txt \u2514\u2500\u2500 test     \u251c\u2500\u2500 Makefile     \u251c\u2500\u2500 build.sh     \u251c\u2500\u2500 container_cfg     \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.py     \u251c\u2500\u2500 create_databases.sql     \u251c\u2500\u2500 docker-compose.yaml     \u2514\u2500\u2500 test_tox.Dockerfile<\/code><\/pre>\n<p>\u041f\u043b\u044e\u0441\u044b \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>\u0412\u0441\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 <code>common<\/code>, \u043d\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u0432 \u043f\u0430\u043f\u043a\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\u043c\u0438 (\u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432)<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 <code>.\/test\/<\/code> \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0432 CI\/CD \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u0438\u043d\u0443\u0441\u044b:<\/p>\n<ul>\n<li>\n<p>\u041a\u043e\u0441\u0442\u044b\u043b\u044c\u043d\u043e\u0435 \u0432\u043a\u043e\u0440\u044f\u0447\u0438\u0432\u0430\u043d\u0438\u0435 2 \u0432\u0435\u0440\u0441\u0438\u0438 python \u0432 \u043e\u0434\u0438\u043d \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u043b\u0433\u0430\u044f \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438  python<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0444\u043b\u0430\u0433\u0430\u043c\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 &#8212;pdb)<\/p>\n<\/li>\n<\/ul>\n<p>P.S. \u041f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u0435\u0437\u043b\u0438\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u043d\u0435\u0441\u0442\u0438 \u0441\u0443\u0442\u044c.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/807549\/\"> https:\/\/habr.com\/ru\/articles\/807549\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-373559","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/373559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=373559"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/373559\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=373559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=373559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=373559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}