Prepare various background tasks.

This commit is contained in:
Glenn Y. Rolland 2014-08-13 00:34:00 +02:00
parent 3d85ecc049
commit deff39cd5f
6 changed files with 38 additions and 6 deletions

View file

@ -3,14 +3,30 @@ MAINTAINER Glenn Y. Rolland <glenux@glenux.net>
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -q -y supervisor
RUN apt-get install -q -y reprepro
# Install supervisor for managing services
RUN apt-get install -q -y supervisor cron openssh-server pwgen reprepro screen vim-tiny
RUN service supervisor stop
ADD configs/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Install cron for managing regular tasks
ADD configs/supervisor-cron.conf /etc/supervisor/conf.d/cron.conf
RUN sed -i 's/\(session *required *pam_loginuid.so\)/#\1/' /etc/pam.d/cron
# Install ssh
ADD configs/supervisor-ssh.conf /etc/supervisor/conf.d/ssh.conf
RUN mkdir /var/run/sshd
ENV DEBIAN_FRONTEND newt
VOLUME /data
ADD scripts/start.sh /start.sh
RUN chmod 755 /start.sh
VOLUME /data
EXPOSE 80
EXPOSE 22
CMD ["/bin/bash", "/start.sh"]

View file

@ -2,3 +2,6 @@
build:
docker build -t glenux/debian-repo .
run:
docker run -i -t glenux/debian-repo /bin/bash

View file

@ -0,0 +1,2 @@
[program:cron]
command=/usr/sbin/cron -f

View file

@ -0,0 +1,2 @@
[program:ssh]
command=/usr/sbin/sshd -D

2
configs/supervisord.conf Normal file
View file

@ -0,0 +1,2 @@
[supervisord]
nodaemon=true

View file

@ -3,13 +3,20 @@
# Many thanks to John Fink <john.fink@gmail.com> for the
# inspiration and to his great work on docker-wordpress'
# let's create a user to ssh into
# let's create a user to SSH into
SSH_USERPASS=`pwgen -c -n -1 8`
mkdir /home/user
useradd -G sudo -d /home/user user
chown user /home/user
echo user:$SSH_USERPASS | chpasswd
echo ssh user password: $SSH_USERPASS
echo "user:$SSH_USERPASS" | chpasswd
echo "ssh user password: $SSH_USERPASS"
CRONFILE=`mktemp`
cat > $CRONFILE <<EOF
* * * * * echo "pif" >> /home/user/pif.log
EOF
crontab -u user $CRONFILE
rm -f $CRONFILE
supervisord -n