{"id":481773,"date":"2026-05-31T13:08:33","date_gmt":"2026-05-31T13:08:33","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=481773"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=481773","title":{"rendered":"Best Practices \u043f\u043e Dockerfile: \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430 \u0438 \u043a\u0435\u0448\u0430 \u0434\u043e SBOM, Cosign \u0438 CI\/CD"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/h2>\n<p>\u0421\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439: \u043f\u0440\u0430\u043a\u0442\u0438\u043a \u043c\u043d\u043e\u0433\u043e, \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043d\u0438\u0445 \u0432\u0430\u0436\u043d\u0430 \u043f\u043e-\u0441\u0432\u043e\u0435\u043c\u0443. \u042f \u0441\u043e\u0431\u0440\u0430\u043b \u0435\u0451 \u043a\u0430\u043a \u043d\u0430\u0431\u043e\u0440 best practices: \u043d\u0435 \u0432\u0441\u0435 \u043f\u0443\u043d\u043a\u0442\u044b \u043d\u0443\u0436\u043d\u044b \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0443, \u043d\u043e \u043f\u043e\u0447\u0442\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0443\u043d\u043a\u0442 \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0440\u0435\u0432\u044c\u044e, \u0432 CI \u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0438\u043d\u0446\u0438\u0434\u0435\u043d\u0442\u0430.<\/p>\n<p>\u042f \u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0433\u0440\u0435\u0439\u0434\u043e\u0432: \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u0440\u043e\u0434\u0435 <code>COPY . .<\/code>, <code>latest<\/code> \u0438 root-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043e \u043f\u0440\u043e\u0434\u043e\u0432\u044b\u0445 \u0442\u0435\u043c \u0432\u0440\u043e\u0434\u0435 BuildKit, \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u0432, SBOM, \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u0438 \u0437\u0430\u0449\u0438\u0442\u044b \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u041f\u041e.<br \/> \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f\u0437\u044b\u043a \u043f\u043e\u0434\u0430\u0447\u0438 \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u0441\u0443\u0445\u043e\u0439, \u043f\u0440\u044f\u043c\u043e\u0439 \u0438 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043d\u044b\u0439: \u0431\u0435\u0437 \u0434\u043e\u043b\u0433\u0438\u0445 \u0437\u0430\u0445\u043e\u0434\u043e\u0432, \u0431\u0435\u0437 \u0432\u043e\u0434\u044b \u0438 \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0441\u043a\u0430\u0437\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0440\u0430\u0434\u0438 \u043f\u0435\u0440\u0435\u0441\u043a\u0430\u0437\u0430. \u042f \u0445\u043e\u0442\u0435\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043e\u0431\u0437\u043e\u0440\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e, \u0430 \u0440\u0430\u0431\u043e\u0447\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u043a\u0443, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438, \u0440\u0435\u0432\u044c\u044e \u0438\u043b\u0438 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0435 Dockerfile.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u044b\u043b\u043e \u043b\u0435\u0433\u0447\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u044f \u0440\u0430\u0437\u0431\u0438\u043b \u0435\u0451 \u043d\u0430 \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u044b\u0435 \u0431\u043b\u043e\u043a\u0438. \u041d\u0438\u0436\u0435 \u043e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435: \u043d\u0430\u0436\u0430\u043b\u0438 \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0439 \u043f\u0443\u043d\u043a\u0442 \u2014 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0443.<\/p>\n<p><strong>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/strong><\/p>\n<ol>\n<li>\n<p><a href=\"#base-image\" rel=\"noopener noreferrer nofollow\">\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437, \u0432\u0435\u0440\u0441\u0438\u0438 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#build-context\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u0431\u043e\u0440\u043a\u0438, <code>.dockerignore<\/code>, \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#layers-cache-buildkit\" rel=\"noopener noreferrer nofollow\">\u0421\u043b\u043e\u0438, \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 BuildKit<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#multistage\" rel=\"noopener noreferrer nofollow\">Multi-stage build \u0438 \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#secrets\" rel=\"noopener noreferrer nofollow\">\u0421\u0435\u043a\u0440\u0435\u0442\u044b: build-time, runtime \u0438 \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0443\u0442\u0435\u0447\u0435\u043a \u0432 \u0441\u043b\u043e\u044f\u0445<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#user-permissions\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, UID, \u043f\u0440\u0430\u0432\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#process-startup\" rel=\"noopener noreferrer nofollow\">\u0417\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: <code>CMD<\/code>, <code>ENTRYPOINT<\/code>, PID 1, SIGTERM \u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u00ab\u043e\u0434\u0438\u043d \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u2014 \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0438\u0441\u00bb<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#runtime-behavior\" rel=\"noopener noreferrer nofollow\">Runtime-\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435: healthcheck, \u043f\u043e\u0440\u0442\u044b, volumes, \u043a\u043e\u043d\u0444\u0438\u0433\u0438, \u043b\u043e\u0433\u0438, \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 Gunicorn<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#supply-chain-ci\" rel=\"noopener noreferrer nofollow\">\u0426\u0435\u043f\u043e\u0447\u043a\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u041f\u041e, registry, \u043f\u043e\u0434\u043f\u0438\u0441\u044c, \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043b\u0438\u043d\u0442\u0438\u043d\u0433, \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 CI\/CD<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#examples\" rel=\"noopener noreferrer nofollow\">\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b Dockerfile<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#conclusion\" rel=\"noopener noreferrer nofollow\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/a><\/p>\n<\/li>\n<\/ol>\n<h3>\u0417\u0430\u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u0443\u043c\u0430\u0442\u044c \u043e Dockerfile<\/h3>\n<p>Dockerfile \u2014 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u042d\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0443\u0449\u0435\u0439 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d-\u0441\u0440\u0435\u0434\u044b: \u043a\u0430\u043a\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432\u043d\u0443\u0442\u0440\u044c, \u043e\u0442 \u043a\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u0430\u043a\u0438\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u043b\u043e\u044f\u0445, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0431\u0440\u0430\u0437 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 CI\/CD \u0438 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e \u043e\u043d \u043f\u043e\u0432\u0435\u0434\u0451\u0442 \u0441\u0435\u0431\u044f \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0441\u044f\u0446.<\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u0438\u0439 Dockerfile \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0448\u0430\u0442\u044c \u0442\u0440\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e:<\/p>\n<ol>\n<li>\n<p><strong>\u0412\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c<\/strong> \u2014 \u043e\u0434\u043d\u0430 \u0438 \u0442\u0430 \u0436\u0435 \u0432\u0435\u0440\u0441\u0438\u044f Dockerfile \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u0440\u0430\u0437.<\/p>\n<\/li>\n<li>\n<p><strong>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438 \u0431\u044b\u0441\u0442\u0440\u044b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438<\/strong> \u2014 \u0432 \u043e\u0431\u0440\u0430\u0437\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e.<\/p>\n<\/li>\n<li>\n<p><strong>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c<\/strong> \u2014 \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u041f\u041e, \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439, \u043c\u0435\u043d\u044c\u0448\u0435 \u0448\u0430\u043d\u0441\u043e\u0432 \u0443\u0442\u0435\u0447\u043a\u0438 \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u0432 \u0438 \u043f\u0440\u043e\u0449\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439.<\/p>\n<\/li>\n<\/ol>\n<hr\/>\n<p><a class=\"anchor\" name=\"base-image\" id=\"base-image\"><\/a><\/p>\n<h3>1. \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437, \u0432\u0435\u0440\u0441\u0438\u0438 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 <code>FROM<\/code>, \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440, \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u041f\u043b\u043e\u0445\u0430\u044f \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0430 \u2014 \u0431\u0440\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e Ubuntu\/Debian\/CentOS \u00ab\u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439\u00bb, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043a\u0443\u0447\u0443 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u0443\u0442\u0438\u043b\u0438\u0442, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435: <strong>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0441\u0430\u043c\u044b\u0439 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0443\u043c\u0435\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/strong>.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e:<\/p>\n<pre><code>FROM ubuntu:22.04RUN apt-get update &amp;&amp; apt-get install -y python3 python3-pip curl vim git<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>FROM python:3.12-slim<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0449\u0451 \u043b\u0443\u0447\u0448\u0435 \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439:<\/p>\n<pre><code>FROM gcr.io\/distroless\/python3-debian12<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>1.1. \u0412\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u043f\u043e\u0434 \u0437\u0430\u0434\u0430\u0447\u0443<\/h3>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Node.js \u0431\u0435\u0440\u0438\u0442\u0435 <code>node<\/code>, \u0434\u043b\u044f Python \u2014 <code>python<\/code>, \u0434\u043b\u044f Java \u2014 <code>eclipse-temurin<\/code>, <code>amazoncorretto<\/code> \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0439 JDK\/JRE-\u043e\u0431\u0440\u0430\u0437, \u0434\u043b\u044f Nginx \u2014 <code>nginx<\/code>, \u0434\u043b\u044f PostgreSQL \u2014 <code>postgres<\/code>.<\/p>\n<p>\u0421\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0437\u044b \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 runtime, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u043c \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0443\u043a\u0430\u043c\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u042d\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440, \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u0438\u0448\u043d\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0437 \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435 \u0434\u043b\u044f \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0447\u0435\u0442\u044b\u0440\u0435 \u0432\u0435\u0449\u0438:<\/p>\n<ul>\n<li>\n<p>\u043e\u0431\u0440\u0430\u0437 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0438\u043b\u0438 \u043e\u0442 \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f;<\/p>\n<\/li>\n<li>\n<p>\u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 Dockerfile \u0438\u043b\u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u0443\u044e \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u043c, \u043d\u043e \u043d\u0435 \u0446\u0435\u043d\u043e\u0439 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>1.2. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 slim, alpine, distroless \u0438 scratch \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e<\/h3>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0430\u043c\u044b\u0439 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439. \u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0435\u0441\u0442\u044c \u0446\u0435\u043d\u0430.<\/p>\n<h4>slim<\/h4>\n<p><code>slim<\/code>-\u043e\u0431\u0440\u0430\u0437\u044b \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u044b \u043d\u0430 Debian, \u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u0412\u0430\u0436\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u2014 \u0442\u0430\u043c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f <code>glibc<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d\u0438 \u0447\u0430\u0441\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0434\u043b\u044f Python, Java, Node.js \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0441 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438.<\/p>\n<p>\u0427\u0430\u0441\u0442\u043e \u044d\u0442\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441:<\/p>\n<pre><code>FROM python:3.12-slim<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>alpine<\/h4>\n<p>Alpine \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439, \u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>musl<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <code>glibc<\/code>. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 Python\/C\/C++-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u043b\u044c\u0448\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438\u043d\u0430\u0447\u0435 \u0438\u043b\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432.<\/p>\n<p>Alpine \u0445\u043e\u0440\u043e\u0448, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ul>\n<li>\n<p>\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043e \u043d\u0430 Alpine;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0435 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0442 \u0441 <code>musl<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u0440\u0430\u0437\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u043d.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u043e Alpine \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u043d \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439.<\/p>\n<h4>distroless<\/h4>\n<p>Distroless-\u043e\u0431\u0440\u0430\u0437\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 runtime \u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043d\u043e \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432: shell, package manager, curl, vim \u0438 \u0442.\u0434. \u042d\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c \u0430\u0442\u0430\u043a\u0438: \u0435\u0441\u043b\u0438 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432\u043d\u0443\u0442\u0440\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u0443 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>\u041c\u0438\u043d\u0443\u0441 \u2014 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c: \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0439\u0442\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c <code>bash<\/code>.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f Go:<\/p>\n<pre><code>FROM golang:1.22 AS builderWORKDIR \/srcCOPY go.mod go.sum .\/RUN go mod downloadCOPY . .RUN CGO_ENABLED=0 GOOS=linux go build -o \/app .\/cmd\/appFROM gcr.io\/distroless\/static-debian12COPY --from=builder \/app \/appUSER nonroot:nonrootENTRYPOINT [\"\/app\"]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>scratch<\/h4>\n<p><code>scratch<\/code> \u2014 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0443\u0441\u0442\u043e\u0439 \u043e\u0431\u0440\u0430\u0437. \u041e\u043d \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b shell, libc, \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b, timezone data \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b.<\/p>\n<pre><code>FROM scratchCOPY --from=builder \/app \/appENTRYPOINT [\"\/app\"]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>scratch<\/code>, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u043a\u0430\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u043d\u0443\u0436\u043d\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<h3>1.3. \u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 latest \u0432 production<\/h3>\n<p><code>latest<\/code> \u2014 \u044d\u0442\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043f\u0440\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0435\u0433, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439. \u0421\u0435\u0433\u043e\u0434\u043d\u044f <code>node:latest<\/code> \u043c\u043e\u0436\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043e\u0434\u043d\u0443 \u0432\u0435\u0440\u0441\u0438\u044e Node.js, \u0437\u0430\u0432\u0442\u0440\u0430 \u2014 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e. \u0412 CI\/CD \u044d\u0442\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043b\u043e\u0442\u0435\u0440\u0435\u044e: Dockerfile \u043d\u0435 \u043c\u0435\u043d\u044f\u043b\u0441\u044f, \u0430 \u0441\u0431\u043e\u0440\u043a\u0430 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u0441\u043b\u043e\u043c\u0430\u043b\u0430\u0441\u044c.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e:<\/p>\n<pre><code>FROM node:latest<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>FROM node:24.16.0-slim<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0449\u0451 \u0441\u0442\u0440\u043e\u0436\u0435:<\/p>\n<pre><code>FROM node@sha256:&lt;digest&gt;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0434\u0430 \u043b\u0443\u0447\u0448\u0435 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0432\u0435\u0440\u0441\u0438\u044e runtime: <code>node:24.16.0<\/code>, <code>python:3.12.13<\/code>, <code>golang:1.22.2<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u0431\u0440\u0430\u0437\u0430: <code>slim<\/code>, <code>alpine<\/code>, <code>bookworm<\/code>, <code>bullseye<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u043d\u044b\u0445 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u2014 digest \u0447\u0435\u0440\u0435\u0437 <code>sha256<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0435\u0433 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c, digest \u2014 \u043d\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 digest \u0434\u0430\u0451\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c.<\/p>\n<h3>1.4. \u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0439\u0442\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043e\u0431\u0440\u0430\u0437\u044b \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e, \u0430 \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e<\/h3>\n<p>\u041e\u0442\u043a\u0430\u0437 \u043e\u0442 <code>latest<\/code> \u043d\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f\u00bb. \u041d\u0430\u043e\u0431\u043e\u0440\u043e\u0442: \u043e\u0431\u0440\u0430\u0437\u044b \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c security-\u043f\u0430\u0442\u0447\u0438. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u043c.<\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0435\/LTS-\u0432\u0435\u0440\u0441\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043d\u0430 CVE;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c digest \u0438\u043b\u0438 \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043b\u043e\u0445\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f:<\/p>\n<pre><code>FROM python:latest<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0425\u043e\u0440\u043e\u0448\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f:<\/p>\n<pre><code>FROM python:3.12.13-slim-bookworm<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0434\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e patch-\u0440\u0435\u043b\u0438\u0437\u0430 \u0438\u043b\u0438 \u043d\u043e\u0432\u043e\u0433\u043e digest, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u0438 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c.<\/p>\n<h3>1.5. \u041d\u0435 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 upgrade \u0432\u0441\u0435\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/h3>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u044b \u0432\u0440\u043e\u0434\u0435 <code>apt-get upgrade<\/code>, <code>yum update<\/code>, <code>apk upgrade<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 Dockerfile \u0447\u0430\u0441\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u0441\u0431\u043e\u0440\u043a\u0443 \u043c\u0435\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0439. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043e\u043d\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u044f\u0442 \u043e\u0434\u0438\u043d \u043d\u0430\u0431\u043e\u0440 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u0437\u0430\u0432\u0442\u0440\u0430 \u2014 \u0434\u0440\u0443\u0433\u043e\u0439. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0438\u0441\u044c SCA\/\u0441\u043a\u0430\u043d\u0435\u0440\u0430\u043c\u0438.<\/p>\n<p>\u0420\u0435\u0447\u044c \u043d\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e security-\u043f\u0430\u0442\u0447\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b. \u041d\u0443\u0436\u043d\u044b. \u041d\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430, \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0443 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435, \u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 <code>apt-get upgrade<\/code> \u0432 \u043a\u0430\u0436\u0434\u043e\u043c build \u0431\u0435\u0437 \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e:<\/p>\n<pre><code>RUN apt-get update &amp;&amp; apt-get upgrade -y<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>RUN apt-get update &amp;&amp; apt-get install -y --no-install-recommends \\    ca-certificates \\    curl \\    &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/*<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u0441\u0440\u0435\u0434\u0430\u0445 \u0441 \u0436\u0451\u0441\u0442\u043a\u0438\u043c\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0439\u0442\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0430\u043a\u0435\u0442\u043e\u0432:<\/p>\n<pre><code>RUN apt-get update &amp;&amp; apt-get install -y --no-install-recommends \\    cowsay=3.03+dfsg1-6 \\    &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/*<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0430\u043a\u0435\u0442 \u0442\u044f\u043d\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c, \u0435\u0451 \u0442\u043e\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439.<\/p>\n<h3>1.6. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0439\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b<\/h3>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u2014 \u044d\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440;<\/p>\n<\/li>\n<li>\n<p>\u043d\u043e\u0432\u044b\u0435 CVE;<\/p>\n<\/li>\n<li>\n<p>\u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0441\u0431\u043e\u0440\u043a\u0443 \u0438 pull\/push;<\/p>\n<\/li>\n<li>\n<p>\u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0432 runtime-\u043e\u0431\u0440\u0430\u0437 <code>vim<\/code>, <code>git<\/code>, <code>gcc<\/code>, <code>make<\/code>, <code>curl<\/code>, <code>wget<\/code>, <code>bash<\/code>, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0435\u0437 \u043d\u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0414\u043b\u044f Debian\/Ubuntu \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435:<\/p>\n<pre><code>RUN apt-get update &amp;&amp; apt-get install -y --no-install-recommends \\    ca-certificates \\    &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/*<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><code>--no-install-recommends<\/code> \u043d\u0435 \u0434\u0430\u0451\u0442 \u043f\u0430\u043a\u0435\u0442\u043d\u043e\u043c\u0443 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0443 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0435, \u043d\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<hr\/>\n<p><a class=\"anchor\" name=\"build-context\" id=\"build-context\"><\/a><\/p>\n<h2>2. Build context, .dockerignore, \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u042d\u0442\u043e\u0442 \u0431\u043b\u043e\u043a \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0432\u0441\u0451, \u0447\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u043e\u0431\u0440\u0430\u0437 \u0438\u0437\u0432\u043d\u0435: \u0444\u0430\u0439\u043b\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0430\u0440\u0445\u0438\u0432\u044b, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0432\u043d\u0435\u0448\u043d\u0438\u0435 URL, \u0441\u0435\u043a\u0440\u0435\u0442\u044b \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u0432\u044b\u0431\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 <code>COPY<\/code> \u0438 <code>ADD<\/code>. \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f: <strong>\u0432 \u043e\u0431\u0440\u0430\u0437 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e, \u0438\u0437 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c<\/strong>.<\/p>\n<h3>2.1. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 .dockerignore<\/h3>\n<p>Docker \u043f\u0435\u0440\u0435\u0434 \u0441\u0431\u043e\u0440\u043a\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u0431\u043e\u0440\u043a\u0438 \u0434\u0435\u043c\u043e\u043d\u0443. \u0415\u0441\u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u2014 \u044d\u0442\u043e \u043a\u043e\u0440\u0435\u043d\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0442\u0443\u0434\u0430 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043f\u0430\u0441\u0442\u044c <code>.git<\/code>, <code>node_modules<\/code>, <code>.env<\/code>, \u043a\u043b\u044e\u0447\u0438, \u043b\u043e\u0433\u0438, \u043a\u0435\u0448\u0438, \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 IDE.<\/p>\n<p><code>.dockerignore<\/code> \u0440\u0435\u0448\u0430\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447:<\/p>\n<ul>\n<li>\n<p>\u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u0431\u043e\u0440\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u0441\u0431\u043e\u0440\u043a\u0443;<\/p>\n<\/li>\n<li>\n<p>\u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0440\u0438\u0441\u043a \u0443\u0442\u0435\u0447\u043a\u0438 \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043b\u0438\u0448\u043d\u044e\u044e \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043a\u0435\u0448\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u0434\u0430\u0451\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0443\u0441\u043e\u0440 \u0432 \u043e\u0431\u0440\u0430\u0437.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e <code>.dockerignore<\/code>:<\/p>\n<pre><code>.git.gitignore.vscode\/.idea\/.env.env.**.log__pycache__\/*.pycnode_modules\/coverage\/dist\/build\/.cache\/.DS_Store.aws\/.ssh\/<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f Go\/Java\/\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0447\u0430\u0441\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c allowlist-\u043f\u043e\u0434\u0445\u043e\u0434: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0451, \u0430 \u043f\u043e\u0442\u043e\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u043e\u0435.<\/p>\n<pre><code>*!go.mod!go.sum!cmd\/!internal\/!pkg\/<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u043e \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u043d\u0443\u0442\u044c: <code>.dockerignore<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u044f\u0437\u044b\u043a\u0443 \u0438 \u0441\u0431\u043e\u0440\u043a\u0435. \u0415\u0441\u043b\u0438 Java-\u043e\u0431\u0440\u0430\u0437\u0443 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0439 <code>.jar<\/code>, \u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0433\u043e, \u0430 \u043d\u0435 \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<h3>2.2. \u041d\u0435 \u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438<\/h3>\n<p>\u0410\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d:<\/p>\n<pre><code>COPY . .<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u0447\u0430\u0441\u0442\u043e \u044d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0448\u0438\u0440\u043e\u043a\u043e. \u0422\u0430\u043a\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0451, \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0432 build context \u043f\u043e\u0441\u043b\u0435 <code>.dockerignore<\/code>. \u0415\u0441\u043b\u0438 <code>.dockerignore<\/code> \u043d\u0435\u043f\u043e\u043b\u043d\u044b\u0439, \u0432 \u043e\u0431\u0440\u0430\u0437 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u043b\u0438\u0448\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u044b.<\/p>\n<p>\u041b\u0443\u0447\u0448\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044f\u0432\u043d\u043e:<\/p>\n<pre><code>COPY package.json package-lock.json .\/RUN npm ciCOPY src\/ .\/src\/<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u043b\u0438 \u0434\u043b\u044f Java:<\/p>\n<pre><code>COPY target\/app.jar \/app\/app.jar<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u043c\u044b\u0441\u043b: Dockerfile \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0438\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430.<\/p>\n<h3>2.3. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 COPY, \u0430 \u043d\u0435 ADD<\/h3>\n<p><code>COPY<\/code> \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u0443\u044e \u0432\u0435\u0449\u044c: \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 build context \u0432 \u043e\u0431\u0440\u0430\u0437.<\/p>\n<p><code>ADD<\/code> \u0443\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435:<\/p>\n<ul>\n<li>\n<p>\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u0440\u0445\u0438\u0432\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043f\u043e URL.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0438\u0437-\u0437\u0430 \u044d\u0442\u043e\u0439 \u043c\u043d\u043e\u0433\u043e\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <code>ADD<\/code> \u0447\u0430\u0449\u0435 \u043e\u043f\u0430\u0441\u043d\u0435\u0435 \u0438 \u043c\u0435\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e:<\/p>\n<pre><code>ADD https:\/\/example.com\/app.tar.gz \/app<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>COPY app\/ \/app\/<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0432, \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u044d\u0442\u043e \u044f\u0432\u043d\u043e \u0447\u0435\u0440\u0435\u0437 <code>RUN<\/code>, \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 checksum \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432:<\/p>\n<pre><code>RUN set -eux; \\    curl -fsSLo \/tmp\/app.tar.gz https:\/\/example.com\/app.tar.gz; \\    echo \"&lt;sha256&gt;  \/tmp\/app.tar.gz\" | sha256sum -c -; \\    tar -xzf \/tmp\/app.tar.gz -C \/app; \\    rm -f \/tmp\/app.tar.gz<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><code>ADD<\/code> \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0440\u0435\u0434\u043a\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e tar-\u0430\u0440\u0445\u0438\u0432\u0430 \u0438 \u0432\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442\u0435 \u044d\u0442\u043e\u0442 \u0430\u0440\u0445\u0438\u0432.<\/p>\n<h3>2.4. \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0439\u0442\u0435 \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e<\/h3>\n<p>\u041e\u043f\u0430\u0441\u043d\u044b\u0439 \u0430\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d:<\/p>\n<pre><code>RUN curl -fsSL http:\/\/example.com\/install.sh | sh<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0437\u0434\u0435\u0441\u044c \u0441\u0440\u0430\u0437\u0443 \u0442\u0440\u0438:<\/p>\n<ol>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u0438\u043b\u0438 \u043d\u0435\u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0439 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043a\u0430\u0447\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u0438\u043b\u0438 checksum.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>\u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043f\u043e HTTPS;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c SHA256\/SHA512;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c GPG-\u043f\u043e\u0434\u043f\u0438\u0441\u044c, \u0435\u0441\u043b\u0438 \u0432\u0435\u043d\u0434\u043e\u0440 \u0435\u0451 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443 \u043f\u0440\u0438 \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0438 checksum;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c, \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0430\u0440\u0445\u0438\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c <code>RUN<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>ARG TOOL_VERSION=1.2.3ARG TOOL_SHA256=&lt;expected_sha256&gt;RUN set -eux; \\    curl -fsSLo \/tmp\/tool.tar.gz \"https:\/\/example.com\/tool-${TOOL\\_VERSION}.tar.gz\"; \\    echo \"${TOOL_SHA256}  \/tmp\/tool.tar.gz\" | sha256sum -c -; \\    tar -xzf \/tmp\/tool.tar.gz -C \/usr\/local\/bin; \\    rm -f \/tmp\/tool.tar.gz<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0439 apt\/yum\/apk-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u0435\u0433\u043e GPG-\u043a\u043b\u044e\u0447\u0438 \u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a. \u041d\u0435 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0438\u0437 Dockerfile \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0434\u043e\u0432\u0435\u0440\u0438\u044f \u043a \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u043c\u0443 URL<\/p>\n<hr\/>\n<p><a class=\"anchor\" name=\"layers-cache-buildkit\" id=\"layers-cache-buildkit\"><\/a><\/p>\n<h2>3. \u0421\u043b\u043e\u0438, \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 BuildKit<\/h2>\n<p>Docker-\u043e\u0431\u0440\u0430\u0437 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u043b\u043e\u0451\u0432. \u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <code>RUN<\/code>, <code>COPY<\/code>, <code>ADD<\/code> \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043d\u043e\u0432\u044b\u0435 \u0441\u043b\u043e\u0438. \u0415\u0441\u043b\u0438 \u0441\u043b\u043e\u0439 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043e\u043d \u0438 \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0438\u0436\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u0435\u0448\u0435\u043c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0438, \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u0440\u0430\u0437\u0430 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c.<\/p>\n<h3>3.1. \u0420\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0439\u0442\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043a\u0435\u0448<\/h3>\n<p>\u0427\u0430\u0441\u0442\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u2014 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u043a\u043e\u0434, \u0430 \u043f\u043e\u0442\u043e\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e:<\/p>\n<pre><code>COPY . .RUN npm install<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041b\u044e\u0431\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u0434\u0435 \u0441\u0431\u0440\u043e\u0441\u0438\u0442 \u043a\u0435\u0448 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>COPY package.json package-lock.json .\/RUN npm ciCOPY . .<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041e\u0431\u0449\u0438\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f:<\/p>\n<ol>\n<li>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0442\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0442\u043e\u043c lock-\u0444\u0430\u0439\u043b\u044b \u0438 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u044b \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0442\u043e\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0442\u043e\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u2014 \u0442\u043e, \u0447\u0442\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u043b\u044f Python:<\/p>\n<pre><code>COPY requirements.txt .\/RUN pip install --no-cache-dir -r requirements.txtCOPY . .<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f Go:<\/p>\n<pre><code>COPY go.mod go.sum .\/RUN go mod downloadCOPY . .RUN go build -o \/app .\/cmd\/app<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f Node.js:<\/p>\n<pre><code>COPY package*.json .\/RUN npm ciCOPY . .<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>3.2. \u041e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u043e\u0434\u0438\u043d RUN<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u0442\u0435 \u043b\u0438\u0448\u043d\u0438\u0439 \u043c\u0443\u0441\u043e\u0440 \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u043b\u043e\u0435, \u0430 \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u0435\u0433\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u043c, \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u0440\u0430\u0437\u0430 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043c: \u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u0436\u0435 \u043f\u043e\u043f\u0430\u043b\u0438 \u0432 \u043d\u0438\u0436\u043d\u0438\u0439 \u0441\u043b\u043e\u0439.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e:<\/p>\n<pre><code>RUN apt-get updateRUN apt-get install -y curlRUN rm -rf \/var\/lib\/apt\/lists\/*<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>RUN apt-get update &amp;&amp; apt-get install -y --no-install-recommends \\    curl \\    &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/*<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u043e: <strong>\u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u043a\u0435\u0448 \u0438\u043b\u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u2014 \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u0435\u0433\u043e \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <\/strong><code><strong>RUN<\/strong><\/code>.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043d\u044b\u0445 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432:<\/p>\n<pre><code># Debian\/UbuntuRUN apt-get update &amp;&amp; apt-get install -y --no-install-recommends curl \\    &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/*# AlpineRUN apk add --no-cache curl# Yum\/DNFRUN dnf install -y curl \\    &amp;&amp; dnf clean all \\    &amp;&amp; rm -rf \/var\/cache\/dnf<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>3.3. \u041c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u043b\u043e\u0438, \u043d\u043e \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0439\u0442\u0435 Dockerfile \u0432 \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u043c\u043e\u043d\u043e\u043b\u0438\u0442<\/h3>\n<p>\u0421\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0441\u043b\u043e\u0451\u0432 \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0446\u0435\u043b\u044c. \u0415\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0432\u0435\u0441\u044c Dockerfile \u0432 \u043e\u0434\u0438\u043d \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 <code>RUN<\/code>, \u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0443\u0434\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0438 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434:<\/p>\n<ul>\n<li>\n<p>\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0448\u0430\u0433\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0433\u043e\u0434\u043d\u043e \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e builder-\u0441\u0442\u0430\u0434\u0438\u0438, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043a\u0438 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043f\u043e \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0443 \u0434\u043b\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438 \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u0445 diff.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>RUN apt-get update &amp;&amp; apt-get install -y --no-install-recommends \\    ca-certificates \\    curl \\    libpq5 \\    &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/*<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>3.4. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435, \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043b\u0435\u0436\u0438\u0442 \u0432 \u0441\u043b\u043e\u044f\u0445<\/h3>\n<p>\u041d\u0435 \u0434\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u044e, \u0447\u0442\u043e \u0432\u044b \u0443\u0434\u0430\u043b\u0438\u043b\u0438 \u0444\u0430\u0439\u043b. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u043e\u0431\u0440\u0430\u0437.<\/p>\n<p>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"bash\">docker history my-image:tag<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<pre><code class=\"bash\">docker image inspect my-image:tag<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0441\u043b\u043e\u0451\u0432 \u0432\u0440\u043e\u0434\u0435 <code>dive<\/code>. \u041e\u043d\u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u043a\u0430\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u044b \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u043b\u043e\u0435, \u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043d\u0430\u0439\u0442\u0438 \u043c\u0443\u0441\u043e\u0440, \u0441\u0435\u043a\u0440\u0435\u0442\u044b, \u043a\u0435\u0448\u0438 \u0438 \u0442\u044f\u0436\u0451\u043b\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h3>3.5. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 BuildKit<\/h3>\n<p>BuildKit \u2014 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 backend \u0441\u0431\u043e\u0440\u043a\u0438 Docker. \u041e\u043d \u0443\u043c\u0435\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0433\u0440\u0430\u0444 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0442\u044c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u0441\u0442\u0430\u0434\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c cache mounts, secret mounts \u0438 bind mounts.<\/p>\n<p>\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">DOCKER_BUILDKIT=1 docker build -t myapp .<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>docker buildx<\/code>.<\/p>\n<h4>Cache mounts<\/h4>\n<p>BuildKit \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043d\u0435 \u0437\u0430\u043f\u0435\u043a\u0430\u044f \u043a\u0435\u0448 \u0432 \u0441\u043b\u043e\u0439 \u043e\u0431\u0440\u0430\u0437\u0430.<\/p>\n<p>Python:<\/p>\n<pre><code>RUN --mount=type=cache,target=\/root\/.cache\/pip \\    pip install -r requirements.txt<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Node.js:<\/p>\n<pre><code>RUN --mount=type=cache,target=\/root\/.npm \\    npm ci<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Apt:<\/p>\n<pre><code>RUN --mount=type=cache,target=\/var\/cache\/apt,sharing=locked \\    --mount=type=cache,target=\/var\/lib\/apt,sharing=locked \\    apt-get update &amp;&amp; apt-get install -y --no-install-recommends curl<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>Bind mounts \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0441\u0431\u043e\u0440\u043a\u0438<\/h4>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0444\u0430\u0439\u043b \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441\u0431\u043e\u0440\u043a\u0438, \u043d\u043e \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043f\u0430\u0434\u0430\u0442\u044c \u0432 \u043e\u0431\u0440\u0430\u0437. BuildKit \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <code>requirements.txt<\/code> \u0432 runtime-\u0441\u0442\u0430\u0434\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c bind mount:<\/p>\n<pre><code>RUN --mount=type=bind,source=requirements.txt,target=\/tmp\/requirements.txt,readonly \\    --mount=type=cache,target=\/root\/.cache\/pip \\    pip install --no-cache-dir -r \/tmp\/requirements.txt<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043b\u043e\u0451\u0432 \u0438 \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u043e\u0431\u0440\u0430\u0437\u0435.<\/p>\n<h3>3.6. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043a\u0435\u0448 \u0432 CI\/CD \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e<\/h3>\n<p>\u0411\u0435\u0437 \u043a\u0435\u0448\u0430 Docker-\u0441\u0431\u043e\u0440\u043a\u0438 \u0432 CI \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c\u0438. \u041d\u043e \u043a\u0435\u0448 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043b\u043e\u043c\u0430\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0438 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c.<\/p>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 BuildKit\/buildx cache;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>--cache-from<\/code> \u0438 <code>--cache-to<\/code>, \u0435\u0441\u043b\u0438 runner \u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u044b\u0439;<\/p>\n<\/li>\n<li>\n<p>\u043a\u0435\u0448\u0438\u0440\u0443\u0439\u0442\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 <code>--mount=type=cache<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u043a\u0435\u0448\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u044b;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u043f\u043e\u043b\u0430\u0433\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u043a\u0435\u0448 \u043a\u0430\u043a \u043d\u0430 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 security-\u043f\u0430\u0442\u0447\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0447\u0438\u0441\u0442\u0443\u044e \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0443 \u0438 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441 buildx:<\/p>\n<pre><code class=\"bash\">docker buildx build \\  --cache-from=type=registry,ref=registry.example.com\/myapp:buildcache \\  --cache-to=type=registry,ref=registry.example.com\/myapp:buildcache,mode=max \\  -t registry.example.com\/myapp:${GIT_SHA} \\  --push \\  .<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>3.7. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 Podman\/Buildah \u043a\u0430\u043a \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443 Docker \u0432 CI<\/h3>\n<p>\u0412 CI \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u043b\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 Docker-in-Docker. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <code>podman<\/code>\/<code>buildah<\/code>: \u043e\u043d\u0438 \u0443\u043c\u0435\u044e\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437\u044b \u043f\u043e Dockerfile\/Containerfile-\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0443 \u0438 \u0447\u0430\u0441\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043b\u043e\u0436\u0430\u0442\u0441\u044f \u0432 rootless-\u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438.<\/p>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 registry-based cache \u0447\u0435\u0440\u0435\u0437 <code>--cache-from<\/code> \u0438 <code>--cache-to<\/code>. \u0418\u0434\u0435\u044f \u0442\u0430\u043a\u0430\u044f: \u043a\u0435\u0448 \u0441\u043b\u043e\u0451\u0432 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u043d\u0430 \u0440\u0430\u043d\u043d\u0435\u0440\u0435, \u0430 \u0432 registry. \u042d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 CI-runner \u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u044b\u0439 \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 pipeline \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0441 \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f Podman\/Buildah:<\/p>\n<pre><code class=\"bash\">podman build \\  --layers \\  --cache-from registry.example.com\/myapp\/buildcache \\  --cache-to registry.example.com\/myapp\/buildcache \\  -t registry.example.com\/myapp:${GIT_SHA} \\  .<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0435\u0441\u0442\u044c \u0438 \u0432 Docker Buildx\/BuildKit \u0447\u0435\u0440\u0435\u0437 <code>--cache-from<\/code> \u0438 <code>--cache-to<\/code>. \u0414\u043b\u044f CI \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u201cDocker \u0438\u043b\u0438 Podman\u201d, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u043e\u0433\u043e \u043a\u0435\u0448\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0432 registry \u0438 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u0430\u0439\u043f\u043b\u0430\u043d\u0430\u043c\u0438.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 Podman\/Buildah \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0443\u043c\u0435\u0441\u0442\u0435\u043d:<\/p>\n<ul>\n<li>\n<p>\u0432 rootless CI-\u0441\u0431\u043e\u0440\u043a\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c Docker daemon \u0432\u043d\u0443\u0442\u0440\u0438 job;<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u0433\u0434\u0430 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Podman;<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d daemonless-\u043f\u043e\u0434\u0445\u043e\u0434;<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u0433\u0434\u0430 cache \u043d\u0443\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 registry \u0438 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u044b\u043c\u0438 \u0440\u0430\u043d\u043d\u0435\u0440\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<p><a class=\"anchor\" name=\"multistage\" id=\"multistage\"><\/a><\/p>\n<h2>4. Multi-stage build \u0438 \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/h2>\n<p>Multi-stage build \u043e\u0442\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u0440\u0435\u0434\u0443 \u0441\u0431\u043e\u0440\u043a\u0438 \u043e\u0442 \u0441\u0440\u0435\u0434\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430. \u0412 builder-\u0441\u0442\u0430\u0434\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b, SDK, dev-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u0435\u0448\u0438 \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438. \u0412 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u0431\u0440\u0430\u0437\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e runtime \u0438 \u043d\u0443\u0436\u043d\u044b\u0435 \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b.<\/p>\n<p>\u042d\u0442\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u0440\u0430\u0437\u0430, \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c \u0430\u0442\u0430\u043a\u0438 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 runtime-\u043e\u0431\u0440\u0430\u0437 \u0447\u0438\u0449\u0435.<\/p>\n<h3>4.1. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 multi-stage build<\/h3>\n<p>\u041f\u043b\u043e\u0445\u043e:<\/p>\n<pre><code>FROM golang:1.22WORKDIR \/appCOPY . .RUN go build -o app .\/cmd\/appCMD [\".\/app\"]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0430\u043a \u0432 \u043e\u0431\u0440\u0430\u0437\u0435 \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f Go toolchain, \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0438 \u043b\u0438\u0448\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u044b.<\/p>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>FROM golang:1.22 AS builderWORKDIR \/srcCOPY go.mod go.sum .\/RUN go mod downloadCOPY . .RUN CGO_ENABLED=0 GOOS=linux go build -o \/app .\/cmd\/appFROM gcr.io\/distroless\/static-debian12COPY --from=builder \/app \/appUSER nonroot:nonrootENTRYPOINT [\"\/app\"]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Multi-stage \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f:<\/p>\n<ul>\n<li>\n<p>Go, Rust, C\/C++;<\/p>\n<\/li>\n<li>\n<p>Java-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0433\u0434\u0435 build-\u0441\u0442\u0430\u0434\u0438\u044f \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 jar;<\/p>\n<\/li>\n<li>\n<p>Python, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c wheels \u0438\u043b\u0438 venv;<\/p>\n<\/li>\n<li>\n<p>Node.js, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0434\u0435\u043b\u0438\u0442\u044c dev-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 production-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p>frontend-\u0441\u0431\u043e\u0440\u043e\u043a, \u0433\u0434\u0435 Node.js \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<h3>4.2. \u0414\u043b\u044f Python \u0441\u043e\u0431\u0438\u0440\u0430\u0439\u0442\u0435 wheels \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u0435 virtualenv \u0438\u0437 builder-\u0441\u0442\u0430\u0434\u0438\u0438<\/h3>\n<p>\u0412 Python-\u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0443\u0436\u0435\u043d \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0431\u043e\u0440\u043a\u0438, \u043d\u043e \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0432 runtime.<\/p>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 wheel-\u0444\u0430\u0439\u043b\u0430\u043c\u0438:<\/p>\n<pre><code>FROM python:3.12-slim AS builderWORKDIR \/buildRUN apt-get update &amp;&amp; apt-get install -y --no-install-recommends \\    build-essential \\    &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/*COPY requirements.txt .RUN pip wheel --no-cache-dir --wheel-dir \/wheels -r requirements.txtFROM python:3.12-slimWORKDIR \/appCOPY --from=builder \/wheels \/wheelsCOPY requirements.txt .RUN pip install --no-cache-dir --no-index --find-links=\/wheels -r requirements.txt \\    &amp;&amp; rm -rf \/wheelsCOPY . .CMD [\"python\", \"main.py\"]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 virtualenv:<\/p>\n<pre><code>FROM python:3.12-slim AS builderRUN python -m venv \/opt\/venvENV PATH=\"\/opt\/venv\/bin:$PATH\"COPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txtFROM python:3.12-slimENV PATH=\"\/opt\/venv\/bin:$PATH\"COPY --from=builder \/opt\/venv \/opt\/venvWORKDIR \/appCOPY . .CMD [\"python\", \"main.py\"]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Virtualenv \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0443\u0436\u0435 \u0438\u0437\u043e\u043b\u0438\u0440\u0443\u0435\u0442 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435. \u041d\u043e \u0432 multi-stage \u043e\u043d \u0431\u044b\u0432\u0430\u0435\u0442 \u0443\u0434\u043e\u0431\u0435\u043d: \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 builder-\u0441\u0442\u0430\u0434\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0435\u0433\u043e \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u0432 runtime.<\/p>\n<h3>4.3. \u0423\u0441\u043a\u043e\u0440\u044f\u0439\u0442\u0435 Python-\u0441\u0431\u043e\u0440\u043a\u0438 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u043d\u043e \u043d\u0435 \u043b\u043e\u043c\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0441\u0442\u044c<\/h3>\n<p>\u0414\u043b\u044f Python \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>uv<\/code> \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0449\u0438\u043a\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u042d\u0442\u043e \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u0441\u0431\u043e\u0440\u043a\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 CI. \u041d\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u043d\u044f\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430:<\/p>\n<ul>\n<li>\n<p>\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0439\u0442\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 lock-\u0444\u0430\u0439\u043b\u043e\u043c;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043a\u0435\u0448 BuildKit;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u043a\u043b\u0430\u0434\u0438\u0442\u0435 \u043a\u0435\u0448 \u0432 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u0434\u0435\u043b\u044f\u0439\u0442\u0435 build-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 runtime-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u044b \u0438 \u043b\u0438\u0448\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u044b.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0434\u0435\u0438:<\/p>\n<pre><code>RUN --mount=type=cache,target=\/root\/.cache\/uv \\    uv pip install --system -r requirements.txt<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<hr\/>\n<p><a class=\"anchor\" name=\"secrets\" id=\"secrets\"><\/a><\/p>\n<h2>5. \u0421\u0435\u043a\u0440\u0435\u0442\u044b: build-time, runtime \u0438 \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0443\u0442\u0435\u0447\u0435\u043a \u0432 \u0441\u043b\u043e\u044f\u0445<\/h2>\n<p>\u0421\u0435\u043a\u0440\u0435\u0442\u044b \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <code>ENV<\/code>, <code>ARG<\/code>, <code>COPY<\/code>, <code>RUN echo ...<\/code> \u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u0431\u043e\u0440\u043a\u0438.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e:<\/p>\n<pre><code>ARG SSH_PRIVATE_KEYENV API_TOKEN=super-secretCOPY . .<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u043f\u043b\u043e\u0445\u043e:<\/p>\n<ul>\n<li>\n<p>\u0441\u0435\u043a\u0440\u0435\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0441\u043b\u043e\u0439;<\/p>\n<\/li>\n<li>\n<p>\u0441\u0435\u043a\u0440\u0435\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0438\u0434\u0435\u043d \u0447\u0435\u0440\u0435\u0437 <code>docker history<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0447\u0435\u0440\u0435\u0437 inspect\/runtime;<\/p>\n<\/li>\n<li>\n<p>\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0441\u043b\u043e\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0441\u043b\u043e\u044f.<\/p>\n<\/li>\n<\/ul>\n<h3>5.1. BuildKit secrets \u0434\u043b\u044f \u044d\u0442\u0430\u043f\u0430 \u0441\u0431\u043e\u0440\u043a\u0438<\/h3>\n<pre><code>RUN --mount=type=secret,id=npm_token \\    NPM_TOKEN=\"$(cat \/run\/secrets\/npm_token)\" npm ci<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430:<\/p>\n<pre><code class=\"bash\">docker build \\  --secret id=npm_token,src=.npm_token \\  -t myapp .<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u0435\u043a\u0440\u0435\u0442 \u043c\u043e\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e <code>RUN<\/code> \u0438 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u043e\u0439.<\/p>\n<h3>5.2. Runtime secrets<\/h3>\n<p>\u0414\u043b\u044f runtime \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435:<\/p>\n<ul>\n<li>\n<p>Docker secrets;<\/p>\n<\/li>\n<li>\n<p>Kubernetes Secrets;<\/p>\n<\/li>\n<li>\n<p>Secret Manager\/Vault;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0443\u0433\u0440\u043e\u0437;<\/p>\n<\/li>\n<li>\n<p>mounted secret files.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0439\u0442\u0435 <code>.env<\/code>, <code>.aws<\/code>, <code>.ssh<\/code>, \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0447\u0435\u0440\u0435\u0437 <code>.dockerignore<\/code>.<\/p>\n<hr\/>\n<p><a class=\"anchor\" name=\"user-permissions\" id=\"user-permissions\"><\/a><\/p>\n<h2>6. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, UID, \u043f\u0440\u0430\u0432\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430<\/h2>\n<p>\u042d\u0442\u043e\u0442 \u0431\u043b\u043e\u043a \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u043c \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439. \u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0442 root \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043c\u043e\u0433 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 runtime-\u0441\u0440\u0435\u0434\u0430\u0445.<\/p>\n<h3>6.1. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u043e\u0442 root<\/h3>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0447\u0430\u0441\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0442 root. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u043d\u043e \u043f\u043b\u043e\u0445\u043e \u0434\u043b\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043e, root \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0438\u0441\u043a \u044d\u0441\u043a\u0430\u043b\u0430\u0446\u0438\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0440\u0438 volume, Docker socket, capabilities \u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u0441\u044c \u043d\u0430 \u043d\u0435\u0433\u043e:<\/p>\n<pre><code>RUN addgroup --system app &amp;&amp; adduser --system --ingroup app appUSER app<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f Debian\/Ubuntu:<\/p>\n<pre><code>RUN groupadd -r app &amp;&amp; useradd -r -g app -d \/nonexistent -s \/usr\/sbin\/nologin appUSER app<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f Alpine:<\/p>\n<pre><code>RUN addgroup -S app &amp;&amp; adduser -S app -G appUSER app<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 non-root \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0435\u0433\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 Node.js-\u043e\u0431\u0440\u0430\u0437\u0430\u0445 \u0447\u0430\u0441\u0442\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <code>node<\/code>.<\/p>\n<h3>6.2. \u041d\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u0436\u0451\u0441\u0442\u043a\u043e \u043a \u043e\u0434\u043d\u043e\u043c\u0443 UID<\/h3>\n<p>\u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 OpenShift, \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u043c UID. \u0415\u0441\u043b\u0438 Dockerfile \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 UID, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0443\u0436\u043d\u044b\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f\u043c.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e:<\/p>\n<pre><code>RUN mkdir \/app-tmp &amp;&amp; chown -R app:app \/app-tmpUSER appENV TMP_DIR=\/app-tmp<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 runtime \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u0440\u0443\u0433\u0438\u043c UID, \u0437\u0430\u043f\u0438\u0441\u044c \u0432 <code>\/app-tmp<\/code> \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u043e\u043c\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>ENV TMP_DIR=\/tmp<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>\u043f\u0438\u0448\u0438\u0442\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 <code>\/tmp<\/code>, \u0433\u0434\u0435 \u044d\u0442\u043e \u0443\u043c\u0435\u0441\u0442\u043d\u043e;<\/p>\n<\/li>\n<li>\n<p>\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0439\u0442\u0435 \u0432\u043b\u0430\u0434\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u043a \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u043c UID;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u0440\u0435\u0448\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u0440\u0430\u0432 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043e\u0442 root.<\/p>\n<\/li>\n<\/ul>\n<h3>6.3. \u0414\u0435\u043b\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c\u0438 \u0434\u043b\u044f runtime-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/h3>\n<p>\u041d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0435\u043c \u043a\u043e\u0434\u0430. \u0427\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0430\u0432 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d:<\/p>\n<pre><code>COPY --chown=app:app . \/appUSER app<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0432 <code>\/app<\/code>, \u043e\u043d \u0441\u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u043b\u0438 entrypoint-\u0441\u043a\u0440\u0438\u043f\u0442\u044b.<\/p>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>COPY . \/appRUN chmod -R a-w \/app &amp;&amp; chmod +x \/app\/entrypoint.shUSER app<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u0434\u0435\u044f: \u043a\u043e\u0434 \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442 root, runtime-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0438\u0445 \u0447\u0438\u0442\u0430\u0442\u044c\/\u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c, \u043d\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c. \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u044f\u0432\u043d\u043e: <code>\/tmp<\/code>, <code>\/var\/cache\/myapp<\/code>, <code>\/data<\/code> \u0438 \u0442.\u0434.<\/p>\n<h3>6.4. \u0415\u0441\u043b\u0438 \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u043d\u0443\u0436\u043d\u044b root-\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 gosu\/su-exec, \u0430 \u043d\u0435 sudo<\/h3>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 entrypoint \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c root-\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c ownership volume, \u0430 \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>\u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0430\u043c\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 <code>sudo<\/code>. \u041b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>gosu<\/code> \u0438\u043b\u0438 <code>su-exec<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043b\u0438\u0448\u043d\u044e\u044e \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u00ab\u043e\u0434\u0438\u043d \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u00bb.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"bash\">#!\/bin\/shset -eif [ \"$1\" = \"myapp\" ]; then  chown -R app:app \/data  exec gosu app \"$@\"fiexec \"$@\"<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u0430\u0436\u043d\u043e: <code>gosu<\/code> \u2014 \u043d\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u043d\u0430 <code>sudo<\/code>. \u041e\u043d \u0443\u043c\u0435\u0441\u0442\u0435\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u0432 entrypoint-\u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445, \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 root-\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<hr\/>\n<p><a class=\"anchor\" name=\"process-startup\" id=\"process-startup\"><\/a><\/p>\n<h2>7. \u0417\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: CMD, ENTRYPOINT, PID 1, SIGTERM \u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u00ab\u043e\u0434\u0438\u043d \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u2014 \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0438\u0441\u00bb<\/h2>\n<p>\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u043b\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u043c\u0438\u043d\u0438-\u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 \u0432\u043d\u0443\u0442\u0440\u0438.<\/p>\n<h3>7.1. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 exec-\u0444\u043e\u0440\u043c\u0443 CMD \u0438 ENTRYPOINT<\/h3>\n<p>Docker \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0434\u0432\u0435 \u0444\u043e\u0440\u043c\u044b.<\/p>\n<p>Shell-\u0444\u043e\u0440\u043c\u0430:<\/p>\n<pre><code>CMD \"python app.py\"<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Exec-\u0444\u043e\u0440\u043c\u0430:<\/p>\n<pre><code>CMD [\"python\", \"app.py\"]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043b\u0443\u0447\u0448\u0435 exec-\u0444\u043e\u0440\u043c\u0430. \u041f\u0440\u0438 shell-\u0444\u043e\u0440\u043c\u0435 Docker \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 <code>\/bin\/sh -c ...<\/code>, \u0438 shell \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f PID 1. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u044b \u043c\u043e\u0433\u0443\u0442 \u043d\u0435 \u0434\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043c\u0435\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e:<\/p>\n<pre><code>ENTRYPOINT python app.py<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>ENTRYPOINT [\"python\", \"app.py\"]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>7.2. \u041f\u043e\u043d\u0438\u043c\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 CMD \u0438 ENTRYPOINT<\/h3>\n<p><code>ENTRYPOINT<\/code> \u2014 \u044d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u0415\u0451 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c.<\/p>\n<p><code>CMD<\/code> \u2014 \u044d\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0415\u0451 \u043b\u0435\u0433\u043a\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0438 <code>docker run<\/code>.<\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d:<\/p>\n<pre><code>ENTRYPOINT [\"gunicorn\", \"config.wsgi\", \"-b\", \"0.0.0.0:8000\", \"-w\"]CMD [\"4\"]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0443\u0434\u0435\u0442:<\/p>\n<pre><code class=\"bash\">gunicorn config.wsgi -b 0.0.0.0:8000 -w 4<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442:<\/p>\n<pre><code class=\"bash\">docker run myapp 8<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c <code>ENTRYPOINT<\/code> \u0437\u0430\u0434\u0430\u0451\u0442 \u0447\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c, \u0430 <code>CMD<\/code> \u2014 \u0441 \u043a\u0430\u043a\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<h3>7.3. \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0439\u0442\u0435 SIGTERM \u0438 PID 1<\/h3>\n<p>\u0412 Kubernetes \u0438 Docker \u043f\u0440\u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 SIGTERM, \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0441\u043b\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u2014 SIGKILL. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 SIGTERM, \u043e\u043d\u043e \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u043b\u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b.<\/p>\n<p>\u0427\u0430\u0441\u0442\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430:<\/p>\n<pre><code>ENTRYPOINT [\"\/app\/start.sh\"]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410 \u0432\u043d\u0443\u0442\u0440\u0438 <a href=\"http:\/\/start.sh\" rel=\"noopener noreferrer nofollow\"><code>start.sh<\/code><\/a>:<\/p>\n<pre><code class=\"bash\">python app.py<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 shell-\u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f PID 1 \u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u043f\u0440\u043e\u043a\u0438\u043d\u0443\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e.<\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e:<\/p>\n<pre><code class=\"bash\">#!\/bin\/shset -eexec python app.py<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><code>exec<\/code> \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 shell \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f PID 1.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u043d\u0443\u0436\u0435\u043d init-\u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>tini<\/code> \u0438\u043b\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 init, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u0441\u0438\u0433\u043d\u0430\u043b\u044b \u0438 \u0443\u0431\u0438\u0440\u0430\u0435\u0442 zombie-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b.<\/p>\n<h3>7.4. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0439\u0442\u0435 \u043e\u0434\u0438\u043d \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440<\/h3>\n<p>\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430: \u043e\u0434\u0438\u043d web-server, \u043e\u0434\u0438\u043d worker, \u043e\u0434\u0438\u043d database process \u0438 \u0442.\u0434. \u042d\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p>\u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p>healthcheck;<\/p>\n<\/li>\n<li>\n<p>graceful shutdown;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u043b\u0430\u0434\u043a\u0443.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043b\u043e\u0445\u043e: \u043e\u0434\u0438\u043d \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 Nginx, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, cron \u0438 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041b\u0443\u0447\u0448\u0435: \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u0430 \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0442\u044c, volumes, \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u043b\u0438 \u043e\u0440\u043a\u0435\u0441\u0442\u0440\u0430\u0442\u043e\u0440.<\/p>\n<p>\u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0431\u044b\u0432\u0430\u044e\u0442: sidecar-\u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, init-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u0442\u0435\u0441\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b. \u041d\u043e \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0430 \u043d\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0430 \u0437\u0430\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u0432\u0441\u0451 \u0432\u043d\u0443\u0442\u0440\u044c.<\/p>\n<hr\/>\n<p><a class=\"anchor\" name=\"runtime-behavior\" id=\"runtime-behavior\"><\/a><\/p>\n<h2>8. Runtime-\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435: healthcheck, \u043f\u043e\u0440\u0442\u044b, volumes, \u043a\u043e\u043d\u0444\u0438\u0433\u0438, \u043b\u043e\u0433\u0438, \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 Gunicorn<\/h2>\n<p>Dockerfile \u2014 \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u0438. \u041e\u0431\u0440\u0430\u0437 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0436\u0438\u0442\u044c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430, \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f, \u043f\u0438\u0441\u0430\u0442\u044c \u043b\u043e\u0433\u0438 \u043d\u0430\u0440\u0443\u0436\u0443 \u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0434 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438 CPU\/memory.<\/p>\n<h3>8.1. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0439\u0442\u0435 HEALTHCHECK, \u0435\u0441\u043b\u0438 \u043e\u0431\u0440\u0430\u0437 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 Docker\/Docker Swarm<\/h3>\n<p>Docker \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0436\u0438\u0432\u044b\u043c, \u043f\u043e\u043a\u0430 \u0436\u0438\u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u041d\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u043d\u0443\u0442\u044c, \u0443\u0439\u0442\u0438 \u0432 \u0434\u0435\u0434\u043b\u043e\u043a, \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0438\u043b\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c 500.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>HEALTHCHECK --interval=30s --timeout=5s --retries=3 \\  CMD wget -qO- http:\/\/127.0.0.1:8000\/health || exit 1<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u043b\u0438:<\/p>\n<pre><code>HEALTHCHECK CMD curl --fail http:\/\/127.0.0.1:8000\/health || exit 1<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c <code>curl<\/code> \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0434\u0438 healthcheck, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 \u043e\u0431\u0440\u0430\u0437\u0435.<\/p>\n<p>\u0414\u043b\u044f Kubernetes \u043f\u043e\u043c\u043d\u0438\u0442\u0435: Dockerfile <code>HEALTHCHECK<\/code> \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 <code>livenessProbe<\/code>, <code>readinessProbe<\/code> \u0438 <code>startupProbe<\/code>. \u0412 Kubernetes \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043b\u0443\u0447\u0448\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0430\u0445.<\/p>\n<h3>8.2. \u041d\u0435 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0439\u0442\u0435 \u043b\u0438\u0448\u043d\u0438\u0435 \u043f\u043e\u0440\u0442\u044b<\/h3>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0440\u0442 \u2014 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430. \u0412 Dockerfile \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <code>EXPOSE<\/code> \u043d\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u043f\u043e\u0440\u0442 \u043d\u0430\u0440\u0443\u0436\u0443 \u0441\u0430\u043c\u0430 \u043f\u043e \u0441\u0435\u0431\u0435, \u043e\u043d\u0430 \u0441\u043a\u043e\u0440\u0435\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u043e:<\/p>\n<pre><code>EXPOSE 8080<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u043e \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435:<\/p>\n<pre><code class=\"bash\">docker run -p 8080:8080 myapp<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0439\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043f\u043e\u0440\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u044b;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0439\u0442\u0435 SSH \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0439\u0442\u0435 \u043f\u043e\u0440\u0442\u044b \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0431\u0438\u043d\u0434\u0443\u0439\u0442\u0435 \u043d\u0430 <code>127.0.0.1<\/code>, \u0430 \u043d\u0435 \u043d\u0430 \u0432\u0441\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b.<\/p>\n<\/li>\n<\/ul>\n<h3>8.3. \u041e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 volumes \u0438 bind mounts<\/h3>\n<p>Bind mount \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0442\u0435\u0440\u0435\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432 \u043e\u0431\u0440\u0430\u0437\u0435 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c <code>\/app<\/code>, \u0430 \u0432\u044b \u043c\u043e\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0435 \u0442\u0443\u0434\u0430 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <code>\/app<\/code> \u0438\u0437 \u043e\u0431\u0440\u0430\u0437\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u0440\u044b\u0442\u043e.<\/p>\n<p>\u041e\u043f\u0430\u0441\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a:<\/p>\n<pre><code class=\"bash\">docker run -v $(pwd):\/app myapp<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u043b\u043e\u043c\u0430\u0442\u044c \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>\u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u043e\u043c\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432 \u043c\u043e\u043d\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0430 \u043d\u0435 \u0432\u0435\u0441\u044c \u043a\u043e\u0440\u0435\u043d\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0431\u0440\u0430\u0437\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 volume \u043a\u0430\u043a \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u044b \u0431\u0435\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043f\u0440\u0430\u0432;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435, \u0447\u0442\u043e volume \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 root-\u0432\u043b\u0430\u0434\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<h3>8.4. \u041d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0435 environment-specific \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0432 \u043e\u0431\u0440\u0430\u0437\u0435<\/h3>\n<p>\u041e\u0431\u0440\u0430\u0437 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0434\u043b\u044f dev, staging \u0438 production. \u041e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430: \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0441\u0435\u043a\u0440\u0435\u0442\u044b, config maps, mounted config files.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e:<\/p>\n<pre><code>COPY config.prod.yml \/app\/config.yml<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code>COPY config.example.yml \/app\/config.example.yml<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d-\u043a\u043e\u043d\u0444\u0438\u0433 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430 runtime \u0447\u0435\u0440\u0435\u0437 \u043e\u0440\u043a\u0435\u0441\u0442\u0440\u0430\u0442\u043e\u0440.<\/p>\n<h3>8.5. \u041f\u0438\u0448\u0438\u0442\u0435 \u043b\u043e\u0433\u0438 \u0432 stdout\/stderr<\/h3>\n<p>\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043b\u043e\u0433\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0444\u0430\u0439\u043b \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u041b\u043e\u0433\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0434\u0442\u0438 \u0432 stdout\/stderr, \u0447\u0442\u043e\u0431\u044b Docker, Kubernetes \u0438 \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0433\u043b\u0438 \u0438\u0445 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c.<\/p>\n<p>\u041f\u043b\u043e\u0445\u043e:<\/p>\n<pre><code class=\"bash\">myapp --log-file \/var\/log\/myapp.log<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code class=\"bash\">myapp --log-format json<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0418\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>LOG_TO_STDOUT=true<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0424\u0430\u0439\u043b\u044b \u043b\u043e\u0433\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u044e\u0442 \u0440\u043e\u0442\u0430\u0446\u0438\u044e, \u0441\u0431\u043e\u0440 \u0438 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0443.<\/p>\n<h3>8.6. \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0439\u0442\u0435 CPU \u0438 memory \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430<\/h3>\n<p>\u042d\u0442\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c Dockerfile-\u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430, \u043d\u043e \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u0415\u0441\u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443 \u043d\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u043b\u0438\u043c\u0438\u0442\u044b, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0441\u044a\u0435\u0441\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u0438\u043b\u0438 CPU \u0445\u043e\u0441\u0442\u0430 \u0438 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b.<\/p>\n<p>Docker:<\/p>\n<pre><code class=\"bash\">docker run --cpus=2 --memory=512m myapp<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Docker Compose:<\/p>\n<pre><code class=\"yaml\">services:  app:    image: myapp:1.0.0    deploy:      resources:        limits:          cpus: \"2\"          memory: 512M        reservations:          cpus: \"1\"          memory: 256M<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 Kubernetes \u0437\u0430\u0434\u0430\u0432\u0430\u0439\u0442\u0435 <code>resources.requests<\/code> \u0438 <code>resources.limits<\/code>.<\/p>\n<h3>8.7. \u0414\u043b\u044f Gunicorn \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 memory-backed worker temp directory<\/h3>\n<p>Gunicorn heartbeat \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u0415\u0441\u043b\u0438 \u043e\u043d\u0438 \u043b\u0435\u0436\u0430\u0442 \u043d\u0430 \u0434\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0438 \u043f\u043e\u0434\u0432\u0438\u0441\u0430\u043d\u0438\u044f \u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u0432\u0440\u043e\u0434\u0435 <code>os.fchmod<\/code>.<\/p>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430:<\/p>\n<pre><code class=\"bash\">gunicorn --worker-tmp-dir \/dev\/shm config.wsgi -b 0.0.0.0:8000<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f Python web-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u0445.<\/p>\n<hr\/>\n<p><a class=\"anchor\" name=\"supply-chain-ci\" id=\"supply-chain-ci\"><\/a><\/p>\n<h2>9. \u0426\u0435\u043f\u043e\u0447\u043a\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u041f\u041e, registry, \u043f\u043e\u0434\u043f\u0438\u0441\u044c, \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043b\u0438\u043d\u0442\u0438\u043d\u0433, \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 CI\/CD<\/h2>\n<p>\u0414\u0430\u0436\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 Dockerfile \u043d\u0435 \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u0435\u0441\u043b\u0438 \u043e\u0431\u0440\u0430\u0437\u044b \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0438\u0437 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432, \u043d\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f, \u043d\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u043f\u0443\u0448\u0430\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043a <code>latest<\/code>, \u0430 CI \u0438\u043c\u0435\u0435\u0442 \u043b\u0438\u0448\u043d\u0438\u0435 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u0431\u0440\u0430\u0437\u0430 \u0442\u0430\u043a \u0436\u0435 \u0432\u0430\u0436\u043d\u044b, \u043a\u0430\u043a \u0438 \u0441\u0430\u043c Dockerfile.<\/p>\n<h3>9.1. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0439\u0442\u0435 metadata labels<\/h3>\n<p>Labels \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u043e\u0431\u0440\u0430\u0437, \u043a\u0442\u043e \u0435\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442, \u0433\u0434\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438, \u043a\u0430\u043a\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0438 \u043a\u0443\u0434\u0430 \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>LABEL org.opencontainers.image.title=\"myapp\"LABEL org.opencontainers.image.description=\"Example service\"LABEL org.opencontainers.image.version=\"1.2.3\"LABEL org.opencontainers.image.source=\"https:\/\/git.example.com\/team\/myapp\"LABEL org.opencontainers.image.vendor=\"Example Team\"LABEL org.opencontainers.image.licenses=\"MIT\"LABEL securitytxt=\"https:\/\/example.com\/.well-known\/security.txt\"<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u043f\u043e\u043b\u0435\u0437\u0435\u043d <code>security.txt<\/code>: \u043e\u043d \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c, \u043a\u0443\u0434\u0430 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0445 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h3>9.2. \u0425\u0440\u0430\u043d\u0438\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u044b \u0432 \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u043c registry<\/h3>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0434\u0430 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 registry \u0438\u043b\u0438 \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0435 enterprise-\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u0432. \u041f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 Docker Hub \u0443\u0434\u043e\u0431\u0435\u043d, \u043d\u043e \u043d\u0435 \u0432\u0441\u0435 \u043e\u0431\u0440\u0430\u0437\u044b \u0442\u0430\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f.<\/p>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u044b \u0432 private registry;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 push\/pull;<\/p>\n<\/li>\n<li>\n<p>\u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 registry;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u0442\u044f\u043d\u0443\u0442\u044c \u0432 \u043f\u0440\u043e\u0434 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0437\u044b \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a, Dockerfile, \u043f\u043e\u0434\u043f\u0438\u0441\u044c, \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<h3>9.3. \u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u044b<\/h3>\n<p>\u0422\u0435\u0433 \u043e\u0431\u0440\u0430\u0437\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f. Registry \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u043d. MITM-\u0430\u0442\u0430\u043a\u0438 \u0438 \u043f\u043e\u0434\u043c\u0435\u043d\u0430 \u043e\u0431\u0440\u0430\u0437\u0430 \u2014 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0438\u0441\u043a\u0438 \u0434\u043b\u044f \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430: \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0437\u044b \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u043f\u0435\u0440\u0435\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c.<\/p>\n<p>\u0420\u0430\u043d\u044c\u0448\u0435 \u0432 \u044d\u0442\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0447\u0430\u0441\u0442\u043e \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u0438 Docker Content Trust \u0438 Notary v1, \u043d\u043e \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0445 production-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043b\u0443\u0447\u0448\u0435 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432: Sigstore\/Cosign, Notation\/Notary Project, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0432 CI\/CD, registry \u0438\u043b\u0438 Kubernetes admission controller.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441 Cosign:<\/p>\n<pre><code class=\"bash\">IMAGE=\"registry.example.com\/myapp@sha256:&lt;digest&gt;\"cosign sign \"$IMAGE\"cosign verify \"$IMAGE\" \\  --certificate-identity=\"https:\/\/github.com\/org\/repo\/.github\/workflows\/build.yml@refs\/heads\/main\" \\  --certificate-oidc-issuer=\"https:\/\/token.actions.githubusercontent.com\"<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441 Notation:<\/p>\n<pre><code class=\"bash\">IMAGE=\"registry.example.com\/myapp@sha256:&lt;digest&gt;\"notation sign \"$IMAGE\"notation verify \"$IMAGE\"<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u0430\u0436\u043d\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437, \u0430 \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438\u043b\u0438 \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430. \u0418\u043d\u0430\u0447\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u0430 \u043f\u043e \u0441\u0435\u0431\u0435, \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u0449\u0438\u0449\u0430\u0442\u044c \u043f\u0440\u043e\u0434 \u043e\u0442 \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u043e\u0431\u0440\u0430\u0437\u0430.<\/p>\n<h3>9.4. \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0439\u0442\u0435 SBOM \u0438 provenance<\/h3>\n<p>\u0414\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u0430 \u043e\u0431\u0440\u0430\u0437\u0430 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u043e\u0431\u0440\u0430\u0437 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d, \u043d\u043e \u0438 \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u043d\u0435\u0433\u043e \u043f\u043e\u043f\u0430\u043b\u043e \u0438 \u043a\u0430\u043a \u043e\u043d \u0431\u044b\u043b \u0441\u043e\u0431\u0440\u0430\u043d.<\/p>\n<p>SBOM \u2014 \u044d\u0442\u043e Software Bill of Materials, \u0442\u043e \u0435\u0441\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0431\u0440\u0430\u0437\u0430: \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, runtime-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0438. \u041e\u043d \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u044c, \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0435\u0442 \u043b\u0438 \u043d\u043e\u0432\u0430\u044f CVE \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437, \u043a\u0430\u043a\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0438 \u043e\u0442\u043a\u0443\u0434\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0443\u044f\u0437\u0432\u0438\u043c\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442.<\/p>\n<p>Provenance \u2014 \u044d\u0442\u043e \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0441\u0431\u043e\u0440\u043a\u0438: \u0438\u0437 \u043a\u0430\u043a\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f, \u043a\u043e\u043c\u043c\u0438\u0442\u0430, workflow, \u0440\u0430\u043d\u043d\u0435\u0440\u0430, \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u0438 \u0441 \u043a\u0430\u043a\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0431\u044b\u043b \u0441\u043e\u0431\u0440\u0430\u043d \u043e\u0431\u0440\u0430\u0437. \u042d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d \u043e\u0431\u0440\u0430\u0437 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u043d \u0438\u0437 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0430 \u043d\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0432 registry \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0438\u043b\u0438 \u0438\u0437 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441 Docker Buildx:<\/p>\n<pre><code class=\"bash\">docker buildx build \\  --sbom=true \\  --provenance=true \\  -t registry.example.com\/myapp:${GIT_SHA} \\  --push \\  .<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c SBOM \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u043e\u0432\u044b\u0445 \u043e\u0431\u0440\u0430\u0437\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0445\u0440\u0430\u043d\u0438\u0442\u044c SBOM \u0438 provenance \u0440\u044f\u0434\u043e\u043c \u0441 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438\u043b\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u043e\u0440\u043c\u0430\u0442\u044b SPDX \u0438\u043b\u0438 CycloneDX, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c SBOM\/provenance \u0441 \u043f\u043e\u0434\u043f\u0438\u0441\u044c\u044e \u043e\u0431\u0440\u0430\u0437\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c provenance \u0432 CI\/CD \u0438\u043b\u0438 admission policy, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u0430 \u0441\u0442\u0440\u043e\u0433\u0430\u044f \u0437\u0430\u0449\u0438\u0442\u0430 supply chain.<\/p>\n<\/li>\n<\/ul>\n<p>SBOM \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0430 provenance \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u044c. \u041e\u043d\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430: \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u00ab\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0434\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u044d\u0442\u043e\u043c\u0443 \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u0443\u00bb, SBOM \u2014 \u00ab\u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438\u00bb, provenance \u2014 \u00ab\u043a\u0430\u043a \u0438 \u043e\u0442\u043a\u0443\u0434\u0430 \u043e\u043d \u0431\u044b\u043b \u0441\u043e\u0431\u0440\u0430\u043d\u00bb.<\/p>\n<h3>9.5. \u0421\u043a\u0430\u043d\u0438\u0440\u0443\u0439\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u044b \u043d\u0430 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438, \u0441\u0435\u043a\u0440\u0435\u0442\u044b, malware \u0438 misconfiguration<\/h3>\n<p>\u0414\u0430\u0436\u0435 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 Dockerfile \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437 \u0441 \u0443\u044f\u0437\u0432\u0438\u043c\u044b\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u0441\u043b\u043e\u0435\u043c \u0438\u043b\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0447\u0430\u0441\u0442\u044c\u044e CI\/CD.<\/p>\n<p>\u0427\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>CVE \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p>CVE \u0432 language dependencies;<\/p>\n<\/li>\n<li>\n<p>\u0441\u0435\u043a\u0440\u0435\u0442\u044b;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u043f\u0443\u0441\u043a \u043e\u0442 root;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>ADD<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u043f\u043e\u0440\u0442\u044b;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b;<\/p>\n<\/li>\n<li>\n<p>malware, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b: Trivy, Snyk, Clair, Grype, Anchore, Dockle \u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"bash\">trivy image --scanners vuln,secret,misconfig myapp:1.2.3<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0434\u043e push;<\/p>\n<\/li>\n<li>\n<p>\u0432 CI \u043f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0432 registry \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043b\u044f \u0443\u0436\u0435 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0437\u043e\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u043e\u0432\u044b\u0435 CVE \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435.<\/p>\n<\/li>\n<\/ul>\n<h3>9.6. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 Dockerfile linters \u0438 Docker Build Checks<\/h3>\n<p>\u041b\u0438\u043d\u0442\u0435\u0440 \u043b\u043e\u0432\u0438\u0442 \u0442\u0438\u043f\u043e\u0432\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043e\u043d\u0438 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432 \u043f\u0440\u043e\u0434.<\/p>\n<p>\u0421\u0430\u043c\u044b\u0439 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u2014 <code>hadolint<\/code>.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"bash\">hadolint Dockerfile<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u0438\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0433\u0430;<\/p>\n<\/li>\n<li>\n<p>shell-\u0444\u043e\u0440\u043c\u0443 <code>CMD<\/code>\/<code>ENTRYPOINT<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043b\u0438\u0448\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 <code>RUN<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 package manager cache;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0430\u043a\u0435\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 Docker Build Checks. \u042d\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043f\u043e\u0439\u043c\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 Dockerfile \u0435\u0449\u0451 \u0434\u043e \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0437\u0430.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"bash\">docker buildx build --check .<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Build Checks \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u0438\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<ul>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u0432 \u0432 <code>ARG<\/code> \u0438\u043b\u0438 <code>ENV<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043f\u044b\u0442\u043a\u0443 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043a\u043b\u044e\u0447\u0451\u043d \u0447\u0435\u0440\u0435\u0437 <code>.dockerignore<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 <code>ARG<\/code> \u0432 <code>FROM<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0439 \u0438\u043b\u0438 \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p>shell-\u0444\u043e\u0440\u043c\u0443 \u043a\u043e\u043c\u0430\u043d\u0434 \u0442\u0430\u043c, \u0433\u0434\u0435 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JSON\/exec-\u0444\u043e\u0440\u043c\u0443.<\/p>\n<\/li>\n<\/ul>\n<p><code>hadolint<\/code> \u0438 Docker Build Checks \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. \u041b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430: <code>hadolint<\/code> \u043a\u0430\u043a \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043b\u0438\u043d\u0442\u0435\u0440 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u043f\u0440\u0430\u0432\u0438\u043b, \u0430 Build Checks \u2014 \u043a\u0430\u043a \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 Docker\/BuildKit, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u0430\u043c\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0438.<\/p>\n<p>\u041b\u0438\u043d\u0442\u0438\u043d\u0433 Dockerfile \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0448\u0430\u0433\u043e\u043c CI.<\/p>\n<h3>9.7. \u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0439\u0442\u0435 Dockerfile \u0438 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437<\/h3>\n<p>Dockerfile \u043d\u0430\u0434\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u043a\u043e\u0434.<\/p>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a:<\/p>\n<pre><code class=\"bash\">docker build -t myapp:test .docker run --rm myapp:test --versiondocker run --rm myapp:test iddocker run --rm -p 8080:8080 myapp:test<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0427\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 health endpoint;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435 \u043e\u0442 root;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0443\u0436\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0435\u0441\u0442\u044c;<\/p>\n<\/li>\n<li>\n<p>\u043b\u0438\u0448\u043d\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u0432 \u043d\u0435\u0442;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u043a\u0440\u044b\u0442\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u043e\u0440\u0442\u044b;<\/p>\n<\/li>\n<li>\n<p>SIGTERM \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u0440\u0430\u0437 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043b\u0438\u043d\u0442\u0435\u0440 \u0438 \u0441\u043a\u0430\u043d\u0435\u0440.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c container structure tests \u0438\u043b\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<h3>9.8. \u041d\u0435 \u043f\u0443\u0448\u044c\u0442\u0435 \u043e\u0434\u0438\u043d \u0442\u043e\u043b\u044c\u043a\u043e latest \u0432 CI\/CD<\/h3>\n<p>\u0412 CI \u0447\u0430\u0441\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">docker build -t myapp:latest .docker push myapp:latest<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u043f\u043b\u043e\u0445\u043e: \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a\u043e\u0439 \u043a\u043e\u043c\u043c\u0438\u0442 \u0441\u0435\u0439\u0447\u0430\u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 <code>latest<\/code>, \u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043a\u0430\u0442\u0438\u0442\u044c\u0441\u044f.<\/p>\n<p>\u041b\u0443\u0447\u0448\u0435 \u0442\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0435\u0433\u0430\u043c\u0438:<\/p>\n<pre><code class=\"bash\">docker build \\  -t registry.example.com\/myapp:1.2.3 \\  -t registry.example.com\/myapp:git-${GIT_SHA} \\  .<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u0431\u043e\u0435\u0432\u043e\u0439 \u0434\u0435\u043f\u043b\u043e\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 immutable-\u0442\u0435\u0433 \u0438\u043b\u0438 digest, \u0430 \u043d\u0435 \u043d\u0430 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0438\u0439 <code>latest<\/code>.<\/p>\n<h3>9.9. \u0417\u0430\u0449\u0438\u0449\u0430\u0439\u0442\u0435 Docker socket \u0438 Docker TCP API<\/h3>\n<p>\u042d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435 Dockerfile, \u043d\u043e \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. <code>\/var\/run\/docker.sock<\/code> \u0434\u0430\u0451\u0442 \u043f\u043e\u0447\u0442\u0438 root-\u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0445\u043e\u0441\u0442\u0443. \u0415\u0441\u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443 \u0441\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c Docker socket, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0441\u043c\u043e\u0436\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c Docker \u043d\u0430 \u0445\u043e\u0441\u0442\u0435.<\/p>\n<p>\u041e\u043f\u0430\u0441\u043d\u043e:<\/p>\n<pre><code class=\"yaml\">volumes:  - \/var\/run\/docker.sock:\/var\/run\/docker.sock<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435 \u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c Docker socket \u0431\u0435\u0437 \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f \u043a Docker API, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e proxy\/policy-\u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c Docker TCP API \u0431\u0435\u0437 TLS \u0438 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u043d\u0430 <code>\/var\/run\/docker.sock<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c CI jobs \u0441 \u043b\u0438\u0448\u043d\u0438\u043c\u0438 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u044f\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<p><a class=\"anchor\" name=\"examples\" id=\"examples\"><\/a><\/p>\n<h2>10. \u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b Dockerfile<\/h2>\n<p>\u041d\u0438\u0436\u0435 \u0434\u0432\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0433\u0434\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u043a \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0432 \u043e\u0434\u0438\u043d \u0440\u0430\u0431\u043e\u0447\u0438\u0439 Dockerfile: \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430, multi-stage, \u043a\u0435\u0448 BuildKit, non-root, healthcheck, exec-\u0444\u043e\u0440\u043c\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430, \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043b\u0438\u0448\u043d\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0437\u0430\u0449\u0438\u0442\u0430 \u043a\u043e\u0434\u0430 \u043e\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 runtime-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c.<\/p>\n<h3>10.1. \u041f\u0440\u0438\u043c\u0435\u0440 Dockerfile \u0434\u043b\u044f Python API<\/h3>\n<pre><code>FROM python:3.12.13-slim-bookworm AS builderENV PYTHONDONTWRITEBYTECODE=1 \\    PYTHONUNBUFFERED=1WORKDIR \/buildRUN apt-get update &amp;&amp; apt-get install -y --no-install-recommends \\    build-essential \\    &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/*COPY requirements.txt .\/RUN --mount=type=cache,target=\/root\/.cache\/pip \\    pip wheel --wheel-dir \/wheels -r requirements.txtFROM python:3.12.13-slim-bookworm AS runtimeENV PYTHONDONTWRITEBYTECODE=1 \\    PYTHONUNBUFFERED=1WORKDIR \/appRUN groupadd -r app &amp;&amp; useradd -r -g app -d \/nonexistent -s \/usr\/sbin\/nologin appCOPY --from=builder \/wheels \/wheelsCOPY requirements.txt .\/RUN pip install --no-cache-dir --no-index --find-links=\/wheels -r requirements.txt \\    &amp;&amp; rm -rf \/wheelsCOPY . \/appRUN chmod -R a-w \/appUSER appEXPOSE 8000HEALTHCHECK --interval=30s --timeout=5s --retries=3 \\  CMD python -c \"import urllib.request; urllib.request.urlopen('http:\/\/127.0.0.1:8000\/health', timeout=3)\" || exit 1ENTRYPOINT [\"gunicorn\", \"--worker-tmp-dir\", \"\/dev\/shm\", \"app.main:app\", \"-k\", \"uvicorn.workers.UvicornWorker\", \"-b\", \"0.0.0.0:8000\"]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0427\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430;<\/p>\n<\/li>\n<li>\n<p><code>slim<\/code>, \u0430 \u043d\u0435 \u0444\u0443\u043b\u043b \u041e\u0421;<\/p>\n<\/li>\n<li>\n<p>multi-stage;<\/p>\n<\/li>\n<li>\n<p>build-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 runtime;<\/p>\n<\/li>\n<li>\n<p>pip cache \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0441\u043b\u043e\u0439;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u0432\u044f\u0442\u0441\u044f \u0434\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430;<\/p>\n<\/li>\n<li>\n<p>non-root \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c;<\/p>\n<\/li>\n<li>\n<p>exec-\u0444\u043e\u0440\u043c\u0430 <code>ENTRYPOINT<\/code>;<\/p>\n<\/li>\n<li>\n<p>healthcheck;<\/p>\n<\/li>\n<li>\n<p>Gunicorn temp directory \u0432 <code>\/dev\/shm<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u0434 \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c runtime-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.<\/p>\n<\/li>\n<\/ul>\n<h3>10.2. \u041f\u0440\u0438\u043c\u0435\u0440 Dockerfile \u0434\u043b\u044f Node.js<\/h3>\n<pre><code>FROM node:24.16.0-slim AS depsWORKDIR \/appCOPY package.json package-lock.json .\/RUN --mount=type=cache,target=\/root\/.npm \\    npm ci --omit=devFROM node:24.16.0-slim AS runtimeWORKDIR \/appENV NODE_ENV=productionCOPY --from=deps \/app\/node_modules .\/node_modulesCOPY package.json .\/COPY src\/ .\/src\/RUN chmod -R a-w \/appUSER nodeEXPOSE 3000HEALTHCHECK --interval=30s --timeout=5s --retries=3 \\  CMD node -e \"fetch('http:\/\/127.0.0.1:3000\/health').then(r=&gt;process.exit(r.ok?0:1)).catch(()=&gt;process.exit(1))\"CMD [\"node\", \"src\/index.js\"]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0427\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f Node.js;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u0432\u044f\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f npm cache mount;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u0442 <code>latest<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u0442 root;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u0442 shell-\u0444\u043e\u0440\u043c\u044b CMD;<\/p>\n<\/li>\n<li>\n<p>healthcheck \u0431\u0435\u0437 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 curl;<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u043f\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<p><a class=\"anchor\" name=\"conclusion\" id=\"conclusion\"><\/a><\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0425\u043e\u0440\u043e\u0448\u0438\u0439 Dockerfile \u2014 \u044d\u0442\u043e \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 Dockerfile. \u0425\u043e\u0440\u043e\u0448\u0438\u0439 Dockerfile \u2014 \u044d\u0442\u043e \u0442\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439, \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u044b\u0439 \u0438 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u044b\u0439 \u043e\u0431\u0440\u0430\u0437. \u0412 \u043d\u0451\u043c \u043d\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0439, root-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u0432 \u0432 \u0441\u043b\u043e\u044f\u0445 \u0438 \u043c\u0430\u0433\u0438\u0438 \u0432\u0440\u043e\u0434\u0435 <code>ADD<\/code> \u043f\u043e URL. \u041e\u043d \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f, \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0441\u043a\u0430\u043d\u0435\u0440\u044b \u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0432\u0435\u0434\u0451\u0442 \u0441\u0435\u0431\u044f \u0432 CI, staging \u0438 production.<\/p>\n<\/div>\n<p>\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\/1041784\/\">https:\/\/habr.com\/ru\/articles\/1041784\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435\u0421\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439: \u043f\u0440\u0430\u043a\u0442\u0438\u043a \u043c\u043d\u043e\u0433\u043e, \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043d\u0438\u0445 \u0432\u0430\u0436\u043d\u0430 \u043f\u043e-\u0441\u0432\u043e\u0435\u043c\u0443. \u042f \u0441\u043e\u0431\u0440\u0430\u043b \u0435\u0451 \u043a\u0430\u043a \u043d\u0430\u0431\u043e\u0440 best practices: \u043d\u0435 \u0432\u0441\u0435 \u043f\u0443\u043d\u043a\u0442\u044b \u043d\u0443\u0436\u043d\u044b \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0443, \u043d\u043e \u043f\u043e\u0447\u0442\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0443\u043d\u043a\u0442 \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0440\u0435\u0432\u044c\u044e, \u0432 CI \u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0438\u043d\u0446\u0438\u0434\u0435\u043d\u0442\u0430.\u042f \u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0433\u0440\u0435\u0439\u0434\u043e\u0432: \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u0440\u043e\u0434\u0435 COPY . ., latest \u0438 root-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043e \u043f\u0440\u043e\u0434\u043e\u0432\u044b\u0445 \u0442\u0435\u043c \u0432\u0440\u043e\u0434\u0435 BuildKit, \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u0432, SBOM, \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u0438 \u0437\u0430\u0449\u0438\u0442\u044b \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u041f\u041e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f\u0437\u044b\u043a \u043f\u043e\u0434\u0430\u0447\u0438 \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u0441\u0443\u0445\u043e\u0439, \u043f\u0440\u044f\u043c\u043e\u0439 \u0438 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043d\u044b\u0439: \u0431\u0435\u0437 \u0434\u043e\u043b\u0433\u0438\u0445 \u0437\u0430\u0445\u043e\u0434\u043e\u0432, \u0431\u0435\u0437 \u0432\u043e\u0434\u044b \u0438 \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0441\u043a\u0430\u0437\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0440\u0430\u0434\u0438 \u043f\u0435\u0440\u0435\u0441\u043a\u0430\u0437\u0430. \u042f \u0445\u043e\u0442\u0435\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043e\u0431\u0437\u043e\u0440\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e, \u0430 \u0440\u0430\u0431\u043e\u0447\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u043a\u0443, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438, \u0440\u0435\u0432\u044c\u044e \u0438\u043b\u0438 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0435 Dockerfile.\u0427\u0442\u043e\u0431\u044b \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u044b\u043b\u043e \u043b\u0435\u0433\u0447\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u044f \u0440\u0430\u0437\u0431\u0438\u043b \u0435\u0451 \u043d\u0430 \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u044b\u0435 \u0431\u043b\u043e\u043a\u0438. \u041d\u0438\u0436\u0435 \u043e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435: \u043d\u0430\u0436\u0430\u043b\u0438 \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0439 \u043f\u0443\u043d\u043a\u0442 \u2014 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0443.\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435:\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437, \u0432\u0435\u0440\u0441\u0438\u0438 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u0431\u043e\u0440\u043a\u0438, .dockerignore, \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445\u0421\u043b\u043e\u0438, \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 BuildKitMulti-stage build \u0438 \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438\u0421\u0435\u043a\u0440\u0435\u0442\u044b: build-time, runtime \u0438 \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0443\u0442\u0435\u0447\u0435\u043a \u0432 \u0441\u043b\u043e\u044f\u0445\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, UID, \u043f\u0440\u0430\u0432\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u0417\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430: CMD, ENTRYPOINT, PID 1, SIGTERM \u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u00ab\u043e\u0434\u0438\u043d \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u2014 \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0438\u0441\u00bbRuntime-\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435: healthcheck, \u043f\u043e\u0440\u0442\u044b, volumes, \u043a\u043e\u043d\u0444\u0438\u0433\u0438, \u043b\u043e\u0433\u0438, \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 Gunicorn\u0426\u0435\u043f\u043e\u0447\u043a\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u041f\u041e, registry, \u043f\u043e\u0434\u043f\u0438\u0441\u044c, \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043b\u0438\u043d\u0442\u0438\u043d\u0433, \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 CI\/CD\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b Dockerfile\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u0417\u0430\u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u0443\u043c\u0430\u0442\u044c \u043e DockerfileDockerfile \u2014 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u042d\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0443\u0449\u0435\u0439 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d-\u0441\u0440\u0435\u0434\u044b: \u043a\u0430\u043a\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432\u043d\u0443\u0442\u0440\u044c, \u043e\u0442 \u043a\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043a\u0430\u043a\u0438\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u043b\u043e\u044f\u0445, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0431\u0440\u0430\u0437 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 CI\/CD \u0438 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e \u043e\u043d \u043f\u043e\u0432\u0435\u0434\u0451\u0442 \u0441\u0435\u0431\u044f \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0441\u044f\u0446.\u0425\u043e\u0440\u043e\u0448\u0438\u0439 Dockerfile \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0448\u0430\u0442\u044c \u0442\u0440\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e:\u0412\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u2014 \u043e\u0434\u043d\u0430 \u0438 \u0442\u0430 \u0436\u0435 \u0432\u0435\u0440\u0441\u0438\u044f Dockerfile \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u0440\u0430\u0437.\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438 \u0431\u044b\u0441\u0442\u0440\u044b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u2014 \u0432 \u043e\u0431\u0440\u0430\u0437\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e.\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u2014 \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u041f\u041e, \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439, \u043c\u0435\u043d\u044c\u0448\u0435 \u0448\u0430\u043d\u0441\u043e\u0432 \u0443\u0442\u0435\u0447\u043a\u0438 \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u0432 \u0438 \u043f\u0440\u043e\u0449\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439.1. \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437, \u0432\u0435\u0440\u0441\u0438\u0438 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 FROM, \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440, \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u041f\u043b\u043e\u0445\u0430\u044f \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0430 \u2014 \u0431\u0440\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e Ubuntu\/Debian\/CentOS \u00ab\u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439\u00bb, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043a\u0443\u0447\u0443 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u0443\u0442\u0438\u043b\u0438\u0442, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439.\u041f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0441\u0430\u043c\u044b\u0439 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0443\u043c\u0435\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.\u041f\u043b\u043e\u0445\u043e:FROM ubuntu:22.04RUN apt-get update &amp;&amp; apt-get install -y python3 python3-pip curl vim git\u041b\u0443\u0447\u0448\u0435:FROM python:3.12-slim\u0415\u0449\u0451 \u043b\u0443\u0447\u0448\u0435 \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439:FROM gcr.io\/distroless\/python3-debian121.1. \u0412\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u043f\u043e\u0434 \u0437\u0430\u0434\u0430\u0447\u0443\u0414\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Node.js \u0431\u0435\u0440\u0438\u0442\u0435 node, \u0434\u043b\u044f Python \u2014 python, \u0434\u043b\u044f Java \u2014 eclipse-temurin, amazoncorretto \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0439 JDK\/JRE-\u043e\u0431\u0440\u0430\u0437, \u0434\u043b\u044f Nginx \u2014 nginx, \u0434\u043b\u044f PostgreSQL \u2014 postgres.\u0421\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0437\u044b \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 runtime, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u043c \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0443\u043a\u0430\u043c\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u042d\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440, \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u0438\u0448\u043d\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0437 \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435 \u0434\u043b\u044f \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u044f.\u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0447\u0435\u0442\u044b\u0440\u0435 \u0432\u0435\u0449\u0438:\u043e\u0431\u0440\u0430\u0437 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0438\u043b\u0438 \u043e\u0442 \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430;\u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f;\u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 Dockerfile \u0438\u043b\u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u0443\u044e \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0438;\u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u043c, \u043d\u043e \u043d\u0435 \u0446\u0435\u043d\u043e\u0439 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438.1.2. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 slim, alpine, distroless \u0438 scratch \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0430\u043c\u044b\u0439 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439. \u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0435\u0441\u0442\u044c \u0446\u0435\u043d\u0430.slimslim-\u043e\u0431\u0440\u0430\u0437\u044b \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u044b \u043d\u0430 Debian, \u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u0412\u0430\u0436\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u2014 \u0442\u0430\u043c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f glibc, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d\u0438 \u0447\u0430\u0441\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0434\u043b\u044f Python, Java, Node.js \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0441 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438.\u0427\u0430\u0441\u0442\u043e \u044d\u0442\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441:FROM python:3.12-slimalpineAlpine \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439, \u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 musl \u0432\u043c\u0435\u0441\u0442\u043e glibc. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 Python\/C\/C++-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u043b\u044c\u0448\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438\u043d\u0430\u0447\u0435 \u0438\u043b\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432.Alpine \u0445\u043e\u0440\u043e\u0448, \u043a\u043e\u0433\u0434\u0430:\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043e \u043d\u0430 Alpine;\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0435 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0442 \u0441 musl;\u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u0440\u0430\u0437\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u043d.\u041d\u043e Alpine \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u043d \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439.distrolessDistroless-\u043e\u0431\u0440\u0430\u0437\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 runtime \u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043d\u043e \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432: shell, package manager, curl, vim \u0438 \u0442.\u0434. \u042d\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c \u0430\u0442\u0430\u043a\u0438: \u0435\u0441\u043b\u0438 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432\u043d\u0443\u0442\u0440\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u0443 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432.\u041c\u0438\u043d\u0443\u0441 \u2014 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c: \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0439\u0442\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c bash.\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f Go:FROM golang:1.22 AS builderWORKDIR \/srcCOPY go.mod go.sum .\/RUN go mod downloadCOPY . .RUN CGO_ENABLED=0 GOOS=linux go build -o \/app .\/cmd\/appFROM gcr.io\/distroless\/static-debian12COPY &#8212;from=builder \/app \/appUSER nonroot:nonrootENTRYPOINT [&#171;\/app&#187;]scratchscratch \u2014 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0443\u0441\u0442\u043e\u0439 \u043e\u0431\u0440\u0430\u0437. \u041e\u043d \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b shell, libc, \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b, timezone data \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b.FROM scratchCOPY &#8212;from=builder \/app \/appENTRYPOINT [&#171;\/app&#187;]\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 scratch, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u043a\u0430\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u043d\u0443\u0436\u043d\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.1.3. \u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 latest \u0432 productionlatest \u2014 \u044d\u0442\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043f\u0440\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0435\u0433, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439. \u0421\u0435\u0433\u043e\u0434\u043d\u044f node:latest \u043c\u043e\u0436\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043e\u0434\u043d\u0443 \u0432\u0435\u0440\u0441\u0438\u044e Node.js, \u0437\u0430\u0432\u0442\u0440\u0430 \u2014 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e. \u0412 CI\/CD \u044d\u0442\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043b\u043e\u0442\u0435\u0440\u0435\u044e: Dockerfile \u043d\u0435 \u043c\u0435\u043d\u044f\u043b\u0441\u044f, \u0430 \u0441\u0431\u043e\u0440\u043a\u0430 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u0441\u043b\u043e\u043c\u0430\u043b\u0430\u0441\u044c.\u041f\u043b\u043e\u0445\u043e:FROM node:latest\u041b\u0443\u0447\u0448\u0435:FROM node:24.16.0-slim\u0415\u0449\u0451 \u0441\u0442\u0440\u043e\u0436\u0435:FROM node@sha256:&lt;digest&gt;\u0414\u043b\u044f \u043f\u0440\u043e\u0434\u0430 \u043b\u0443\u0447\u0448\u0435 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c:\u0432\u0435\u0440\u0441\u0438\u044e runtime: node:24.16.0, python:3.12.13, golang:1.22.2;\u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u0431\u0440\u0430\u0437\u0430: slim, alpine, bookworm, bullseye;\u043f\u0440\u0438 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u043d\u044b\u0445 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u2014 digest \u0447\u0435\u0440\u0435\u0437 sha256.\u0422\u0435\u0433 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c, digest \u2014 \u043d\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 digest \u0434\u0430\u0451\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c.1.4. \u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0439\u0442\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043e\u0431\u0440\u0430\u0437\u044b \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e, \u0430 \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u041e\u0442\u043a\u0430\u0437 \u043e\u0442 latest \u043d\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f\u00bb. \u041d\u0430\u043e\u0431\u043e\u0440\u043e\u0442: \u043e\u0431\u0440\u0430\u0437\u044b \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c security-\u043f\u0430\u0442\u0447\u0438. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u043c.\u0425\u043e\u0440\u043e\u0448\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f:\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0435\/LTS-\u0432\u0435\u0440\u0441\u0438\u0438;\u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438;\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437\u044b;\u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043d\u0430 CVE;\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c digest \u0438\u043b\u0438 \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.\u041f\u043b\u043e\u0445\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f:FROM python:latest\u0425\u043e\u0440\u043e\u0448\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f:FROM python:3.12.13-slim-bookworm\u0410 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0434\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e patch-\u0440\u0435\u043b\u0438\u0437\u0430 \u0438\u043b\u0438 \u043d\u043e\u0432\u043e\u0433\u043e digest, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u0438 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c.1.5. \u041d\u0435 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 upgrade \u0432\u0441\u0435\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432\u041a\u043e\u043c\u0430\u043d\u0434\u044b \u0432\u0440\u043e\u0434\u0435 apt-get upgrade, yum update, apk upgrade \u0432\u043d\u0443\u0442\u0440\u0438 Dockerfile \u0447\u0430\u0441\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u0441\u0431\u043e\u0440\u043a\u0443 \u043c\u0435\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0439. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043e\u043d\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u044f\u0442 \u043e\u0434\u0438\u043d \u043d\u0430\u0431\u043e\u0440 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u0437\u0430\u0432\u0442\u0440\u0430 \u2014 \u0434\u0440\u0443\u0433\u043e\u0439. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0438\u0441\u044c SCA\/\u0441\u043a\u0430\u043d\u0435\u0440\u0430\u043c\u0438.\u0420\u0435\u0447\u044c \u043d\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e security-\u043f\u0430\u0442\u0447\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b. \u041d\u0443\u0436\u043d\u044b. \u041d\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430, \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0443 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435, \u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 apt-get upgrade \u0432 \u043a\u0430\u0436\u0434\u043e\u043c build \u0431\u0435\u0437 \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.\u041f\u043b\u043e\u0445\u043e:RUN apt-get update &amp;&amp; apt-get upgrade -y\u041b\u0443\u0447\u0448\u0435:RUN apt-get update &amp;&amp; apt-get install -y &#8212;no-install-recommends \\    ca-certificates \\    curl \\    &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/*\u0412 \u0441\u0440\u0435\u0434\u0430\u0445 \u0441 \u0436\u0451\u0441\u0442\u043a\u0438\u043c\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0439\u0442\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0430\u043a\u0435\u0442\u043e\u0432:RUN apt-get update &amp;&amp; apt-get install -y &#8212;no-install-recommends \\    cowsay=3.03+dfsg1-6 \\    &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/*\u0415\u0441\u043b\u0438 \u043f\u0430\u043a\u0435\u0442 \u0442\u044f\u043d\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c, \u0435\u0451 \u0442\u043e\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439.1.6. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0439\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b\u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u2014 \u044d\u0442\u043e:\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440;\u043d\u043e\u0432\u044b\u0435 CVE;\u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0441\u0431\u043e\u0440\u043a\u0443 \u0438 pull\/push;\u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a.\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0432 runtime-\u043e\u0431\u0440\u0430\u0437 vim, git, gcc, make, curl, wget, bash, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0435\u0437 \u043d\u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.\u0414\u043b\u044f Debian\/Ubuntu \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435:RUN apt-get update &amp;&amp; apt-get install -y &#8212;no-install-recommends \\    ca-certificates \\    &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/*&#8212;no-install-recommends \u043d\u0435 \u0434\u0430\u0451\u0442 \u043f\u0430\u043a\u0435\u0442\u043d\u043e\u043c\u0443 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0443 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0435, \u043d\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.2. Build context, .dockerignore, \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445\u042d\u0442\u043e\u0442 \u0431\u043b\u043e\u043a \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0432\u0441\u0451, \u0447\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u043e\u0431\u0440\u0430\u0437 \u0438\u0437\u0432\u043d\u0435: \u0444\u0430\u0439\u043b\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0430\u0440\u0445\u0438\u0432\u044b, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0432\u043d\u0435\u0448\u043d\u0438\u0435 URL, \u0441\u0435\u043a\u0440\u0435\u0442\u044b \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u0432\u044b\u0431\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 COPY \u0438 ADD. \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f: \u0432 \u043e\u0431\u0440\u0430\u0437 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e, \u0438\u0437 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c.2.1. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 .dockerignoreDocker \u043f\u0435\u0440\u0435\u0434 \u0441\u0431\u043e\u0440\u043a\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u0431\u043e\u0440\u043a\u0438 \u0434\u0435\u043c\u043e\u043d\u0443. \u0415\u0441\u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u2014 \u044d\u0442\u043e \u043a\u043e\u0440\u0435\u043d\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0442\u0443\u0434\u0430 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043f\u0430\u0441\u0442\u044c .git, node_modules, .env, \u043a\u043b\u044e\u0447\u0438, \u043b\u043e\u0433\u0438, \u043a\u0435\u0448\u0438, \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u044b \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 IDE..dockerignore \u0440\u0435\u0448\u0430\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447:\u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u0431\u043e\u0440\u043a\u0438;\u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u0441\u0431\u043e\u0440\u043a\u0443;\u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0440\u0438\u0441\u043a \u0443\u0442\u0435\u0447\u043a\u0438 \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u0432;\u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043b\u0438\u0448\u043d\u044e\u044e \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043a\u0435\u0448\u0430;\u043d\u0435 \u0434\u0430\u0451\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0443\u0441\u043e\u0440 \u0432 \u043e\u0431\u0440\u0430\u0437.\u041f\u0440\u0438\u043c\u0435\u0440 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e .dockerignore:.git.gitignore.vscode\/.idea\/.env.env.**.log__pycache__\/*.pycnode_modules\/coverage\/dist\/build\/.cache\/.DS_Store.aws\/.ssh\/\u0414\u043b\u044f Go\/Java\/\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0447\u0430\u0441\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c allowlist-\u043f\u043e\u0434\u0445\u043e\u0434: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0451, \u0430 \u043f\u043e\u0442\u043e\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u043e\u0435.*!go.mod!go.sum!cmd\/!internal\/!pkg\/\u041d\u043e \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u043d\u0443\u0442\u044c: .dockerignore \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u044f\u0437\u044b\u043a\u0443 \u0438 \u0441\u0431\u043e\u0440\u043a\u0435. \u0415\u0441\u043b\u0438 Java-\u043e\u0431\u0440\u0430\u0437\u0443 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0439 .jar, \u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0433\u043e, \u0430 \u043d\u0435 \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0435\u043a\u0442.2.2. \u041d\u0435 \u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438\u0410\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d:COPY . .\u0418\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u0447\u0430\u0441\u0442\u043e \u044d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0448\u0438\u0440\u043e\u043a\u043e. \u0422\u0430\u043a\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0451, \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0432 build context \u043f\u043e\u0441\u043b\u0435 .dockerignore. \u0415\u0441\u043b\u0438 .dockerignore \u043d\u0435\u043f\u043e\u043b\u043d\u044b\u0439, \u0432 \u043e\u0431\u0440\u0430\u0437 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u043b\u0438\u0448\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u044b.\u041b\u0443\u0447\u0448\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044f\u0432\u043d\u043e:COPY&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-481773","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/481773","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=481773"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/481773\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=481773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=481773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=481773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}