├── README.md ├── clone-logo.png ├── clone-logo.svg ├── commands ├── functions ├── install ├── plugin.toml └── subcommands ├── allow ├── default └── key /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | A dokku plugin which allows you to create an app from a git url 4 | 5 | ## Update! 6 | If you're using version 0.23.0 or above this plugin is no longer required. 7 | Instead use the dokku `git:sync` command. 8 | 9 | See http://dokku.viewdocs.io/dokku~v0.23.0/deployment/methods/git/ for more informaiton 10 | 11 | 12 | ## Requirements 13 | 14 | * dokku 0.4.0+ 15 | 16 | ## Installation 17 | 18 | ```bash 19 | # on 0.4.x 20 | dokku plugin:install https://github.com/crisward/dokku-clone.git clone 21 | ``` 22 | 23 | ## Usage 24 | 25 | ```bash 26 | # create or update and app from e.g. GitHub 27 | dokku@dokku.me clone yourapp https://github.com/you/yourproject.git 28 | 29 | # e.g: 30 | ssh dokku@dokku.me clone nodetest https://github.com/heroku/node-js-getting-started.git 31 | 32 | # you then have the Heroku sample app on nodetest.dokku.me (you may have to update your hosts file) 33 | 34 | # clone a local app: 35 | ssh dokku@dokku.me clone nodetest-clone ~/nodetest 36 | ``` 37 | 38 | ### Private Repos / git urls 39 | 40 | If you need to clone private repos, or just want to use git@ urls you'll need to add a deploy key to your git provider (ie github). 41 | If you want to be able to pull any repo from github, you'll have to add the key [here](https://github.com/settings/ssh) 42 | Clone creates a fresh keypair when the plugin is first installed. The public part of the key can be accessed with. 43 | 44 | ```bash 45 | # output with 46 | ssh dokku@dokku.me clone:key 47 | 48 | # save to clipboard with (mac only) 49 | ssh dokku@dokku.me clone:key | pbcopy 50 | 51 | # before cloning the repo, you'll need to add the remote to known hosts with 52 | ssh dokku@dokku.me clone:allow github.com 53 | ``` 54 | 55 | ### Cloning Branches and Tags 56 | 57 | If you would like to build your app from another branch or tag your can pass that in as a third parameter 58 | ie. 59 | 60 | ```bash 61 | ssh dokku@dokku.me clone nodetest https://github.com/heroku/node-js-getting-started.git 2016 62 | ``` 63 | 64 | ## Credits 65 | 66 | Thanks to [Jose Gonzalez](https://github.com/josegonzalez) for the Dokku5 refactor 67 | and the [Noun Project](https://thenounproject.com/) for the logo 68 | 69 | 70 | ## License 71 | 72 | (The MIT License) 73 | 74 | Copyright (c) 2016 Cris Ward 75 | 76 | 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: 77 | 78 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 79 | 80 | 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. 81 | -------------------------------------------------------------------------------- /clone-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crisward/dokku-clone/264c5ee3f0f158d2b893e5196ffa747f0ed67302/clone-logo.png -------------------------------------------------------------------------------- /clone-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | dokku 7 | 8 | 9 | clone 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /commands: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x 3 | source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" 4 | source "$PLUGIN_AVAILABLE_PATH/clone/functions" 5 | 6 | case "$1" in 7 | help | clone:help) 8 | help_content_func() { 9 | declare desc="return help_content string" 10 | cat< , creates/updates app from remote git repo 12 | clone:key, outputs the dokku public deploy key 13 | clone:allow, adds a domain to known_hosts 14 | help_content 15 | } 16 | 17 | if [[ $1 = "clone:help" ]] ; then 18 | echo -e 'Usage: dokku clone [git-branch/tag]' 19 | echo '' 20 | echo 'Clones and builds remote repos into dokku app' 21 | echo '' 22 | echo 'Example:' 23 | echo '' 24 | echo '$ dokku clone nodeapp https://github.com/heroku/node-js-sample' 25 | echo '' 26 | elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then 27 | help_content_func 28 | else 29 | cat< " 15 | [[ -d "$DOKKU_ROOT/$APP" ]] || dokku apps:create "$APP" 16 | 17 | if [[ ! -d "$DOKKU_ROOT/$APP/.clone" ]]; then 18 | cd "$DOKKU_ROOT/$APP" 19 | if [[ -z $TAGNAME ]]; then 20 | dokku_log_info1 "Creating $APP from $GITURL..." 21 | git clone "$GITURL" .clone 22 | else 23 | dokku_log_info1 "Creating $APP from $GITURL $TAGNAME" 24 | git clone -n -qq "$GITURL" .clone 25 | cd .clone 26 | git checkout -qq "$TAGNAME" 27 | cd .. 28 | fi 29 | rsync -a "$DOKKU_ROOT/$APP/.clone/.git/" ./ 30 | rm -rf "$DOKKU_ROOT/$APP/.clone" 31 | 32 | git config --bool core.bare true 33 | 34 | cat > "$PRERECEIVE_HOOK" <> "$DOKKU_ROOT/.ssh/known_hosts" 65 | dokku_log_info1 "$DOMAIN added to known hosts" 66 | } 67 | -------------------------------------------------------------------------------- /install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x 3 | 4 | clone_install() { 5 | declare desc="generates an ssh keypair for the dokku user and checks installed correctly" 6 | if [[ -f "$DOKKU_ROOT/.ssh/id_rsa" ]]; then 7 | return; 8 | fi 9 | ssh-keygen -t rsa -N "" -q -f "$DOKKU_ROOT/.ssh/id_rsa" 10 | chown dokku:dokku "$DOKKU_ROOT/.ssh/id_rsa.pub" 11 | chown dokku:dokku "$DOKKU_ROOT/.ssh/id_rsa" 12 | } 13 | 14 | clone_install "$@" 15 | -------------------------------------------------------------------------------- /plugin.toml: -------------------------------------------------------------------------------- 1 | [plugin] 2 | description = "dokku git clone plugin" 3 | version = "0.4.1" 4 | [plugin.config] -------------------------------------------------------------------------------- /subcommands/allow: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x 3 | source "$PLUGIN_AVAILABLE_PATH/clone/functions" 4 | 5 | clone_allow_cmd "$@" 6 | -------------------------------------------------------------------------------- /subcommands/default: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x 3 | source "$PLUGIN_AVAILABLE_PATH/clone/functions" 4 | 5 | clone_main_cmd "$@" 6 | -------------------------------------------------------------------------------- /subcommands/key: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x 3 | source "$PLUGIN_AVAILABLE_PATH/clone/functions" 4 | 5 | clone_key_cmd "$@" 6 | --------------------------------------------------------------------------------