forked from agco/dokku-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands
executable file
·56 lines (51 loc) · 1.38 KB
/
commands
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
case "$1" in
registry:login)
shift
echo "$@"
docker login "$@"
;;
registry:push)
mkdir -p /home/dokku/checkout
cd /home/dokku/checkout
UUID=$(uuidgen)
git clone "$2" "$UUID"
cd "$UUID"
dokku apps:create "$UUID"
if [[ -f "$UUID/Dockerfile" ]]; then
IMAGE_TYPE="dockerfile"
else
IMAGE_TYPE="herokuish"
fi
tar c . | dokku build "$UUID" "$IMAGE_TYPE"
docker tag "dokku/$UUID" "$3"
docker push "$3"
dokku delete "$UUID"
rm -rf /home/dokku/checkout/"$UUID"
;;
registry:pull)
APP=$2; DOCKER_REGISTRY_IMAGE=$3
mkdir -p "$DOKKU_ROOT/$APP"
docker pull "$DOCKER_REGISTRY_IMAGE"
docker tag "$DOCKER_REGISTRY_IMAGE" "dokku/$APP"
dokku release "$APP"
dokku deploy "$APP"
;;
help | registry:help)
HELP=$(cat<<EOF
registry:login <docker login args>, Login to a docker registry
registry:push <git_url> <docker_registry_image>, Clone a git url, exec buildstep and push the resulting Docker image to the logged on registry
registry:pull <app> <docker_registry_image>, Pull a Docker image (produced with buildstep) from the logged on registry and deploy
EOF
)
if [[ -n $DOKKU_API_VERSION ]]; then
echo "$HELP"
else
cat && echo "$HELP"
fi
;;
*)
exit $DOKKU_NOT_IMPLEMENTED_EXIT
;;
esac