
Prolog
Ich habe kürzlich von einem "Taschen" -PaaS erfahren, das Heroku ähnelt und einen ziemlich offensichtlichen Namen hat - Dokku. Ich war sehr angetan von der Möglichkeit, der Anwendung und dem vhost sofort ein Zertifikat hinzuzufügen, und entschied mich daher, meine Docker-Bilder nach Dokku zu übertragen. Ich war zwar enttäuscht, dass es in Dokku keine Teams wie Heroku gibt
dokku container:push
dokku container:release
// , :(
tags
, . , image .
tags:create <app> <tag> # Add tag to latest running app image
tags:deploy <app> <tag> # Deploy tagged app image
tags:destroy <app> <tag> # Remove app image tag
Ansible , . dokku, , .
Playbook
playbook , , dokku. Gitlab . .
push-image.dokku.yml---
- name: "DEPLOY APP '{{ appname }}' TO DOKKU"
hosts: dokku_hosts
remote_user: root
gather_facts: false
vars:
tarname: "{{ appname }}__{{ image }}.tar"
upload_dir: "/usr/local/src"
upload_path: "{{ upload_dir }}/{{ tarname }}"
apptag: "{{ upload_tag | default('latest') }}"
dokku_image: "dokku/{{ appname }}:{{ apptag }}"
tasks:
- name: "Archive '{{ image }}' to upload"
register: env
delegate_to: localhost
shell:
cmd: docker image save -o "./{{ tarname }}" {{ image }}
- name: "Upload image '{{ image }}' to dokku at '{{ inventory_hostname }}'"
register: upload
copy:
src: "./{{ tarname }}"
dest: "{{ upload_path }}"
- name: "Log - Upload result"
debug:
var: upload.dest
- name: "Restore uploaded docker image"
register: restore
shell:
cmd: docker image load -i "{{ upload_path }}"
- name: "Log - Restore image"
debug:
var: restore.stdout_lines
- name: "Retag image to '{{ dokku_image }}'"
shell:
cmd: docker tag "{{ image }}" "{{ dokku_image }}"
- name: "Create dokku tag for '{{ dokku_image }}'"
shell:
cmd: dokku tags:create "{{ appname }}" "{{ apptag }}"
- name: "Release '{{ appname }}'"
register: release
shell:
cmd: dokku tags:deploy "{{ appname }}" "{{ apptag }}"
- name: "Log - Release"
debug:
var: release.stdout_lines
ansible dokku
ansible-playbook push-image.dokku.yml -i some_inventory -e "appname=DOKKU_APP_NAME image=DOCKER_IMAGE"
some_inventory
[dokku_hosts]
your.domain.example