From b739ed3e40b675ab40188832fc133344dd11b9ad Mon Sep 17 00:00:00 2001 From: icedream Date: Sat, 24 Oct 2015 10:21:16 +0200 Subject: [PATCH 1/6] Move build to a single install script to save on layers/space. --- Dockerfile | 57 ++++------------------------------------------------- setup.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 53 deletions(-) create mode 100644 setup.sh diff --git a/Dockerfile b/Dockerfile index 7595cdf..db5a4b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,63 +1,14 @@ FROM phusion/passenger-nodejs:0.9.17 -# get rid of useless services -RUN rm -r /etc/service/cron /etc/service/nginx /etc/service/nginx-log-forwarder - -# prepare APT with only the repositories we want -RUN rm /etc/apt/sources.list.d/* &&\ - add-apt-repository ppa:mc3man/trusty-media -y &&\ - DEBIAN_FRONTEND=noninteractive curl -sL https://deb.nodesource.com/setup_4.x | bash - &&\ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - nodejs \ - blackbox xvfb xdotool \ - pulseaudio pulseaudio-utils \ - dbus \ - python python-minimal python-pkg-resources rtmpdump ffmpeg \ - vlc vlc-plugin-pulse - -# initialize DBus -RUN mkdir -p /var/run/dbus && \ - chown messagebus:messagebus /var/run/dbus && \ - dbus-uuidgen --ensure - -# configure gui user -RUN mkdir -p /config &&\ - ln -sf /config ~app/.ts3bot - -# install teamspeak3 -# Original comment that used to be here: temporary non-interactive teamspeak3 install hack, remove before publishing!! -# In fact, it would be nice if we had some lazy handling code for this that just requires the user to provide a "--agree-with-license" once. ENV TS3CLIENT_VERSION 3.0.18.2 -ADD http://dl.4players.de/ts/releases/${TS3CLIENT_VERSION}/TeamSpeak3-Client-linux_amd64-${TS3CLIENT_VERSION}.run /home/app/ts3client.run -WORKDIR /home/app -RUN chmod +x ./ts3client.run &&\ - sed -i 's/^MS_PrintLicense$/#MS_PrintLicense/g' ./ts3client.run &&\ - ./ts3client.run --quiet --target ts3client &&\ - rm ./ts3client.run -USER root - -# install the ts3bot-control app properly ENV TS3BOT_COMMIT 6695fbd83ee07677e6ef920d7687de6a24011d90 -ADD https://github.com/icedream/ts3bot-control/archive/${TS3BOT_COMMIT}.tar.gz /home/app/ts3bot-control.tgz -WORKDIR /home/app -RUN tar xvf ts3bot-control.tgz &&\ - rm ts3bot-control.tgz &&\ - mv ts3bot-control* ts3bot -WORKDIR /home/app/ts3bot -RUN npm install -# install youtube-dl -ADD https://yt-dl.org/latest/youtube-dl /usr/local/bin/youtube-dl -RUN chmod a+rx /usr/local/bin/youtube-dl +ADD setup.sh / +RUN sh /setup.sh -# initialize other configuration for daemons +# Copy over configuration for other daemons COPY etc/ /etc -# clean up apt -RUN apt-get clean && \ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -VOLUME [ "/home/app/ts3client" ] - +# Startup configuration WORKDIR /home/app ENTRYPOINT [ "/sbin/my_init" ] diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..acb1902 --- /dev/null +++ b/setup.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +set -ex + +# For non-interactive install (dpkg) +export INITRD=no +export DEBIAN_FRONTEND=noninteractive + +# Get rid of some preinstalled services we don't need +rm -r /etc/service/cron /etc/service/nginx /etc/service/nginx-log-forwarder + +# Set up APT sources +rm /etc/apt/sources.list.d/* +add-apt-repository ppa:mc3man/trusty-media -y +curl -sL https://deb.nodesource.com/setup_4.x | bash - + +# Now install all packages we need +apt-get install -y --no-install-recommends \ + nodejs \ + blackbox xvfb xdotool \ + pulseaudio pulseaudio-utils \ + dbus \ + python python-minimal python-pkg-resources rtmpdump ffmpeg \ + vlc vlc-plugin-pulse + +# DBus initialization +mkdir -p /var/run/dbus +chown messagebus:messagebus /var/run/dbus +dbus-uuidgen --ensure + +# Configure GUI user, we are going to use the pre-setup "app" user for this +mkdir -p /config +/sbin/setuser app ln -sf /config ~app/.ts3bot + +# Install TeamSpeak3. +# Original comment that used to be here: temporary non-interactive teamspeak3 install hack, remove before publishing!! +# In fact, it would be nice if we had some lazy handling code for this that just requires the user to provide a "--agree-with-license" once. +cd ~app +/sbin/setuser app wget http://dl.4players.de/ts/releases/${TS3CLIENT_VERSION}/TeamSpeak3-Client-linux_amd64-${TS3CLIENT_VERSION}.run -Ots3client.run +chmod +x ./ts3client.run +sed -i 's/^MS_PrintLicense$/#MS_PrintLicense/g' ./ts3client.run +/sbin/setuser app ./ts3client.run --quiet --target ts3client +rm ./ts3client.run + +# Install TS3Bot +wget https://github.com/icedream/ts3bot-control/archive/${TS3BOT_COMMIT}.tar.gz -Ots3bot-control.tgz +/sbin/setuser app tar xvf ts3bot-control.tgz +rm ts3bot-control.tgz +mv ts3bot-control* ts3bot +(cd ts3bot && /sbin/setuser app npm install) + +# Install youtube-dl (actually done by npm already in a non-system-wide way) +#ADD https://yt-dl.org/latest/youtube-dl /usr/local/bin/youtube-dl +#RUN chmod a+rx /usr/local/bin/youtube-dl + +# Clean up APT +apt-get clean +rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* From 60f3eea6d34d028b09989e45975ca1617ddb05a8 Mon Sep 17 00:00:00 2001 From: icedream Date: Sat, 24 Oct 2015 10:30:44 +0200 Subject: [PATCH 2/6] Temporarily install wget to download files. --- setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index acb1902..99b155e 100644 --- a/setup.sh +++ b/setup.sh @@ -16,7 +16,7 @@ curl -sL https://deb.nodesource.com/setup_4.x | bash - # Now install all packages we need apt-get install -y --no-install-recommends \ - nodejs \ + nodejs wget ca-certificates \ blackbox xvfb xdotool \ pulseaudio pulseaudio-utils \ dbus \ @@ -54,5 +54,6 @@ mv ts3bot-control* ts3bot #RUN chmod a+rx /usr/local/bin/youtube-dl # Clean up APT +apt-get autoremove --purge wget apt-get clean rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* From daf6bf8f7c8c95157b8a1e4205bb919cd172dd60 Mon Sep 17 00:00:00 2001 From: icedream Date: Sat, 24 Oct 2015 10:36:32 +0200 Subject: [PATCH 3/6] Pipe ts3bot-control archive through tar immediately. --- setup.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index 99b155e..40f0993 100644 --- a/setup.sh +++ b/setup.sh @@ -43,9 +43,8 @@ sed -i 's/^MS_PrintLicense$/#MS_PrintLicense/g' ./ts3client.run rm ./ts3client.run # Install TS3Bot -wget https://github.com/icedream/ts3bot-control/archive/${TS3BOT_COMMIT}.tar.gz -Ots3bot-control.tgz -/sbin/setuser app tar xvf ts3bot-control.tgz -rm ts3bot-control.tgz +wget https://github.com/icedream/ts3bot-control/archive/${TS3BOT_COMMIT}.tar.gz -O- |\ + /sbin/setuser app tar xzv mv ts3bot-control* ts3bot (cd ts3bot && /sbin/setuser app npm install) From b5fd982b7f64720a33fac25906c3aab4dd0240f1 Mon Sep 17 00:00:00 2001 From: icedream Date: Sat, 24 Oct 2015 10:37:06 +0200 Subject: [PATCH 4/6] Add non-interactive "yes" on purge. --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 40f0993..14e3f51 100644 --- a/setup.sh +++ b/setup.sh @@ -53,6 +53,6 @@ mv ts3bot-control* ts3bot #RUN chmod a+rx /usr/local/bin/youtube-dl # Clean up APT -apt-get autoremove --purge wget +apt-get autoremove -y --purge wget apt-get clean rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* From 408dc778b034d57ce145ee576e9bb69f8674b525 Mon Sep 17 00:00:00 2001 From: icedream Date: Sat, 24 Oct 2015 10:47:38 +0200 Subject: [PATCH 5/6] We don't NEED to update to NodeJS 4.x, do we? --- setup.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 14e3f51..abf4c69 100644 --- a/setup.sh +++ b/setup.sh @@ -12,11 +12,10 @@ rm -r /etc/service/cron /etc/service/nginx /etc/service/nginx-log-forwarder # Set up APT sources rm /etc/apt/sources.list.d/* add-apt-repository ppa:mc3man/trusty-media -y -curl -sL https://deb.nodesource.com/setup_4.x | bash - # Now install all packages we need apt-get install -y --no-install-recommends \ - nodejs wget ca-certificates \ + wget ca-certificates \ blackbox xvfb xdotool \ pulseaudio pulseaudio-utils \ dbus \ From 14623b59cc4c7021463cfe057418eba3e8c34d3a Mon Sep 17 00:00:00 2001 From: icedream Date: Sat, 24 Oct 2015 10:48:41 +0200 Subject: [PATCH 6/6] If we remove NodeJS' script we need to run apt-get update ourselves. --- setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.sh b/setup.sh index abf4c69..582f760 100644 --- a/setup.sh +++ b/setup.sh @@ -14,6 +14,7 @@ rm /etc/apt/sources.list.d/* add-apt-repository ppa:mc3man/trusty-media -y # Now install all packages we need +apt-get update apt-get install -y --no-install-recommends \ wget ca-certificates \ blackbox xvfb xdotool \