Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
docker hosted dokku
# add your public ssh keys to data/ssh
mkdir -p data/{apps,config,ssh,storage}
# build the image and tag it
docker build -t dokku/dokku:dokku-test .
# run the image
docker run \
-p "2222:22" \
-v $PWD/data/apps:/apps \
-v $PWD/data/config:/var/lib/dokku/config \
-v $PWD/data/ssh:/var/lib/dokku/ssh \
-v $PWD/data/storage:/var/lib/dokku/storage \
-v /var/run/docker.sock:/var/run/docker.sock \
--name dokku-0.7.1 \
dokku/dokku:0.7.1
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND="noninteractive"
RUN apt-get update -qq \
&& apt-get -qq -y install apt-transport-https ca-certificates libidn11 openssl wget \
&& apt-get -qq -y install openssh-server \
# Ensure we have an init so that we don't leave random processes lying around
&& wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.1.3/dumb-init_1.1.3_amd64 && chmod +x /usr/local/bin/dumb-init \
# Try and slim down the image
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/bootstrap.sh \
&& mkdir -p /var/run/sshd /apps
ENV NO_INSTALL_RECOMMENDS=" --no-install-recommends "
ENV DOKKU_DOCKERFILE="1"
ENV DOKKU_ROOT="/apps"
ENV DOKKU_TAG="v0.7.1"
ADD bootstrap.sh /tmp/bootstrap.sh
RUN bash /tmp/bootstrap.sh
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
EXPOSE 22
# TODO: What do we do about config/data for community plugins?
# TODO: How do we handle installing custom plugins
COPY contrib/dockerfile-init.sh /sbin/init.sh
RUN chmod 755 /sbin/init.sh
CMD ["dumb-init", "/sbin/init.sh"]
#!/usr/bin/env bash
set -eo pipefail; [[ $TRACE ]] && set -x
main() {
readonly DOKKU_HOME=/apps
readonly DOKKU_SSH_DIR="$DOKKU_HOME/.ssh"
cp -a /home/dokku/. /apps/
usermod -d "$DOKKU_HOME" dokku
mkdir -p "$DOKKU_SSH_DIR"
chown -R dokku:dokku "$DOKKU_HOME"
chmod 700 "$DOKKU_SSH_DIR"
if [[ "$(ls -A $DOKKU_SSH_DIR)" ]]; then
chmod 600 $DOKKU_SSH_DIR/*
fi
# configure sshd
sed -i \
-e "s|^[#]*UsePAM yes|UsePAM no|" \
-e "s|^[#]*UsePrivilegeSeparation yes|UsePrivilegeSeparation no|" \
-e "s|^[#]*PasswordAuthentication yes|PasswordAuthentication no|" \
-e "s|^[#]*LogLevel INFO|LogLevel VERBOSE|" \
/etc/ssh/sshd_config
echo "UseDNS no" >> /etc/ssh/sshd_config
if [[ "$(ls -A /var/lib/dokku/ssh)" ]]; then
local USERNAME_TMP_DIR=$(mktemp -d "/tmp/username.XXXX")
trap 'rm -rf "$USERNAME_TMP_DIR" > /dev/null' RETURN INT TERM
for f in /var/lib/dokku/ssh/*; do
echo "$f" > "$USERNAME_TMP_DIR/u"
local filehash=$(md5sum $USERNAME_TMP_DIR/u | cut -d ' ' -f 1)
sshcommand acl-add dokku dokku-$filehash "$f"
done
fi
chown root:docker /var/run/docker.sock
/usr/sbin/sshd -D -e
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment