{"id":304411,"date":"2020-05-28T15:00:25","date_gmt":"2020-05-28T15:00:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=304411"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=304411","title":{"rendered":"\u0414\u0435\u043f\u043b\u043e\u0439 Docker Image \u043d\u0430 Dokku \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ansible"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/504236\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fs\/hp\/gp\/fshpgpmnrptvl-lyxypvmmkwb9a.jpeg\" alt=\"image\"><\/p>\n<p>  <\/p>\n<h2 id=\"prolog\">\u041f\u0440\u043e\u043b\u043e\u0433<\/h2>\n<p>  <\/p>\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0443\u0437\u043d\u0430\u043b \u043e &quot;\u043a\u0430\u0440\u043c\u0430\u043d\u043d\u043e\u043c&quot; PaaS \u043f\u043e\u0445\u043e\u0436\u0435\u043c \u043d\u0430 Heroku \u0441 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u2014 Dokku. \u041e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0438 vhost \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0441\u0432\u043e\u0438 docker \u043e\u0431\u0440\u0430\u0437\u044b \u043d\u0430 Dokku. \u041f\u0440\u0430\u0432\u0434\u0430, \u044f \u0431\u044b\u043b \u0440\u0430\u0437\u043e\u0447\u0430\u0440\u043e\u0432\u0430\u043d \u0442\u0435\u043c, \u0447\u0442\u043e \u0432 Dokku \u043d\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 Heroku <\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">dokku container:push dokku container:release \/\/ \u041e\u0447\u0435\u043d\u044c \u0431\u044b\u043b\u043e \u0431\u044b \u0443\u0434\u043e\u0431\u043d\u043e, \u043d\u043e \u0435\u0449\u0435 \u043d\u0435\u0442 :(<\/code><\/pre>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <a href=\"http:\/\/dokku.viewdocs.io\/dokku~v0.20.4\/deployment\/methods\/images\/\" rel=\"nofollow\"><code>tags<\/code><\/a> \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u043f\u043b\u043e\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0437\u044b, \u043d\u043e \u0441\u0430\u043c \u043e\u0431\u0440\u0430\u0437 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0436\u0435 \u043d\u0430 \u0445\u043e\u0441\u0442\u0435 \u0432 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u043a\u0430\u0442\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 image \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0445\u043e\u0441\u0442.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">tags:create &lt;app&gt; &lt;tag&gt;                        # Add tag to latest running app image tags:deploy &lt;app&gt; &lt;tag&gt;                        # Deploy tagged app image tags:destroy &lt;app&gt; &lt;tag&gt;                       # Remove app image tag<\/code><\/pre>\n<p>  <\/p>\n<p>\u042f \u0437\u043d\u0430\u043a\u043e\u043c \u0441 Ansible \u0438 \u0434\u0430\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u044b \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0431\u0435\u043a\u0435\u043d\u0434\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0431\u043e\u0440 \u0431\u044b\u043b \u043f\u0440\u043e\u0441\u0442. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0437\u0430\u043f\u0430\u0440\u0438\u0442\u044c\u0441\u044f \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043b\u0430\u0433\u0438\u043d \u043a dokku, \u043d\u043e \u043d\u0435\u0442, \u043d\u0435 \u0441\u0435\u0439\u0447\u0430\u0441.<\/p>\n<p>  <\/p>\n<h2 id=\"playbook\">Playbook<\/h2>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 playbook \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u0442 \u043d\u0435\u043a\u0438\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437, \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u043d\u0430 \u0445\u043e\u0441\u0442, \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0438 \u0434\u0435\u043f\u043b\u043e\u0438\u0442 \u0435\u0433\u043e \u0432 dokku. \u0420\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043b \u0432 Gitlab \u0440\u0435\u043f\u0435. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0435\u0449\u0435 \u043f\u043e\u043b\u043d\u043e.<\/p>\n<p>  <\/p>\n<h3 id=\"push-imagedokkuymlhttpsgitlabcomnogipx-ossdocker-preset-blobmasterdokkupush-imagedokkuyml\"><a href=\"https:\/\/gitlab.com\/nogipx-oss\/docker-preset\/-\/blob\/master\/dokku\/push-image.dokku.yml\" rel=\"nofollow\">push-image.dokku.yml<\/a><\/h3>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">push-image.dokku.yml<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">---   - name: &quot;DEPLOY APP '{{ appname }}' TO DOKKU&quot;     hosts: dokku_hosts     remote_user: root     gather_facts: false     vars:       tarname: &quot;{{ appname }}__{{ image }}.tar&quot;       upload_dir: &quot;\/usr\/local\/src&quot;       upload_path: &quot;{{ upload_dir }}\/{{ tarname }}&quot;       apptag: &quot;{{ upload_tag | default('latest') }}&quot;       dokku_image: &quot;dokku\/{{ appname }}:{{ apptag }}&quot;      tasks:       - name: &quot;Archive '{{ image }}' to upload&quot;         register: env         delegate_to: localhost         shell:            cmd: docker image save -o &quot;.\/{{ tarname }}&quot; {{ image }}        - name: &quot;Upload image '{{ image }}' to dokku at '{{ inventory_hostname }}'&quot;         register: upload         copy:           src: &quot;.\/{{ tarname }}&quot;           dest: &quot;{{ upload_path }}&quot;        - name: &quot;Log - Upload result&quot;         debug:           var: upload.dest        - name: &quot;Restore uploaded docker image&quot;         register: restore         shell:           cmd: docker image load -i &quot;{{ upload_path }}&quot;        - name: &quot;Log - Restore image&quot;         debug:           var: restore.stdout_lines        - name: &quot;Retag image to '{{ dokku_image }}'&quot;         shell:            cmd: docker tag &quot;{{ image }}&quot; &quot;{{ dokku_image }}&quot;        - name: &quot;Create dokku tag for '{{ dokku_image }}'&quot;         shell:            cmd: dokku tags:create &quot;{{ appname }}&quot; &quot;{{ apptag }}&quot;        - name: &quot;Release '{{ appname }}'&quot;         register: release         shell:            cmd: dokku tags:deploy &quot;{{ appname }}&quot; &quot;{{ apptag }}&quot;          - name: &quot;Log - Release&quot;         debug:           var: release.stdout_lines   <\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p><em><u>\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e ansible \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0438 dokku \u043d\u0430 \u0445\u043e\u0441\u0442\u0435 \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b<\/u><\/em><br \/>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">ansible-playbook push-image.dokku.yml -i some_inventory -e &quot;appname=DOKKU_APP_NAME image=DOKER_IMAGE&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>some_inventory<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[dokku_hosts] your.domain.example<\/code><\/pre>\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\/post\/504236\/\"> https:\/\/habr.com\/ru\/post\/504236\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/504236\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fs\/hp\/gp\/fshpgpmnrptvl-lyxypvmmkwb9a.jpeg\" alt=\"image\"><\/p>\n<p>  <\/p>\n<h2 id=\"prolog\">\u041f\u0440\u043e\u043b\u043e\u0433<\/h2>\n<p>  <\/p>\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0443\u0437\u043d\u0430\u043b \u043e &quot;\u043a\u0430\u0440\u043c\u0430\u043d\u043d\u043e\u043c&quot; PaaS \u043f\u043e\u0445\u043e\u0436\u0435\u043c \u043d\u0430 Heroku \u0441 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u2014 Dokku. \u041e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0438 vhost \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0441\u0432\u043e\u0438 docker \u043e\u0431\u0440\u0430\u0437\u044b \u043d\u0430 Dokku. \u041f\u0440\u0430\u0432\u0434\u0430, \u044f \u0431\u044b\u043b \u0440\u0430\u0437\u043e\u0447\u0430\u0440\u043e\u0432\u0430\u043d \u0442\u0435\u043c, \u0447\u0442\u043e \u0432 Dokku \u043d\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 Heroku <\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">dokku container:push dokku container:release \/\/ \u041e\u0447\u0435\u043d\u044c \u0431\u044b\u043b\u043e \u0431\u044b \u0443\u0434\u043e\u0431\u043d\u043e, \u043d\u043e \u0435\u0449\u0435 \u043d\u0435\u0442 :(<\/code><\/pre>\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-304411","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304411","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=304411"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304411\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=304411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=304411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=304411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}