diff --git a/Dockerfile b/Dockerfile index c3fe807..b5b43d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,25 @@ FROM ubuntu -MAINTAINER Manfred Touron m@42.am +MAINTAINER Aaron Daniel aaron@ninjawarriors.io + +# original Dockerfile borrowed from moul/weechat +# updated to use latest weechat and a single command for installation +# to avoid the 42 layers issue + +RUN \ + apt-get -q -y update ;\ + apt-get install -y python-software-properties ;\ + add-apt-repository -y ppa:nesthib/weechat-stable ;\ + apt-get -q -y update ;\ + apt-get install -y openssh-server weechat tmux ;\ + mkdir /var/run/sshd ;\ + useradd -m docker -s /bin/bash -RUN echo "deb http://archive.ubuntu.com/ubuntu/ precise main universe" >> /etc/apt/sources.list -RUN apt-get -q -y update -RUN apt-get install -y openssh-server weechat tmux -RUN mkdir /var/run/sshd -RUN echo "root:root" | chpasswd EXPOSE 22 -RUN useradd -m docker -ADD bashrc /root/.bashrc +ADD bashrc /home/docker/.bashrc +ADD startup.sh /usr/bin/startup.sh + +RUN chmod 755 /usr/bin/startup.sh -CMD ["/usr/sbin/sshd", "-D"] +# The argument is the user as set up above +CMD ["/usr/bin/startup.sh", "docker"] diff --git a/README.md b/README.md index d4d4169..737a566 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,54 @@ -docker-weechat -============== +# docker-weechat Weechat on Docker + +## Usage + +### Persistance + +Normally, the container will store all the weechat configuration and components within the container, so when the container is replaced, the configuration will go away. To fix that, do this on the docker host: + +Run the following as whatever user you use to manage docker. You can put the file anywhere you like, really. +```bash +mkdir ~/.weechat +chown 1000 ~/.weechat +``` + +### Booting + +The image is designed to boot directly into ssh, and you can ssh into the docker image with your public key. You'll need to boot it with the right options: + +```bash +WEECHAT_ID=$(docker run -d -p 22 -e PUB_KEYS="" -v /root/.weechat:/home/docker/.weechat amdtech/weechat) +``` + +> If you don't set the `PUB_KEYS` environment variable, the logs will show that and the image will not boot. + +> Replace `/root/.weechat` with whatever directory you actually created. + +To get the port weechat is running on, run the following: + +```bash +DOCKER_IP=$(curl --silent icanhazip.com) +WEECHAT_PORT=$(docker port $WEECHAT_ID 22 | cut -d: -f2) +``` + +Once you've done that, you can ssh to the image with: + +```bash +ssh -l docker $DOCKER_IP -p $WEECHAT_PORT +``` + +If you don't want to deal with this, you can boot the image with a designated public port so it never changes: + +```bash +docker run -d -p 19122:22 -e PUB_KEYS="" amdtech/weechat +``` + +## Building + +You can either use the trusted build on the index, or grab this repo and build it yourself with: + +```bash +docker build -t / . +``` diff --git a/startup.sh b/startup.sh new file mode 100644 index 0000000..e532fe8 --- /dev/null +++ b/startup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Preconfigure the booted docker image with SSH keys +# + +USER=$1 + +if [ -z "$PUB_KEYS" ]; then + echo "You need to set your public key in PUB_KEYS environment variable" + exit 10 +fi + +mkdir -p /home/$USER/.ssh +echo $PUB_KEYS > /home/$USER/.ssh/authorized_keys +chown $USER /home/$USER/.ssh/authorized_keys + +echo "SSH Keys activated... booting!" +/usr/sbin/sshd -D