From 99f5a16c47274adc215b8fd7dab703d726f7886b Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Wed, 13 Aug 2014 13:28:11 +0200 Subject: [PATCH] Finalize with nginx. --- Dockerfile | 39 ++++++++++++++------- Makefile | 14 ++++---- TODO.md | 0 configs/nginx-default.conf | 16 +++++++++ configs/reprepro-distributions | 17 +++++++++ configs/supervisor-nginx.conf | 4 +++ keys/warbrain@dyction.pub | 1 + scripts/{reprepro.sh => reprepro-import.sh} | 8 ++--- scripts/start.sh | 11 ++++-- 9 files changed, 84 insertions(+), 26 deletions(-) create mode 100644 TODO.md create mode 100644 configs/nginx-default.conf create mode 100644 configs/reprepro-distributions create mode 100644 configs/supervisor-nginx.conf create mode 100644 keys/warbrain@dyction.pub rename scripts/{reprepro.sh => reprepro-import.sh} (91%) diff --git a/Dockerfile b/Dockerfile index cc91356..6ac0223 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,37 +6,52 @@ RUN apt-get update # Install supervisor for managing services -RUN apt-get install -q -y supervisor cron openssh-server pwgen reprepro screen vim-tiny sudo - -RUN service supervisor stop -ADD configs/supervisord.conf /etc/supervisor/conf.d/supervisord.conf +RUN apt-get install -q -y supervisor cron openssh-server pwgen reprepro screen vim-tiny sudo nginx +# Configure cron # 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 +# Install ssh (run/stop to create required directories) RUN mkdir /var/run/sshd -RUN service ssh start ; sleep 1 +#RUN service ssh start ; sleep 1 RUN service ssh stop + +# Configure reprepro +ADD scripts/reprepro-import.sh /usr/local/sbin/reprepro-import +RUN chmod 755 /usr/local/sbin/reprepro-import +RUN mkdir -p /var/lib/reprepro/conf +ADD configs/reprepro-distributions /var/lib/reprepro/conf/distributions + +# Configure nginx +RUN echo "daemon off;" >> /etc/nginx/nginx.conf +RUN rm -f /etc/nginx/sites-enabled/default +ADD configs/nginx-default.conf /etc/nginx/sites-enabled/default + # Setup root & sudo access RUN echo "root:docker" | chpasswd RUN echo %sudo ALL=NOPASSWD: ALL >> /etc/sudoers +# Configure supervisor +RUN service supervisor stop +ADD configs/supervisord.conf /etc/supervisor/conf.d/supervisord.conf +ADD configs/supervisor-cron.conf /etc/supervisor/conf.d/cron.conf +ADD configs/supervisor-ssh.conf /etc/supervisor/conf.d/ssh.conf +ADD configs/supervisor-nginx.conf /etc/supervisor/conf.d/nginx.conf + +# Finalize ENV DEBIAN_FRONTEND newt -ADD scripts/start.sh /start.sh -RUN chmod 755 /start.sh +ADD scripts/start.sh /usr/local/sbin/start +RUN chmod 755 /usr/local/sbin/start VOLUME ["/docker/keys", "/docker/incoming"] EXPOSE 80 EXPOSE 22 -CMD ["/bin/bash", "/start.sh"] - +CMD ["/usr/local/sbin/start"] diff --git a/Makefile b/Makefile index 8c2ebd2..495ceb2 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,16 @@ DEBUG=0 -ifeq ($(DEBUG),0) -RUNCMD= -else -RUNCMD=-i /bin/bash -endif - build: docker build -t glenux/debian-repo . run: - ID=$$(docker run -v $$(pwd)/keys:/docker/keys -d -t glenux/debian-repo $(RUNCMD)); \ + ID=$$(docker run -v $$(pwd)/keys:/docker/keys -d -i -t glenux/debian-repo); \ (docker inspect $$ID |sed -n -e 's/.*"IPAddress": "\(.*\)".*/\1/p'); \ docker logs -f $$ID +test: + docker run -v $$(pwd)/keys:/docker/keys \ + --rm=true \ + -i -t glenux/debian-repo \ + /bin/bash + diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..e69de29 diff --git a/configs/nginx-default.conf b/configs/nginx-default.conf new file mode 100644 index 0000000..efff12e --- /dev/null +++ b/configs/nginx-default.conf @@ -0,0 +1,16 @@ +server { + listen 80 default_server; + listen [::]:80 default_server ipv6only=on; + + root /var/www; + index index.html index.htm; + + # Make site accessible from http://localhost/ + server_name localhost; + autoindex on; + + location / { + try_files $uri $uri/ =404; + } + +} diff --git a/configs/reprepro-distributions b/configs/reprepro-distributions new file mode 100644 index 0000000..c8d5d9d --- /dev/null +++ b/configs/reprepro-distributions @@ -0,0 +1,17 @@ +Origin: Glenn Y. Rolland +Label: Glenux Truc +Suite: unstable +Codename: sid +Version: 3.1 +Architectures: i386 amd64 powerpc source +Components: main non-free contrib +Description: Glenux.Net Repository Unstable + +Origin: Glenn Y. Rolland +Label: Glenux Truc +Suite: testing +Codename: wheezy +Version: 3.1 +Architectures: i386 amd64 powerpc source +Components: main non-free contrib +Description: Glenux.Net Repository Testing diff --git a/configs/supervisor-nginx.conf b/configs/supervisor-nginx.conf new file mode 100644 index 0000000..cb48b65 --- /dev/null +++ b/configs/supervisor-nginx.conf @@ -0,0 +1,4 @@ +[program:nginx] +command=/usr/sbin/nginx +stdout_events_enabled=true +stderr_events_enabled=true diff --git a/keys/warbrain@dyction.pub b/keys/warbrain@dyction.pub new file mode 100644 index 0000000..9b9eaad --- /dev/null +++ b/keys/warbrain@dyction.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC19zZUOjrv/COz8v7J8LI4/kP/BI3xKDG4dsNxzW0ZGQw3ZC2dYZsvmOCNJJMbxzzFjwGzlfXoiqjDrFQ6aOZHrvudL29PE4/RYCn2DMZO5YwEnpkfXArPZ9pxpLbvY+tXReUF7+bRA56BDUEYYAVaP7QfLs1SFcLuHW9lBHEOrJD8oQWr7GvEVyVMRMOIEIngYDut3HwpKk1tweQk0GDG1JpBi4TUXEPQKIwP5aGpojLSM5w2/Q+0ohm4BKO9CFoLhL4Nptu57CuTcfSBoHt72Yg3dd9dVrao3vGRQiYmnxp3WUGGD//qzcRApHxSvoz20usfX/pDKks+f4UT+FUZ warbrain@dyction diff --git a/scripts/reprepro.sh b/scripts/reprepro-import.sh similarity index 91% rename from scripts/reprepro.sh rename to scripts/reprepro-import.sh index 2b91b8c..77db325 100644 --- a/scripts/reprepro.sh +++ b/scripts/reprepro-import.sh @@ -1,8 +1,8 @@ #!/bin/sh -BASEDIR=$HOME/debian -INCOMING=$BASEDIR/incoming -OUTDIR=$HOME/public_html/debian +BASEDIR=/var/lib/reprepro +INCOMING=/docker/incoming +OUTDIR=/var/www/debian # # Make sure we're in the apt/ directory @@ -62,4 +62,4 @@ for i in $INCOMING/*.changes; do # Finally delete the .changes file itself. rm $i done - +chown -R www-data:www-data $OUTDIR diff --git a/scripts/start.sh b/scripts/start.sh index 4af970a..5fb8f26 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -9,7 +9,9 @@ SSH_USERPASS=`pwgen -c -n -1 8` mkdir /home/user useradd -G sudo -d /home/user -s /bin/bash user -chown user /home/user +chown -R user /home/user +chown -R user /docker/incoming + echo "user:$SSH_USERPASS" | chpasswd echo "ssh user password: $SSH_USERPASS" @@ -26,10 +28,13 @@ chown -R user /home/user/.ssh # load cron CRONFILE=`mktemp` cat > $CRONFILE <> /home/user/pif.log +* * * * * reprepro-import >> /var/log/reprepro.log EOF -crontab -u user $CRONFILE +crontab -u root $CRONFILE rm -f $CRONFILE +# run import once, to create the right directory structure +reprepro-import + supervisord -n