├── .editorconfig ├── .gitignore ├── .travis.yml ├── LICENSE.txt ├── Makefile ├── README.md ├── commands └── plugin.toml /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | insert_final_newline = true 5 | indent_style = space 6 | indent_size = 2 7 | 8 | [Makefile] 9 | insert_final_newline = true 10 | indent_style = tab 11 | indent_size = 4 12 | 13 | [*.mk] 14 | insert_final_newline = true 15 | indent_style = tab 16 | indent_size = 4 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | language: bash 3 | env: 4 | - DOKKU_VERSION=master 5 | before_install: make setup 6 | script: make test 7 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2015 AGCO 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | shellcheck: 2 | ifeq ($(shell shellcheck > /dev/null 2>&1 ; echo $$?),127) 3 | ifeq ($(shell uname),Darwin) 4 | brew install shellcheck 5 | else 6 | sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse' 7 | sudo apt-get update -qq && sudo apt-get install -qq -y shellcheck 8 | endif 9 | endif 10 | 11 | bats: 12 | ifeq ($(shell bats > /dev/null 2>&1 ; echo $$?),127) 13 | ifeq ($(shell uname),Darwin) 14 | brew install shellcheck 15 | else 16 | sudo add-apt-repository ppa:duggan/bats --yes 17 | sudo apt-get update -qq && sudo apt-get install -qq -y bats 18 | endif 19 | endif 20 | 21 | ci-dependencies: shellcheck bats 22 | 23 | lint: 24 | # these are disabled due to their expansive existence in the codebase. we should clean it up though 25 | # SC2046: Quote this to prevent word splitting. - https://github.com/koalaman/shellcheck/wiki/SC2046 26 | # SC2068: Double quote array expansions, otherwise they're like $* and break on spaces. - https://github.com/koalaman/shellcheck/wiki/SC2068 27 | # SC2086: Double quote to prevent globbing and word splitting - https://github.com/koalaman/shellcheck/wiki/SC2086 28 | @echo linting... 29 | @$(QUIET) find ./ -maxdepth 1 -not -path '*/\.*' | xargs file | egrep "shell|bash" | awk '{ print $$1 }' | sed 's/://g' | xargs shellcheck -e SC2046,SC2068,SC2086 30 | 31 | setup: 32 | $(MAKE) ci-dependencies 33 | 34 | test: setup lint 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dokku-registry [![Build Status](https://img.shields.io/travis/agco/dokku-registry.svg?branch=master "Build Status")](https://travis-ci.org/agco/dokku-registry) 2 | 3 | The Docker registry plugin for [Dokku](https://github.com/progrium/dokku) adds support for managing application releases as part of a continuous delivery workflow. 4 | 5 | On Heroku similar functionality is offered by the [heroku-labs pipeline feature](https://devcenter.heroku.com/articles/labs-pipelines), which allows you to promote builds across multiple environments (staging -> production) 6 | 7 | ## requirements 8 | 9 | - dokku 0.4.0+ 10 | - docker 1.8.x 11 | 12 | ## installation 13 | 14 | ```shell 15 | # on 0.3.x 16 | cd /var/lib/dokku/plugins 17 | git clone https://github.com/agco/dokku-registry.git registry 18 | dokku plugins-install 19 | 20 | # on 0.4.x 21 | dokku plugin:install https://github.com/agco/dokku-registry.git registry 22 | ``` 23 | 24 | ## Commands 25 | 26 | ``` 27 | $ dokku help 28 | registry:login Login to a docker registry 29 | registry:push Clone a git url, exec buildstep and push the resulting Docker image to the logged on registry 30 | registry:pull Pull a Docker image (produced with buildstep) from the logged on registry and deploy 31 | ``` 32 | 33 | ## Workflow 34 | 35 | 36 | ### Build machine 37 | 38 | ``` 39 | dokku registry:login —username= —password= —email= 40 | ``` 41 | This logs you in to the dockerhub registry 42 | Other registries can be specified as well with using the optional server arg 43 | Check the [docker login](https://docs.docker.com/reference/commandline/cli/#login) docs for more details 44 | 45 | ``` 46 | dokku registry:push 47 | ``` 48 | This clones the code from a given git_url and builds it with buildstep 49 | The resulting Docker is tagged as specified by the image_tag arg and pushed to the current logged-on Docker registry 50 | 51 | ### Deploy target(s) 52 | 53 | ``` 54 | dokku registry:login —username= —password= —email= 55 | ``` 56 | 57 | ``` 58 | dokku registry:pull 59 | ``` 60 | This pulls the image tag from the current logged-on registry and deploys it to Dokku. The application will be auto-created in case it doesn't exist yet. 61 | 62 | ### Quick example 63 | 64 | Note : This is just to demonstrate syntax, replace credentials and registry image tag with your own values 65 | 66 | ``` 67 | dokku registry:login --username=myusername --email=myemail@mailinator.com --password=mypwd 68 | dokku registry:push https://github.com/heroku/node-js-getting-started.git myusername/myapp:1.2.3 69 | dokku registry:pull myapp myusername/myapp:1.2.3 70 | ``` 71 | 72 | ### Set config variables prior to application start 73 | 74 | The workflow then looks something like the following 75 | 76 | ``` 77 | dokku registry:login --username=myusername --email=myemail@mailinator.com --password=mypwd 78 | dokku create myapp 79 | dokku config:set myapp FOO=BAR 80 | dokku registry:pull myapp myusername/myapp:1.2.3 81 | ``` 82 | 83 | An example on how to bootstrap this can be found here : https://github.com/agco-adm/dokku-provision-ALM-support 84 | 85 | 86 | -------------------------------------------------------------------------------- /commands: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x 3 | 4 | case "$1" in 5 | registry:login) 6 | shift 7 | echo "$@" 8 | docker login "$@" 9 | ;; 10 | 11 | registry:push) 12 | mkdir -p /home/dokku/checkout 13 | cd /home/dokku/checkout 14 | UUID=$(uuidgen) 15 | git clone "$2" "$UUID" 16 | cd "$UUID" 17 | dokku apps:create "$UUID" 18 | if [[ -f "$UUID/Dockerfile" ]]; then 19 | IMAGE_TYPE="dockerfile" 20 | else 21 | IMAGE_TYPE="herokuish" 22 | fi 23 | tar c . | dokku build "$UUID" "$IMAGE_TYPE" 24 | docker tag "dokku/$UUID" "$3" 25 | docker push "$3" 26 | dokku delete "$UUID" 27 | rm -rf /home/dokku/checkout/"$UUID" 28 | ;; 29 | 30 | registry:pull) 31 | APP=$2; DOCKER_REGISTRY_IMAGE=$3 32 | mkdir -p "$DOKKU_ROOT/$APP" 33 | docker pull "$DOCKER_REGISTRY_IMAGE" 34 | docker tag "$DOCKER_REGISTRY_IMAGE" "dokku/$APP" 35 | dokku release "$APP" 36 | dokku deploy "$APP" 37 | ;; 38 | 39 | help | registry:help) 40 | HELP=$(cat<, Login to a docker registry 42 | registry:push , Clone a git url, exec buildstep and push the resulting Docker image to the logged on registry 43 | registry:pull , Pull a Docker image (produced with buildstep) from the logged on registry and deploy 44 | EOF 45 | ) 46 | if [[ -n $DOKKU_API_VERSION ]]; then 47 | echo "$HELP" 48 | else 49 | cat && echo "$HELP" 50 | fi 51 | ;; 52 | 53 | *) 54 | exit $DOKKU_NOT_IMPLEMENTED_EXIT 55 | ;; 56 | esac 57 | -------------------------------------------------------------------------------- /plugin.toml: -------------------------------------------------------------------------------- 1 | [plugin] 2 | description = "manage dokku application releases similar to heroku's pipeline" 3 | version = "1.0.0" 4 | [plugin.config] 5 | --------------------------------------------------------------------------------