{"id":404672,"date":"2024-06-29T17:51:17","date_gmt":"2024-06-29T17:51:17","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=404672"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=404672","title":{"rendered":"<span>Docker: \u0437\u0430\u043c\u0435\u0442\u043a\u0438 \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u0418\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/b7\/dj\/ot\/b7djotv_rf_w4fh7wxkpeykxj6g.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/b7\/dj\/ot\/b7djotv_rf_w4fh7wxkpeykxj6g.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e (\u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e) \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u0437\u0430\u043c\u0435\u0442\u043a\u0430\u043c\u0438 \u043e <a href=\"https:\/\/www.docker.com\/\"><code>Docker<\/code><\/a>.<\/p>\n<p>  <\/p>\n<p>\u0417\u0430\u043c\u0435\u0442\u043a\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0438\u0437 4 \u0447\u0430\u0441\u0442\u0435\u0439: 2 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438 2 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/595687\/\">\u043f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a> \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 <code>Docker<\/code>, <code>Docker CLI<\/code> \u0438 <code>Dockerfile<\/code>;<\/li>\n<li>\u0432\u043e <a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/597613\/\">\u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e <code>Docker Compose<\/code>;<\/li>\n<li>\u0432 <a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/650969\/\">\u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432: \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043d\u0430 <a href=\"https:\/\/ru.reactjs.org\/\">React<\/a>, \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u043d\u0430 <a href=\"https:\/\/vuejs.org\/\">Vue<\/a> \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 <a href=\"https:\/\/expressjs.com\/ru\/\">Express<\/a>, \u0438 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 <a href=\"https:\/\/www.postgresql.org\/\">PostgreSQL<\/a>, \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/www.prisma.io\/\">Prisma<\/a>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b &#171;\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u0443\u0435\u043c&#187; \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/harryheman\/docker-test\">\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043a\u043e\u0434\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u044f \u0431\u044b \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439.<\/p>\n<p>  <\/p>\n<p>\u041a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/harryheman\/docker-test.git  cd docker-test  cd client yarn # or npm i  cd ..\/admin yarn  cd ..\/api yarn  cd .. yarn yarn dev # or npm run dev<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 <a href=\"https:\/\/www.npmjs.com\/\">npm<\/a>, \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>package.json<\/code> \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">\"scripts\": {   \"dev:client\": \"npm run start --prefix services\/client\",   \"dev:admin\": \"npm run dev --prefix services\/admin\",   \"dev:api\": \"npm run dev --prefix services\/api\",   \"dev\": \"concurrently \\\"npm run dev:client\\\" \\\"npm run dev:admin\\\" \\\"npm run dev:api\\\"\" }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"dockerfile\">Dockerfile<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f <code>Dockerfile<\/code> \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>client<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b <code>Dockerfile<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f `Node.js` ARG NODE_VERSION=16.13.1  # \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 FROM node:$NODE_VERSION  # \u0440\u0430\u0431\u043e\u0447\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f WORKDIR \/client  # \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u0440\u0430\u0431\u043e\u0447\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e COPY package.json yarn.lock .\/  # \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 RUN yarn  # \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b COPY . .  # \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u0431\u043e\u0440\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f RUN yarn build<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0431\u043e\u0440\u043a\u0438 (<code>RUN yarn build<\/code>) \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>start<\/code> \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438: <code>CMD [\"yarn\", \"start\"]<\/code>, \u043d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0442\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0435\u043c, \u0442\u043e \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 <code>Dockerfile<\/code> \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d\u0430. \u041f\u0440\u043e\u0449\u0435 \u0441\u0440\u0430\u0437\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e <code>Dockerfile<\/code>, \u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>start<\/code> \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u0437 <code>docker-compose.yml<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0439 <code>Dockerfile<\/code> \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>admin<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">ARG NODE_VERSION=16.13.1  FROM node:$NODE_VERSION as build  WORKDIR \/admin  COPY package.json yarn.lock .\/  RUN yarn  COPY . .  RUN yarn build<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u0441\u0431\u043e\u0440\u043a\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>client\/build<\/code>, \u0430 \u0441\u0431\u043e\u0440\u043a\u0430 \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u2014 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>admin\/dist<\/code>. \u0412 \u0444\u0430\u0439\u043b\u0435 <code>api\/index.js<\/code> \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">if (process.env.ENV === 'production') {   const clientBuildPath = join(__dirname, 'client', 'build')   const adminDistPath = join(__dirname, 'admin', 'dist')    app.use(express.static(clientBuildPath))   app.use(express.static(adminDistPath))   app.use('\/admin', (req, res) => {     res.sendFile(join(adminDistPath, decodeURIComponent(req.url)))   }) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u043d\u0430\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 (<code>process.env.ENV === 'production'<\/code>), \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439: \u043a\u043b\u0438\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0443 (\u0440\u043e\u0443\u0442\u0443) <code>\/<\/code>, \u0430 \u0430\u0434\u043c\u0438\u043d\u043a\u0430 \u2014 \u043f\u043e \u0440\u043e\u0443\u0442\u0443 <code>\/admin<\/code>. \u041c\u044b \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u0445\u043e\u0436\u0438\u0439 <code>Dockerfile<\/code> \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>api<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">ARG NODE_VERSION=16.13.1  FROM node:$NODE_VERSION  WORKDIR \/app  COPY package.json yarn.lock .\/  RUN yarn  COPY . .  # \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u0440\u0442 EXPOSE 5000  # \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 CMD [\"yarn\", \"start\"]<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <code>EXPOSE 5000<\/code> \u0438 <code>CMD [\"yarn\", \"start\"]<\/code> \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u043d\u043e \u043e\u043d\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u043d\u0430\u043c \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d\u0435. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u0435-\u0447\u0442\u043e \u0435\u0449\u0435, \u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043f\u043e\u043a\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043d\u0442\u0440\u0438\u0433\u0443.<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 <em>\u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>, \u0447\u0442\u043e \u044f \u0432\u043d\u0435\u0441 \u043f\u0430\u0440\u043e\u0447\u043a\u0443 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442:<\/p>\n<p>  <\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 <code>.env<\/code>, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\"># \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f APP_NAME=my-app  # \u0443\u0442\u043e\u0447\u043d\u0438\u043b \u0432\u0435\u0440\u0441\u0438\u044e `Node.js` NODE_VERSION=16.13.1  POSTGRES_VERSION=14 POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_DB=mydb  # \u043f\u0435\u0440\u0435\u043d\u0435\u0441 \u0441\u044e\u0434\u0430 \u043f\u0443\u0442\u044c \u043a \u0411\u0414 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 `api\/.env` # \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e `localhost` \u043f\u043e\u0441\u043b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 `@` \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 -  `postgres` DATABASE_URL=postgresql:\/\/postgres:postgres@postgres:5432\/mydb?schema=public  ENV=development<\/code><\/pre>\n<p>  <\/li>\n<li>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 (\u0444\u0430\u0439\u043b <code>api\/package.json<\/code>, \u0440\u0430\u0437\u0434\u0435\u043b <code>scripts<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">\"dev\": \"prisma migrate dev &amp;&amp; prisma db seed &amp;&amp; nodemon\",<\/code><\/pre>\n<p>  <\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0437 \u043e\u0431\u0440\u0430\u0437\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>.dockerignore<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">node_modules yarn-error.log # mac .DS_Store<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f <code>Dockerfile<\/code> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043a &#171;\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438&#187; \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<h2 id=\"docker-compose\">Docker Compose<\/h2>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0444\u0430\u0439\u043b <code>docker-compose.dev.yml<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># \u0432\u0435\u0440\u0441\u0438\u044f `compose` version: '3.9' # \u0441\u0435\u0440\u0432\u0438\u0441\u044b services:   # \u0411\u0414   postgres:     # \u0444\u0430\u0439\u043b, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u044b \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f     env_file: .env     # \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430     container_name: ${APP_NAME}_postgres     # \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u0440\u0430\u0437     image: postgres:${POSTGRES_VERSION}     # \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u043e\u043c \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445     volumes:       - data_postgres:\/var\/lib\/postgresql\/data     # \u043f\u043e\u0440\u0442 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0411\u0414     ports:       - 5432:5432     # \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430     restart: on-failure    client:     env_file: .env     container_name: ${APP_NAME}_client     image: node:${NODE_VERSION}     # \u0440\u0430\u0431\u043e\u0447\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f     working_dir: \/app     # \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0439 \u0442\u043e\u043c     # `rw` \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 `read\/write` - \u0447\u0442\u0435\u043d\u0438\u0435\/\u0437\u0430\u043f\u0438\u0441\u044c     volumes:       - .\/services\/client:\/app:rw     # \u0441\u0435\u0440\u0432\u0438\u0441, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430     depends_on:       - api     ports:       - 3000:3000     restart: on-failure     # \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438     command: bash -c \"yarn start\"    admin:     env_file: .env     container_name: ${APP_NAME}_admin     image: node:${NODE_VERSION}     working_dir: \/app     volumes:       - .\/services\/admin:\/app:rw     depends_on:       - api     ports:       - 4000:4000     restart: on-failure     command: bash -c \"yarn dev\"    api:     env_file: .env     container_name: ${APP_NAME}_api     # \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 `Dockerfile`, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0431\u043e\u0440\u043a\u0430     build: services\/api     ports:       - 5000:5000     depends_on:       - postgres     restart: on-failure     # \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b `yarn start`, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0432 `Dockerfile`     command: bash -c \"yarn dev\"  # \u0442\u043e\u043c\u0430 volumes:   data_postgres:<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0432 <code>package.json<\/code> \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f <code>compose<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">\"dev:compose:up\": \"docker compose -f docker-compose.dev.yml up -d\", \"dev:compose:stop\": \"docker compose -f docker-compose.dev.yml stop\", \"dev:compose:rm\": \"docker compose -f docker-compose.dev.yml rm\", \"compose:up\": \"docker compose up -d\", \"compose:stop\": \"docker compose stop\", \"compose:rm\": \"docker compose rm\"<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 <code>compose:up<\/code> \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>compose:stop<\/code> \u2014 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442, \u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>compose:rm<\/code> \u2014 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0441\u0435\u0440\u0432\u0438\u0441. \u041f\u0440\u0435\u0444\u0438\u043a\u0441 <code>dev:<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0447\u0442\u043e \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f\/\u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f\/\u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <code>compose<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0444\u0430\u0439\u043b <code>docker-compose.yml<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u043f\u043e\u0437\u0436\u0435).<\/p>\n<p>  <\/p>\n<p>\u0415\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 <code>compose<\/code> \u043f\u0440\u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\"># \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 docker ps  # \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 docker compose ls  # \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u0440\u0430\u0437\u043e\u0432 docker images  # \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u0430 # [image-name] - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u0430 docker image rm [image-name] # \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 docker image rm docker-test_api  # \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u043e\u043c\u043e\u0432 docker volume ls  # \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043c\u0430 # [volume-name] - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u043e\u043c\u0430 docker volume rm [volume-name] # \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 docker volume rm postgres_data  # \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b (\u0442\u043e\u043c\u0430 \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f) docker system prune -a<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>yarn dev:compose:up<\/code> \u0438\u043b\u0438 <code>npm run dev:compose:up<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/8v\/nn\/wd\/8vnnwdtoonf8r4shpr79a7zp7iu.png\" data-src=\"https:\/\/habrastorage.org\/webt\/8v\/nn\/wd\/8vnnwdtoonf8r4shpr79a7zp7iu.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/nk\/le\/j2\/nklej2vgp4nc9q-bhy5nbhesjli.png\" data-src=\"https:\/\/habrastorage.org\/webt\/nk\/le\/j2\/nklej2vgp4nc9q-bhy5nbhesjli.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0430\u0434\u0440\u0435\u0441\u0430\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043a\u043b\u0438\u0435\u043d\u0442: <code>localhost:3000<\/code>;<\/li>\n<li>\u0430\u0434\u043c\u0438\u043d\u043a\u0430: <code>localhost:4000<\/code>;<\/li>\n<li>\u0441\u0435\u0440\u0432\u0435\u0440: <code>localhost:5000<\/code> (\u043d\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430; \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0430\u0434\u043c\u0438\u043d\u043a\u0438);<\/li>\n<li>\u0411\u0414: <code>postgres:5432<\/code> (\u043d\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430; \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430).<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>dev:compose:up<\/code> \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>dev<\/code> + \u0441\u043a\u0440\u0438\u043f\u0442 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 <code>db<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0427\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438? \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u044e \u0441\u0442\u0430\u0442\u0438\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043b \u0441\u0435\u0440\u0432\u0435\u0440, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c <code>api<\/code> \u0441\u0431\u043e\u0440\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0430\u0434\u043c\u0438\u043d\u043a\u0438. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <a href=\"https:\/\/hub.docker.com\/\">Docker Hub<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0430\u043a\u043a\u0430\u0443\u043d\u0442.<\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e <code>client<\/code> \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0437 \u0441 \u0442\u0435\u0433\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">cd client # [username] - \u0432\u0430\u0448 \u043b\u043e\u0433\u0438\u043d \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430 \u0432 dockerhub # \u0442\u0435\u0433 \u043e\u0431\u0440\u0430\u0437\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u0448\u0435\u0433\u043e \u043b\u043e\u0433\u0438\u043d\u0430 docker build . -t [username]\/docker-test_client # \u043c\u043e\u0439 \u043b\u043e\u0433\u0438\u043d - aio350 docker build . -t aio350\/docker-test_client<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0443\u0435\u043c\u0441\u044f \u0432 <code>dockerhub<\/code> \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0437 \u0432 \u0441\u0432\u043e\u0439 \u0440\u0435\u0435\u0441\u0442\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">docker login  docker push aio350\/docker-test_client<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">cd admin  docker build . -t aio350\/docker-test_admin  docker push aio350\/docker-test_admin<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432 \u0441\u0432\u043e\u0435\u043c \u0440\u0435\u0435\u0441\u0442\u0440\u0435 <code>dockerhub<\/code> \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/nk\/8k\/qw\/nk8kqwzyg2atkg7znuf9maep9pe.png\" data-src=\"https:\/\/habrastorage.org\/webt\/nk\/8k\/qw\/nk8kqwzyg2atkg7znuf9maep9pe.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b <code>api\/Dockerfile<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">ARG NODE_VERSION=16.13.1  # \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0437 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438\u0437 `dockerhub` # `AS` \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u0442 \u0441\u043b\u043e\u0439 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u0445 FROM aio350\/docker-test_client AS client # \u043e\u0431\u0440\u0430\u0437 \u0430\u0434\u043c\u0438\u043d\u043a\u0438 FROM aio350\/docker-test_admin AS admin  FROM node:$NODE_VERSION  WORKDIR \/app  COPY package.json yarn.lock .\/  RUN yarn  COPY . .  # \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0441\u0431\u043e\u0440\u043a\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 COPY --from=client \/client\/build \/app\/client\/build # \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0441\u0431\u043e\u0440\u043a\u0443 \u0430\u0434\u043c\u0438\u043d\u043a\u0438 COPY --from=admin \/admin\/dist \/app\/admin\/dist  EXPOSE 5000  CMD [\"yarn\", \"start\"]<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0444\u0430\u0439\u043b <code>docker-compose.yml<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">version: '3.9' services:   postgres:     env_file: .env     container_name: ${APP_NAME}_postgres     image: postgres:${POSTGRES_VERSION}     volumes:       - data_postgres:\/var\/lib\/postgresql\/data     ports:       - 5432:5432     restart: on-failure   # \u0441\u0442\u0430\u0442\u0438\u043a\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c   # \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u044b `client` \u0438 `admin`   api:     env_file: .env     # \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e `ENV`, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0432 \u0444\u0430\u0439\u043b\u0435 `.env`     environment:       - ENV=production     container_name: ${APP_NAME}_api     build: services\/api     depends_on:       - postgres     ports:       - 5000:5000     restart: on-failure     # \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 `yarn start`, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0430\u044f \u0432 `Dockerfile`  volumes:   data_postgres:<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0437 <code>docker-test_api<\/code>, \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0442\u043e\u043c <code>docker-test_data_postgres<\/code> \u0438 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">yarn dev:compose:stop yarn dev:compose:rm  # \u0434\u043b\u044f \u0447\u0438\u0441\u0442\u043e\u0442\u044b \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 docker image rm docker-test_api  docker volume rm docker-test_data_postgres  yarn compose:up<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/kb\/cb\/bu\/kbcbbu9_p16qtrzv6ejbvlg7jpy.png\" data-src=\"https:\/\/habrastorage.org\/webt\/kb\/cb\/bu\/kbcbbu9_p16qtrzv6ejbvlg7jpy.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0438\u0441 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432\u0441\u0435\u0433\u043e \u0438\u0437 2 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041a\u043b\u0438\u0435\u043d\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443: <code>localhost:5000<\/code>, \u0430 \u0430\u0434\u043c\u0438\u043d\u043a\u0430 \u2014 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>localhost:5000\/admin<\/code>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/v4\/_1\/71\/v4_171hi0yhfqv-jhmhbyjbhqo8.png\" data-src=\"https:\/\/habrastorage.org\/webt\/v4\/_1\/71\/v4_171hi0yhfqv-jhmhbyjbhqo8.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/2r\/jy\/bh\/2rjybhdepx7ozyifsuvdyi9-udk.png\" data-src=\"https:\/\/habrastorage.org\/webt\/2r\/jy\/bh\/2rjybhdepx7ozyifsuvdyi9-udk.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c &#171;\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e&#187; \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e\u0439.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/CI\/CD\">CI\/CD<\/a>, \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u0430\u043a <code>GitLab CI\/CD<\/code> \u0438\u043b\u0438 <code>GitHub Actions<\/code>, \u0442\u043e, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u044d\u0442\u043e \u0442\u0435\u043c\u0430 \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u044d\u0442\u043e \u0432\u0441\u0435, \u0447\u0442\u043e \u044f \u0445\u043e\u0442\u0435\u043b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u043e <code>Docker<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438 happy coding!<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p><a href=\"https:\/\/cloud.timeweb.com\/vds-promo-1-rub?utm_source=habr&amp;utm_medium=banner&amp;utm_campaign=vds-promo-1-rub\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/st\/f9\/ui\/stf9uiznc_h9q5qyjl2fw7sx0m0.png\" data-src=\"https:\/\/habrastorage.org\/webt\/st\/f9\/ui\/stf9uiznc_h9q5qyjl2fw7sx0m0.png\"\/><\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/657361\/\"> https:\/\/habr.com\/ru\/articles\/657361\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/b7\/dj\/ot\/b7djotv_rf_w4fh7wxkpeykxj6g.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/b7\/dj\/ot\/b7djotv_rf_w4fh7wxkpeykxj6g.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e (\u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e) \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u0437\u0430\u043c\u0435\u0442\u043a\u0430\u043c\u0438 \u043e <a href=\"https:\/\/www.docker.com\/\"><code>Docker<\/code><\/a>.<\/p>\n<p>  <\/p>\n<p>\u0417\u0430\u043c\u0435\u0442\u043a\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0438\u0437 4 \u0447\u0430\u0441\u0442\u0435\u0439: 2 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438 2 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/595687\/\">\u043f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a> \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 <code>Docker<\/code>, <code>Docker CLI<\/code> \u0438 <code>Dockerfile<\/code>;<\/li>\n<li>\u0432\u043e <a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/597613\/\">\u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e <code>Docker Compose<\/code>;<\/li>\n<li>\u0432 <a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/650969\/\">\u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432: \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043d\u0430 <a href=\"https:\/\/ru.reactjs.org\/\">React<\/a>, \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u043d\u0430 <a href=\"https:\/\/vuejs.org\/\">Vue<\/a> \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 <a href=\"https:\/\/expressjs.com\/ru\/\">Express<\/a>, \u0438 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 <a href=\"https:\/\/www.postgresql.org\/\">PostgreSQL<\/a>, \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/www.prisma.io\/\">Prisma<\/a>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b &#171;\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0438\u0437\u0443\u0435\u043c&#187; \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/harryheman\/docker-test\">\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043a\u043e\u0434\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-404672","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/404672","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=404672"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/404672\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=404672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=404672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=404672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}