From 7d7fd6d1886f34393f054bd07577f5010bebadfb Mon Sep 17 00:00:00 2001 From: Aaron Daniel Date: Thu, 26 Dec 2013 13:46:40 -0800 Subject: [PATCH 1/3] Upgrade weechat and make it easier to get running --- Dockerfile | 27 ++++++++++++++++++--------- README.md | 40 ++++++++++++++++++++++++++++++++++++++-- startup.sh | 18 ++++++++++++++++++ 3 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 startup.sh diff --git a/Dockerfile b/Dockerfile index c3fe807..d62b40d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,23 @@ 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 -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..43d082a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,40 @@ -docker-weechat -============== +# docker-weechat Weechat on Docker + +## Usage + +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="" amdtech/weechat) +``` + +> If you don't set the `PUB_KEYS` environment variable, the logs will show that and the image will not boot. + +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 From 3e1124a44d606126efae8777ea3f33879c6244af Mon Sep 17 00:00:00 2001 From: Aaron Daniel Date: Thu, 26 Dec 2013 14:02:53 -0800 Subject: [PATCH 2/3] Add persistence documentation --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 43d082a..737a566 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,28 @@ 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="" amdtech/weechat) +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 From 3c162a0938ceac3d5e2c04a3b876f54b79c54b78 Mon Sep 17 00:00:00 2001 From: Aaron Daniel Date: Thu, 26 Dec 2013 14:09:18 -0800 Subject: [PATCH 3/3] Set startup.sh to runnable --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index d62b40d..b5b43d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,5 +19,7 @@ EXPOSE 22 ADD bashrc /home/docker/.bashrc ADD startup.sh /usr/bin/startup.sh +RUN chmod 755 /usr/bin/startup.sh + # The argument is the user as set up above CMD ["/usr/bin/startup.sh", "docker"]