{"id":462789,"date":"2025-06-10T15:01:24","date_gmt":"2025-06-10T15:01:24","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=462789"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=462789","title":{"rendered":"<span>\u041a\u0430\u043a \u0441\u043e\u0431\u0440\u0430\u0442\u044c Docker-\u043e\u0431\u0440\u0430\u0437, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u0434\u0435 (\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u0441\u0435\u0431\u044f \u043d\u0430 \u043d\u043e\u0443\u0442\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>\u0415\u0441\u043b\u0438 \u0442\u044b \u043f\u0438\u0448\u0435\u0448\u044c <code>Dockerfile<\/code>, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0435 \u0432 \u0442\u043e\u043c, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438. \u0412\u043e\u043f\u0440\u043e\u0441 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c: <strong>\u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0434\u0435\u043b\u044e, \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0432 CI\/CD, \u043d\u0430 \u0447\u0443\u0436\u043e\u043c \u0436\u0435\u043b\u0435\u0437\u0435 \u2014 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u044d\u0442\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e<\/strong>. \u0418\u043b\u0438 \u0432\u0441\u0451 \u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u044b \u043d\u0435 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043b \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u043b\u043e\u0436\u0438\u043b\u0441\u044f \u043d\u0430 <code>latest<\/code>, \u0438 \u0437\u0430\u0431\u044b\u043b \u043f\u0440\u043e \u0442\u043e, \u0447\u0442\u043e <code>ENTRYPOINT<\/code> \u2014 \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u043a\u043e\u0434.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u2014 \u043a\u0430\u043a \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 Docker-\u043e\u0431\u0440\u0430\u0437, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 <strong>\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c<\/strong>, <strong>\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432<\/strong> \u0438 <strong>\u0433\u043e\u0442\u043e\u0432 \u043a \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0443<\/strong>.<\/p>\n<hr\/>\n<h4>1. \u041f\u0435\u0440\u0432\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430: \u0442\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0448\u044c \u0441 \u043f\u043b\u043e\u0445\u043e\u0439 \u0431\u0430\u0437\u044b<\/h4>\n<p>\u041c\u043d\u043e\u0433\u0438\u0435 \u0431\u0435\u0440\u0443\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437, \u043d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u044f\u0441\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>python:3.12<\/code>. \u042d\u0442\u043e &#171;\u0442\u043e\u043b\u0441\u0442\u044b\u0439&#187; \u043e\u0431\u0440\u0430\u0437 \u0441 \u043a\u0443\u0447\u0435\u0439 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0441\u0438\u0442\u044c 1+ \u0413\u0411. \u0422\u0430\u043c \u043a\u0443\u0447\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0447\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u0430\u0442\u0430\u043a \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0431\u0438\u043b\u0434\u044b \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e\u0439 <code>Dockerfile<\/code>:<\/p>\n<pre><code class=\"yaml\">FROM python:3.12 WORKDIR \/app COPY . . RUN pip install -r requirements.txt CMD [\"python\", \"main.py\"]<\/code><\/pre>\n<p>\u0427\u0442\u043e \u0442\u0443\u0442 \u043d\u0435 \u0442\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0437 <strong>\u0431\u043e\u043b\u044c\u0448\u043e\u0439<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0435 \u0441\u043b\u043e\u0438 \u043a\u044d\u0448\u0430 \u0441\u0431\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043b\u044e\u0431\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0422\u044b \u043a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u0448\u044c \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u043d\u0443\u0442\u0440\u044c, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043c\u0443\u0441\u043e\u0440.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0430\u043a \u043b\u0443\u0447\u0448\u0435:<\/p>\n<ul>\n<li>\n<p>\u0411\u0440\u0430\u0442\u044c <code>python:3.12-slim<\/code> \u0438\u043b\u0438 <code>python:3.12-alpine<\/code>, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0448\u044c, \u043a\u0430\u043a \u0441 \u043d\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0442\u044b \u0435\u0433\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0448\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0443\u043f\u0435\u043d\u0447\u0430\u0442\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0438\u043b\u0434, \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0432 &#171;\u0447\u0438\u0441\u0442\u0443\u044e&#187; \u0444\u0430\u0437\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0447\u0451\u0442\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u043b\u043e\u0451\u0432: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u0442\u043e\u043c \u043a\u043e\u0434.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>2. \u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 latest<\/h4>\n<p><code>latest<\/code> \u2014 \u044d\u0442\u043e \u043b\u043e\u0432\u0443\u0448\u043a\u0430. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043e\u0431\u0440\u0430\u0437 \u043e\u0434\u0438\u043d, \u0437\u0430\u0432\u0442\u0440\u0430 \u043e\u043d \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0441\u044f, \u0438 \u0432\u0441\u0451 \u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f. \u041f\u0440\u0438\u0447\u0451\u043c \u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u2014 \u0443 \u0442\u0435\u0431\u044f \u0432 \u043f\u0440\u043e\u0434\u0435 \u0438\u043b\u0438 \u0432 CI.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>FROM node:latest<\/code><\/pre>\n<p>\u0412 \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a \u044d\u0442\u043e Node 18. \u0412 \u0441\u0440\u0435\u0434\u0443 \u2014 \u0443\u0436\u0435 20. \u0418 \u0442\u0432\u043e\u0439 build \u043f\u0430\u0434\u0430\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0430\u043a\u0435\u0442 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c.<\/p>\n<p>\u041b\u0443\u0447\u0448\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e:<\/p>\n<pre><code>FROM node:18.16.1<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u0434\u0430\u0436\u0435 \u0441 sha256:<\/p>\n<pre><code>FROM node@sha256:&lt;digest&gt;<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0430\u0440\u0430\u043d\u043e\u0439\u044f. \u042d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435. \u0411\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u2014 \u043c\u0435\u043d\u044c\u0448\u0435 \u0441\u044e\u0440\u043f\u0440\u0438\u0437\u043e\u0432.<\/p>\n<hr\/>\n<h4>3. \u041f\u0440\u0438\u043c\u0435\u0440 \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e Dockerfile \u0434\u043b\u044f Python\u2011\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h4>\n<pre><code>FROM python:3.12.1-slim as builder WORKDIR \/install RUN apt-get update &amp;&amp; apt-get install -y build-essential COPY requirements.txt . RUN pip install --upgrade pip &amp;&amp; \\     pip wheel --no-deps --wheel-dir \/wheels -r requirements.txt  FROM python:3.12.1-slim ENV PYTHONDONTWRITEBYTECODE=1 \\     PYTHONUNBUFFERED=1 WORKDIR \/app COPY --from=builder \/wheels \/wheels COPY requirements.txt . RUN pip install --no-deps --no-index --find-links=\/wheels -r requirements.txt COPY . . CMD [\"uvicorn\", \"app.main:app\", \"--host\", \"0.0.0.0\", \"--port\", \"8000\"]<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 Dockerfile \u0434\u0435\u043b\u0430\u0435\u0442 \u0434\u0432\u0435 \u0432\u0435\u0449\u0438: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u0442\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0447\u0438\u0441\u0442\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c. \u0422\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u044c\u0448\u0435 \u043c\u0443\u0441\u043e\u0440\u0430 \u0438 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0441\u0431\u043e\u0440\u043a\u0430.<\/p>\n<p><strong>\u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u2014 \u0441\u0431\u043e\u0440\u043a\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439:<\/strong><\/p>\n<ol>\n<li>\n<p>\u0411\u0435\u0440\u0451\u043c \u043b\u0451\u0433\u043a\u0438\u0439 \u043e\u0431\u0440\u0430\u0437 Python 3.12.1<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0430\u0432\u0438\u043c build-essential \u2014 \u043e\u043d \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b requirements.txt<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 wheel-\u0444\u0430\u0439\u043b\u044b (\u044d\u0442\u043e \u043a\u0430\u043a zip-\u0430\u0440\u0445\u0438\u0432\u044b \u0434\u043b\u044f Python-\u043f\u0430\u043a\u0435\u0442\u043e\u0432)<\/p>\n<\/li>\n<\/ol>\n<p>\u0424\u0438\u0448\u043a\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e build-essential \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u044d\u0442\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0438 \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437.<\/p>\n<p><strong>\u0412\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u2014 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437:<\/strong><\/p>\n<ol>\n<li>\n<p>\u0421\u043d\u043e\u0432\u0430 \u0431\u0435\u0440\u0451\u043c \u0447\u0438\u0441\u0442\u044b\u0439 Python 3.12.1 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0435\u0433\u043e<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0434\u0432\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<ul>\n<li>\n<p>PYTHONDONTWRITEBYTECODE \u2014 \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438\u0441\u044c .pyc-\u0444\u0430\u0439\u043b\u044b<\/p>\n<\/li>\n<li>\n<p>PYTHONUNBUFFERED \u2014 \u0447\u0442\u043e\u0431\u044b \u043b\u043e\u0433\u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0441\u0440\u0430\u0437\u0443<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c wheel-\u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0430\u0432\u0438\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 (\u0443\u0436\u0435 \u0431\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438)<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0441\u0430\u043c\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c uvicorn \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 8000<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u043b\u0443\u0447\u0448\u0435:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0435\u0441\u0438\u0442<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043a\u0435\u0442\u044b \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435<\/p>\n<\/li>\n<li>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430 \u0438\u0434\u0451\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0437\u0430 \u0441\u0447\u0451\u0442 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f wheel-\u0444\u0430\u0439\u043b\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0442 \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0442\u0438\u043f\u0430 build-essential \u0432 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u0431\u0440\u0430\u0437\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432 \u043e\u0431\u0440\u0430\u0437 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, curl \u0434\u043b\u044f healthcheck), \u0434\u0435\u043b\u0430\u0439 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c COPY. \u041d\u043e \u043f\u043e\u043c\u043d\u0438 \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 RUN \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u043e\u0439 \u043a \u043e\u0431\u0440\u0430\u0437\u0443.<\/p>\n<hr\/>\n<h4>4. .dockerignore \u2014 must-have<\/h4>\n<p>\u0411\u0435\u0437 <code>.dockerignore<\/code> \u0442\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043a\u043b\u0430\u0434\u0451\u0448\u044c \u0432 \u043e\u0431\u0440\u0430\u0437 \u043b\u0438\u0448\u043d\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>.git<\/p>\n<\/li>\n<li>\n<p><strong>pycache<\/strong><\/p>\n<\/li>\n<li>\n<p>.env<\/p>\n<\/li>\n<li>\n<p>.vscode\/<\/p>\n<\/li>\n<li>\n<p>node_modules\/<\/p>\n<\/li>\n<li>\n<p>\u0438 \u0442.\u0434. \u0438 \u0442.\u043f.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440, \u0441\u0431\u0438\u0432\u0430\u0435\u0442 \u043a\u0435\u0448, \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043b\u043e\u0445\u043e.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 <code>.dockerignore<\/code>:<\/p>\n<pre><code>.git __pycache__\/ *.pyc .env .vscode\/ node_modules\/ *.log<\/code><\/pre>\n<p>\u0421\u0434\u0435\u043b\u0430\u0439 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u2014 \u0438 \u0437\u0430\u0431\u0443\u0434\u0435\u0448\u044c \u043f\u0440\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<hr\/>\n<h4>5. Volume: \u0431\u0443\u0434\u044c \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u0435\u043d<\/h4>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u043a\u043e\u0433\u0434\u0430 \u0442\u044b \u043c\u043e\u043d\u0442\u0438\u0440\u0443\u0435\u0448\u044c volume, \u043e\u043d \u0437\u0430\u0442\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0451 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430.<\/p>\n<pre><code class=\"bash\">docker run -v $(pwd):\/app myapp <\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435:<\/p>\n<ul>\n<li>\n<p>\u0412\u0441\u0451, \u0447\u0442\u043e \u0442\u044b \u0441\u043e\u0431\u0440\u0430\u043b \u2014 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043c\u043e\u0433\u0443\u0442 \u0441\u043b\u043e\u043c\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443.<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 volume:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">docker volume create mydata docker run -v mydata:\/data myapp<\/code><\/pre>\n<ul>\n<li>\n<p>\u041f\u0440\u043e\u043f\u0438\u0448\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0430 \u0437\u0430\u0440\u0430\u043d\u0435\u0435.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>6. CMD \u0438 ENTRYPOINT<\/h4>\n<p>\u041d\u044e\u0430\u043d\u0441: CMD \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, ENTRYPOINT \u2014 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>CMD [\"python\", \"app.py\"]<\/code><\/pre>\n<p>\u0422\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b:<\/p>\n<pre><code class=\"bash\">docker run myapp bash<\/code><\/pre>\n<p>\u0410 \u043f\u043e\u043b\u0443\u0447\u0438\u043b: <code>python app.py bash<\/code><\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code>ENTRYPOINT [\"python\", \"app.py\"] CMD [\"--debug\"]<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e.<\/p>\n<hr\/>\n<h4>7. USER: \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0439 \u0432\u0441\u0451 \u043e\u0442 root<\/h4>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Docker \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0442 root. \u042d\u0442\u043e \u043e\u043f\u0430\u0441\u043d\u043e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c volume \u0438\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u043e\u043a\u0435\u0442\u0443.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c:<\/p>\n<pre><code>RUN useradd -m myuser USER myuser<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0418 \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u043e\u043d \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 root.<\/p>\n<hr\/>\n<h4>8. Healthcheck<\/h4>\n<p>Docker \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0436\u0438\u0432, \u0435\u0441\u043b\u0438 \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0443\u043c\u0435\u0440. \u041d\u043e \u0442\u0432\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u043d\u0443\u0442\u044c \u0438\u043b\u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c 500.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c healthcheck:<\/p>\n<pre><code>HEALTHCHECK --interval=30s --timeout=10s --retries=3 \\   CMD curl -f http:\/\/localhost:8000\/health || exit 1<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c Docker \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0438\u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0436\u0438\u0432.<\/p>\n<hr\/>\n<h4>9. \u041a\u0435\u0448 Docker<\/h4>\n<p>\u0421\u043b\u043e\u0438 \u0432 Docker \u043a\u0435\u0448\u0438\u0440\u0443\u044e\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u0442\u044b \u043f\u0438\u0448\u0435\u0448\u044c \u0441\u043b\u043e\u0438 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u043a\u0435\u0448 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e:<\/p>\n<pre><code>COPY . . RUN pip install -r requirements.txt<\/code><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>COPY requirements.txt . RUN pip install -r requirements.txt COPY . .<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0435\u0441\u043b\u0438 \u0442\u044b \u043c\u0435\u043d\u044f\u0435\u0448\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0434, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0435 \u0441\u0442\u0430\u0432\u044f\u0442\u0441\u044f \u0437\u0430\u043d\u043e\u0432\u043e.<\/p>\n<hr\/>\n<h4>10. Docker \u0432 CI<\/h4>\n<p>\u0427\u0430\u0441\u0442\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>\u041f\u0443\u0448 <code>latest<\/code> \u0431\u0435\u0437 \u0442\u0435\u0433\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041a\u043b\u0430\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u0432 \u043e\u0431\u0440\u0430\u0437.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <code>.dockerignore<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0430\u043a \u043d\u0430\u0434\u043e:<\/p>\n<ul>\n<li>\n<p>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u0433\u0438 \u044f\u0432\u043d\u043e: <code>myapp:1.2.3<\/code><\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u044b \u0432 \u043e\u0431\u0440\u0430\u0437\u0435. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c secrets \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e <code>.dockerignore<\/code> \u0435\u0441\u0442\u044c \u0438 \u0440\u0430\u0431\u043e\u0447\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>11. \u0423\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043e\u0431\u0440\u0430\u0437\u0430<\/h4>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 MB \u0432\u0430\u0436\u0435\u043d, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 CI\/CD. \u0427\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0423\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<pre><code>RUN apt-get install -y gcc &amp;&amp; pip install some-lib &amp;&amp; apt-get remove -y gcc<\/code><\/pre>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>--no-cache<\/code> \u0438 \u0447\u0438\u0441\u0442\u0438\u0442\u044c <code>\/tmp<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c <code>slim<\/code>, \u0430 \u043d\u0435 full-\u043e\u0431\u0440\u0430\u0437\u044b.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>12. Alpine \u2014 \u043d\u0435 \u0441\u0435\u0440\u0435\u0431\u0440\u044f\u043d\u0430\u044f \u043f\u0443\u043b\u044f<\/h4>\n<p>\u0414\u0430, \u043e\u043d \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439. \u041d\u043e:<\/p>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 musl, \u0430 \u043d\u0435 glibc.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c\u044e C-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u043b\u0433\u0438\u0439 \u0431\u0438\u043b\u0434 Python\u2011\u043f\u0430\u043a\u0435\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 Alpine \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0442\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0448\u044c, \u0437\u0430\u0447\u0435\u043c \u043e\u043d \u0442\u0435\u0431\u0435 \u043d\u0443\u0436\u0435\u043d. \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u2014 <code>slim<\/code>.<\/p>\n<hr\/>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430 Docker-\u043e\u0431\u0440\u0430\u0437\u0430 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e &#171;\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 \u0443 \u043c\u0435\u043d\u044f&#187;. \u042d\u0442\u043e \u043f\u0440\u043e \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u044c, \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0441\u0442\u044c. \u041c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u043a \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 \u043b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u2014 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0431\u043e\u043b\u0438.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u0448\u044c \u0447\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u0438\u0437 \u043c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u043a &#171;\u0432\u0440\u0435\u0434\u043d\u044b\u043c \u0441\u043e\u0432\u0435\u0442\u0430\u043c&#187; &#8212; \u043c\u0438\u043b\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0448\u0443 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438. \u042f \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u044e \u0438 \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u044e, \u0435\u0441\u043b\u0438 \u0442\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e.<\/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\/917226\/\"> https:\/\/habr.com\/ru\/articles\/917226\/<\/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>\u0415\u0441\u043b\u0438 \u0442\u044b \u043f\u0438\u0448\u0435\u0448\u044c <code>Dockerfile<\/code>, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0435 \u0432 \u0442\u043e\u043c, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438. \u0412\u043e\u043f\u0440\u043e\u0441 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c: <strong>\u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0434\u0435\u043b\u044e, \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0432 CI\/CD, \u043d\u0430 \u0447\u0443\u0436\u043e\u043c \u0436\u0435\u043b\u0435\u0437\u0435 \u2014 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u044d\u0442\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e<\/strong>. \u0418\u043b\u0438 \u0432\u0441\u0451 \u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u044b \u043d\u0435 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043b \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u043b\u043e\u0436\u0438\u043b\u0441\u044f \u043d\u0430 <code>latest<\/code>, \u0438 \u0437\u0430\u0431\u044b\u043b \u043f\u0440\u043e \u0442\u043e, \u0447\u0442\u043e <code>ENTRYPOINT<\/code> \u2014 \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u043a\u043e\u0434.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u2014 \u043a\u0430\u043a \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 Docker-\u043e\u0431\u0440\u0430\u0437, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 <strong>\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c<\/strong>, <strong>\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432<\/strong> \u0438 <strong>\u0433\u043e\u0442\u043e\u0432 \u043a \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0443<\/strong>.<\/p>\n<hr\/>\n<h4>1. \u041f\u0435\u0440\u0432\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430: \u0442\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0448\u044c \u0441 \u043f\u043b\u043e\u0445\u043e\u0439 \u0431\u0430\u0437\u044b<\/h4>\n<p>\u041c\u043d\u043e\u0433\u0438\u0435 \u0431\u0435\u0440\u0443\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437, \u043d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u044f\u0441\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>python:3.12<\/code>. \u042d\u0442\u043e &#171;\u0442\u043e\u043b\u0441\u0442\u044b\u0439&#187; \u043e\u0431\u0440\u0430\u0437 \u0441 \u043a\u0443\u0447\u0435\u0439 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0441\u0438\u0442\u044c 1+ \u0413\u0411. \u0422\u0430\u043c \u043a\u0443\u0447\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0447\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u0430\u0442\u0430\u043a \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0431\u0438\u043b\u0434\u044b \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e\u0439 <code>Dockerfile<\/code>:<\/p>\n<pre><code class=\"yaml\">FROM python:3.12 WORKDIR \/app COPY . . RUN pip install -r requirements.txt CMD [\"python\", \"main.py\"]<\/code><\/pre>\n<p>\u0427\u0442\u043e \u0442\u0443\u0442 \u043d\u0435 \u0442\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0437 <strong>\u0431\u043e\u043b\u044c\u0448\u043e\u0439<\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0435 \u0441\u043b\u043e\u0438 \u043a\u044d\u0448\u0430 \u0441\u0431\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043b\u044e\u0431\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0422\u044b \u043a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u0448\u044c \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u043d\u0443\u0442\u0440\u044c, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043c\u0443\u0441\u043e\u0440.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0430\u043a \u043b\u0443\u0447\u0448\u0435:<\/p>\n<ul>\n<li>\n<p>\u0411\u0440\u0430\u0442\u044c <code>python:3.12-slim<\/code> \u0438\u043b\u0438 <code>python:3.12-alpine<\/code>, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0448\u044c, \u043a\u0430\u043a \u0441 \u043d\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0442\u044b \u0435\u0433\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0448\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0443\u043f\u0435\u043d\u0447\u0430\u0442\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0438\u043b\u0434, \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0432 &#171;\u0447\u0438\u0441\u0442\u0443\u044e&#187; \u0444\u0430\u0437\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0447\u0451\u0442\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u043b\u043e\u0451\u0432: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u0442\u043e\u043c \u043a\u043e\u0434.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>2. \u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 latest<\/h4>\n<p><code>latest<\/code> \u2014 \u044d\u0442\u043e \u043b\u043e\u0432\u0443\u0448\u043a\u0430. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043e\u0431\u0440\u0430\u0437 \u043e\u0434\u0438\u043d, \u0437\u0430\u0432\u0442\u0440\u0430 \u043e\u043d \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0441\u044f, \u0438 \u0432\u0441\u0451 \u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f. \u041f\u0440\u0438\u0447\u0451\u043c \u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u2014 \u0443 \u0442\u0435\u0431\u044f \u0432 \u043f\u0440\u043e\u0434\u0435 \u0438\u043b\u0438 \u0432 CI.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>FROM node:latest<\/code><\/pre>\n<p>\u0412 \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a \u044d\u0442\u043e Node 18. \u0412 \u0441\u0440\u0435\u0434\u0443 \u2014 \u0443\u0436\u0435 20. \u0418 \u0442\u0432\u043e\u0439 build \u043f\u0430\u0434\u0430\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0430\u043a\u0435\u0442 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c.<\/p>\n<p>\u041b\u0443\u0447\u0448\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e:<\/p>\n<pre><code>FROM node:18.16.1<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u0434\u0430\u0436\u0435 \u0441 sha256:<\/p>\n<pre><code>FROM node@sha256:&lt;digest&gt;<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0430\u0440\u0430\u043d\u043e\u0439\u044f. \u042d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435. \u0411\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u2014 \u043c\u0435\u043d\u044c\u0448\u0435 \u0441\u044e\u0440\u043f\u0440\u0438\u0437\u043e\u0432.<\/p>\n<hr\/>\n<h4>3. \u041f\u0440\u0438\u043c\u0435\u0440 \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e Dockerfile \u0434\u043b\u044f Python\u2011\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h4>\n<pre><code>FROM python:3.12.1-slim as builder WORKDIR \/install RUN apt-get update &amp;&amp; apt-get install -y build-essential COPY requirements.txt . RUN pip install --upgrade pip &amp;&amp; \\     pip wheel --no-deps --wheel-dir \/wheels -r requirements.txt  FROM python:3.12.1-slim ENV PYTHONDONTWRITEBYTECODE=1 \\     PYTHONUNBUFFERED=1 WORKDIR \/app COPY --from=builder \/wheels \/wheels COPY requirements.txt . RUN pip install --no-deps --no-index --find-links=\/wheels -r requirements.txt COPY . . CMD [\"uvicorn\", \"app.main:app\", \"--host\", \"0.0.0.0\", \"--port\", \"8000\"]<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 Dockerfile \u0434\u0435\u043b\u0430\u0435\u0442 \u0434\u0432\u0435 \u0432\u0435\u0449\u0438: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u0442\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0447\u0438\u0441\u0442\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c. \u0422\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u044c\u0448\u0435 \u043c\u0443\u0441\u043e\u0440\u0430 \u0438 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0441\u0431\u043e\u0440\u043a\u0430.<\/p>\n<p><strong>\u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u2014 \u0441\u0431\u043e\u0440\u043a\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439:<\/strong><\/p>\n<ol>\n<li>\n<p>\u0411\u0435\u0440\u0451\u043c \u043b\u0451\u0433\u043a\u0438\u0439 \u043e\u0431\u0440\u0430\u0437 Python 3.12.1<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0430\u0432\u0438\u043c build-essential \u2014 \u043e\u043d \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b requirements.txt<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 wheel-\u0444\u0430\u0439\u043b\u044b (\u044d\u0442\u043e \u043a\u0430\u043a zip-\u0430\u0440\u0445\u0438\u0432\u044b \u0434\u043b\u044f Python-\u043f\u0430\u043a\u0435\u0442\u043e\u0432)<\/p>\n<\/li>\n<\/ol>\n<p>\u0424\u0438\u0448\u043a\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e build-essential \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u044d\u0442\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0438 \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437.<\/p>\n<p><strong>\u0412\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u2014 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437:<\/strong><\/p>\n<ol>\n<li>\n<p>\u0421\u043d\u043e\u0432\u0430 \u0431\u0435\u0440\u0451\u043c \u0447\u0438\u0441\u0442\u044b\u0439 Python 3.12.1 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0435\u0433\u043e<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0434\u0432\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<ul>\n<li>\n<p>PYTHONDONTWRITEBYTECODE \u2014 \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438\u0441\u044c .pyc-\u0444\u0430\u0439\u043b\u044b<\/p>\n<\/li>\n<li>\n<p>PYTHONUNBUFFERED \u2014 \u0447\u0442\u043e\u0431\u044b \u043b\u043e\u0433\u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0441\u0440\u0430\u0437\u0443<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c wheel-\u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0430\u0432\u0438\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 (\u0443\u0436\u0435 \u0431\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438)<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0441\u0430\u043c\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c uvicorn \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 8000<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u043b\u0443\u0447\u0448\u0435:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0435\u0441\u0438\u0442<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043a\u0435\u0442\u044b \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435<\/p>\n<\/li>\n<li>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430 \u0438\u0434\u0451\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0437\u0430 \u0441\u0447\u0451\u0442 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f wheel-\u0444\u0430\u0439\u043b\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0442 \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0442\u0438\u043f\u0430 build-essential \u0432 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u0431\u0440\u0430\u0437\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432 \u043e\u0431\u0440\u0430\u0437 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, curl \u0434\u043b\u044f healthcheck), \u0434\u0435\u043b\u0430\u0439 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c COPY. \u041d\u043e \u043f\u043e\u043c\u043d\u0438 \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 RUN \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u043e\u0439 \u043a \u043e\u0431\u0440\u0430\u0437\u0443.<\/p>\n<hr\/>\n<h4>4. .dockerignore \u2014 must-have<\/h4>\n<p>\u0411\u0435\u0437 <code>.dockerignore<\/code> \u0442\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043a\u043b\u0430\u0434\u0451\u0448\u044c \u0432 \u043e\u0431\u0440\u0430\u0437 \u043b\u0438\u0448\u043d\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>.git<\/p>\n<\/li>\n<li>\n<p><strong>pycache<\/strong><\/p>\n<\/li>\n<li>\n<p>.env<\/p>\n<\/li>\n<li>\n<p>.vscode\/<\/p>\n<\/li>\n<li>\n<p>node_modules\/<\/p>\n<\/li>\n<li>\n<p>\u0438 \u0442.\u0434. \u0438 \u0442.\u043f.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440, \u0441\u0431\u0438\u0432\u0430\u0435\u0442 \u043a\u0435\u0448, \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043b\u043e\u0445\u043e.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 <code>.dockerignore<\/code>:<\/p>\n<pre><code>.git __pycache__\/ *.pyc .env .vscode\/ node_modules\/ *.log<\/code><\/pre>\n<p>\u0421\u0434\u0435\u043b\u0430\u0439 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u2014 \u0438 \u0437\u0430\u0431\u0443\u0434\u0435\u0448\u044c \u043f\u0440\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<hr\/>\n<h4>5. Volume: \u0431\u0443\u0434\u044c \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u0435\u043d<\/h4>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u043a\u043e\u0433\u0434\u0430 \u0442\u044b \u043c\u043e\u043d\u0442\u0438\u0440\u0443\u0435\u0448\u044c volume, \u043e\u043d \u0437\u0430\u0442\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0451 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430.<\/p>\n<pre><code class=\"bash\">docker run -v $(pwd):\/app myapp <\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435:<\/p>\n<ul>\n<li>\n<p>\u0412\u0441\u0451, \u0447\u0442\u043e \u0442\u044b \u0441\u043e\u0431\u0440\u0430\u043b \u2014 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043c\u043e\u0433\u0443\u0442 \u0441\u043b\u043e\u043c\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443.<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 volume:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">docker volume create mydata docker run -v mydata:\/data myapp<\/code><\/pre>\n<ul>\n<li>\n<p>\u041f\u0440\u043e\u043f\u0438\u0448\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0430 \u0437\u0430\u0440\u0430\u043d\u0435\u0435.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>6. CMD \u0438 ENTRYPOINT<\/h4>\n<p>\u041d\u044e\u0430\u043d\u0441: CMD \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, ENTRYPOINT \u2014 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>CMD [\"python\", \"app.py\"]<\/code><\/pre>\n<p>\u0422\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b:<\/p>\n<pre><code class=\"bash\">docker run myapp bash<\/code><\/pre>\n<p>\u0410 \u043f\u043e\u043b\u0443\u0447\u0438\u043b: <code>python app.py bash<\/code><\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code>ENTRYPOINT [\"python\", \"app.py\"] CMD [\"--debug\"]<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e.<\/p>\n<hr\/>\n<h4>7. USER: \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0439 \u0432\u0441\u0451 \u043e\u0442 root<\/h4>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Docker \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0442 root. \u042d\u0442\u043e \u043e\u043f\u0430\u0441\u043d\u043e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c volume \u0438\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u043e\u043a\u0435\u0442\u0443.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c:<\/p>\n<pre><code>RUN useradd -m myuser USER myuser<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0418 \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u043e\u043d \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 root.<\/p>\n<hr\/>\n<h4>8. Healthcheck<\/h4>\n<p>Docker \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0436\u0438\u0432, \u0435\u0441\u043b\u0438 \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0443\u043c\u0435\u0440. \u041d\u043e \u0442\u0432\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u043d\u0443\u0442\u044c \u0438\u043b\u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c 500.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c healthcheck:<\/p>\n<pre><code>HEALTHCHECK --interval=30s --timeout=10s --retries=3 \\   CMD curl -f http:\/\/localhost:8000\/health || exit 1<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c Docker \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0438\u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0436\u0438\u0432.<\/p>\n<hr\/>\n<h4>9. \u041a\u0435\u0448 Docker<\/h4>\n<p>\u0421\u043b\u043e\u0438 \u0432 Docker \u043a\u0435\u0448\u0438\u0440\u0443\u044e\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u0442\u044b \u043f\u0438\u0448\u0435\u0448\u044c \u0441\u043b\u043e\u0438 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u043a\u0435\u0448 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e:<\/p>\n<pre><code>COPY . . RUN pip install -r requirements.txt<\/code><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>COPY requirements.txt . RUN pip install -r requirements.txt COPY . .<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0435\u0441\u043b\u0438 \u0442\u044b \u043c\u0435\u043d\u044f\u0435\u0448\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0434, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0435 \u0441\u0442\u0430\u0432\u044f\u0442\u0441\u044f \u0437\u0430\u043d\u043e\u0432\u043e.<\/p>\n<hr\/>\n<h4>10. Docker \u0432 CI<\/h4>\n<p>\u0427\u0430\u0441\u0442\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>\u041f\u0443\u0448 <code>latest<\/code> \u0431\u0435\u0437 \u0442\u0435\u0433\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041a\u043b\u0430\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u0432 \u043e\u0431\u0440\u0430\u0437.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <code>.dockerignore<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0430\u043a \u043d\u0430\u0434\u043e:<\/p>\n<ul>\n<li>\n<p>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u0433\u0438 \u044f\u0432\u043d\u043e: <code>myapp:1.2.3<\/code><\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u044b \u0432 \u043e\u0431\u0440\u0430\u0437\u0435. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c secrets \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e <code>.dockerignore<\/code> \u0435\u0441\u0442\u044c \u0438 \u0440\u0430\u0431\u043e\u0447\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>11. \u0423\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043e\u0431\u0440\u0430\u0437\u0430<\/h4>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 MB \u0432\u0430\u0436\u0435\u043d, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 CI\/CD. \u0427\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0423\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<pre><code>RUN apt-get install -y gcc &amp;&amp; pip install some-lib &amp;&amp; apt-get remove -y gcc<\/code><\/pre>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>--no-cache<\/code> \u0438 \u0447\u0438\u0441\u0442\u0438\u0442\u044c <code>\/tmp<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c <code>slim<\/code>, \u0430 \u043d\u0435 full-\u043e\u0431\u0440\u0430\u0437\u044b.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>12. Alpine \u2014 \u043d\u0435 \u0441\u0435\u0440\u0435\u0431\u0440\u044f\u043d\u0430\u044f \u043f\u0443\u043b\u044f<\/h4>\n<p>\u0414\u0430, \u043e\u043d \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439. \u041d\u043e:<\/p>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 musl, \u0430 \u043d\u0435 glibc.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c\u044e C-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u043b\u0433\u0438\u0439 \u0431\u0438\u043b\u0434 Python\u2011\u043f\u0430\u043a\u0435\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 Alpine \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0442\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0448\u044c, \u0437\u0430\u0447\u0435\u043c \u043e\u043d \u0442\u0435\u0431\u0435 \u043d\u0443\u0436\u0435\u043d. \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u2014 <code>slim<\/code>.<\/p>\n<hr\/>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430 Docker-\u043e\u0431\u0440\u0430\u0437\u0430 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e &#171;\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 \u0443 \u043c\u0435\u043d\u044f&#187;. \u042d\u0442\u043e \u043f\u0440\u043e \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u044c, \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0441\u0442\u044c. \u041c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u043a \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 \u043b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u2014 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0431\u043e\u043b\u0438.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u0448\u044c \u0447\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u0438\u0437 \u043c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u043a &#171;\u0432\u0440\u0435\u0434\u043d\u044b\u043c \u0441\u043e\u0432\u0435\u0442\u0430\u043c&#187; &#8212; \u043c\u0438\u043b\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0448\u0443 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438. \u042f \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u044e \u0438 \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u044e, \u0435\u0441\u043b\u0438 \u0442\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e.<\/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\/917226\/\"> https:\/\/habr.com\/ru\/articles\/917226\/<\/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-462789","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/462789","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=462789"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/462789\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=462789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=462789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=462789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}