diff --git a/Dockerfile b/Dockerfile index cd81ec8..e284340 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM basessh +FROM ubuntu:trusty MAINTAINER Dave P # Create nexus user @@ -6,17 +6,24 @@ RUN useradd --create-home nexus ; \ echo "nexus:nexus" | chpasswd # Install nginx -RUN apt-get install -y nginx-light fcgiwrap +RUN apt-get update ;\ + apt-get install -y nginx-light fcgiwrap supervisor openssh-server cron ;\ + mkdir /start.d /nexus /var/run/sshd ;\ + chown nexus /nexus # Configure nginx RUN echo "daemon off;" >> /etc/nginx/nginx.conf ; cp /usr/share/doc/fcgiwrap/examples/nginx.conf /etc/nginx/fcgiwrap.conf -COPY nginx.conf /etc/supervisor/conf.d/nginx.conf -COPY fcgiwrap.conf /etc/supervisor/conf.d/fcgiwrap.conf -COPY default /etc/nginx/sites-available/default -COPY clear-sockets /start.d/clear-sockets +ADD supervisor.conf /etc/supervisor/conf.d/supervisor.conf +ADD nginx.conf /etc/supervisor/conf.d/nginx.conf +ADD fcgiwrap.conf /etc/supervisor/conf.d/fcgiwrap.conf +ADD sshd.conf /etc/supervisor/conf.d/sshd.conf +ADD cron.conf /etc/supervisor/conf.d/cron.conf +ADD default /etc/nginx/sites-available/default +ADD clear-sockets /start.d/clear-sockets +ADD gen-ssh /start.d/gen-ssh +ADD start /start RUN chmod +x /start.d/clear-sockets EXPOSE 80 - diff --git a/clear-sockets b/clear-sockets old mode 100644 new mode 100755 index 8098265..2a42239 --- a/clear-sockets +++ b/clear-sockets @@ -1,3 +1,3 @@ #!/bin/sh -rm /tmp/fcgiwrap.socket +rm -f /tmp/fcgiwrap.socket diff --git a/cron.conf b/cron.conf new file mode 100644 index 0000000..25ee24b --- /dev/null +++ b/cron.conf @@ -0,0 +1,3 @@ +[program:cron] +command=/usr/sbin/cron -f +autorestart=true \ No newline at end of file diff --git a/gen-ssh b/gen-ssh new file mode 100755 index 0000000..9ebe112 --- /dev/null +++ b/gen-ssh @@ -0,0 +1,4 @@ +# Regenerate ssh key per container +dpkg-reconfigure openssh-server + +rm /start.d/gen-ssh diff --git a/sshd.conf b/sshd.conf new file mode 100644 index 0000000..161e1c8 --- /dev/null +++ b/sshd.conf @@ -0,0 +1,3 @@ +[program:sshd] +command=/usr/sbin/sshd -D +autorestart=true diff --git a/start b/start old mode 100644 new mode 100755 index e2d1db2..3812a50 --- a/start +++ b/start @@ -1,14 +1,12 @@ #!/bin/bash -if [ ! -f /etc/ssh/sshd_config ]; then - # Regenerate ssh key per container - dpkg-reconfigure openssh-server -fi - -chown nexus /nexus +# run everything in start.d +find /start.d -type f -executable -exec {} \; # Cleanly kill supervisor when container is stopped trap 'kill $(jobs -p)' EXIT +chown nexus /nexus + # start services supervisord diff --git a/supervisor.conf b/supervisor.conf new file mode 100644 index 0000000..54296b8 --- /dev/null +++ b/supervisor.conf @@ -0,0 +1,2 @@ +[supervisord] +nodaemon=true