Created
April 7, 2016 14:50
-
-
Save michaelgold/b3eb2ac8f5c6ccc003e66e631dc6e16d to your computer and use it in GitHub Desktop.
docker hosted dokku
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 \ | |
-e "TRACE=1" \ | |
-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 \ | |
dokku/dokku:dokku-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:14.04 | |
ENV DEBIAN_FRONTEND noninteractive | |
ENV DOCKER_HOST unix:///var/run/docker.sock | |
ENV DOKKU_DOCKERFILE 1 | |
ENV DOKKU_ROOT /apps | |
ENV DOKKU_VERSION 0.5.3 | |
RUN apt-get update -qq | |
RUN apt-get -qq -y install apt-transport-https ca-certificates libidn11 openssl wget | |
RUN apt-get -qq -y install openssh-server && mkdir -p /var/run/sshd /apps | |
ADD bootstrap.sh /tmp/bootstrap.sh | |
RUN DOKKU_TAG="v${DOKKU_VERSION}" bash /tmp/bootstrap.sh | |
# Ensure we have an init so that we don't leave random processes lying around | |
RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.0.1/dumb-init_1.0.1_amd64 && chmod +x /usr/local/bin/dumb-init | |
# Try and slim down the image | |
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/bootstrap.sh; | |
EXPOSE 22 | |
# TODO: What do we do about config/data for community plugins? | |
# TODO: How do we handle installing custom plugins | |
COPY contrib/dockerfile-entrypoint.sh /sbin/entrypoint.sh | |
RUN chmod 755 /sbin/entrypoint.sh | |
ENTRYPOINT ["dumb-init", "/sbin/entrypoint.sh"] | |
CMD ["/usr/sbin/sshd", "-D", "-e"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eo pipefail; [[ $TRACE ]] && set -x | |
main() { | |
readonly DOKKU_SSH_DIR=/home/dokku/.ssh | |
mkdir -p "$DOKKU_SSH_DIR" | |
chown -R dokku:dokku /home/dokku | |
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 | |
exec "$@" | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment