feat: initial docker installation support

Refs #1076
This commit is contained in:
Jose Diaz-Gonzalez
2019-05-13 03:05:50 -04:00
parent 6b42fde028
commit 3eb9c9b3ba
10 changed files with 172 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
PATH=/usr/local/bin:/usr/bin:/bin
SHELL=/bin/bash
*/5 * * * * root /usr/bin/dokku ps:retire >> /var/log/dokku/retire.log 2>&1

View File

@@ -0,0 +1,9 @@
/var/log/services/* {
daily
missingok
rotate 7
compress
delaycompress
notifempty
copytruncate
}

View File

@@ -0,0 +1,36 @@
#!/bin/bash
set -eo pipefail
log-info() {
declare desc="Log info formatter"
echo " $*" 1>&2
}
log-fail() {
declare desc="Log fail formatter"
echo "! $*" 1>&2
exit 1
}
main() {
if [[ ! -d /mount ]]; then
log-info "Creating missing /mount"
mkdir -p /mount
fi
directories=("/etc/ssh" "/home/dokku" "/var/lib/dokku/config" "/var/lib/dokku/data")
for dir in "${directories[@]}"; do
if [[ ! -e "$dir" ]]; then
log-info "Copying ${dir} skel into place"
mkdir -p "/mount${dir}"
rsync -a "/skel${dir}/" "${dir}/" || log-fail "Unable to copy ${dir} skel into place"
fi
# chown mount directories to "dokku:dokku"
if [[ "$dir" != "/etc/ssh" ]]; then
find "$dir" -print0 | xargs -0 chown -h dokku:dokku
fi
done
}
main "$@"

View File

@@ -0,0 +1,15 @@
#!/bin/bash
exec >> /var/log/services/dokku-restore
exec 2>&1
if [[ "$1" -ne 0 ]]; then
echo "Error initializing dokku! Retrying in 30 seconds..."
exec sleep 30
exit 0
fi
echo "Done initializing dokku."
exec sleep infinity
exit 0

View File

@@ -0,0 +1,14 @@
#!/bin/bash
exec >> /var/log/services/dokku-init
exec 2>&1
echo "Running dokku-init"
cd /tmp || exit 1
if [[ -n "$DOKKU_HOSTNAME" ]]; then
echo "dokku dokku/vhost_enable boolean true" | debconf-set-selections
dokku --quiet domains:set-global "$DOKKU_HOSTNAME"
fi
exec dokku ps:restore

View File

@@ -0,0 +1,7 @@
#!/bin/bash
exec >> /var/log/services/nginx
exec 2>&1
echo "Running nginx"
exec /usr/sbin/nginx -c /etc/nginx/nginx.conf -g "daemon off;"

View File

@@ -0,0 +1,7 @@
#!/bin/bash
exec >> /var/log/services/rsyslog
exec 2>&1
echo "Running rsyslog"
exec /usr/sbin/rsyslogd -n

View File

@@ -0,0 +1 @@
dokku ALL=NOPASSWD:SETENV:/usr/bin/docker

19
docker/usr/local/bin/docker Executable file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $TRACE ]] && set -x
main() {
declare desc="re-runs docker commands as sudo"
local DOCKER_BIN=""
if [[ -x "/usr/bin/docker" ]]; then
DOCKER_BIN="/usr/bin/docker"
fi
if [[ -z "$DOCKER_BIN" ]]; then
echo "! No docker binary found" 1>&2
exit 1
fi
sudo -E "$DOCKER_BIN" "$@"
}
main "$@"