1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-22 02:17:26 +00:00

Merge branch 'better_docker' of https://github.com/pjz/mailinabox into pjz-better_docker

our trees had diverged, various conflicts resolved
This commit is contained in:
Joshua Tauberer 2014-05-02 14:54:21 -04:00
commit 0659a0bb16
3 changed files with 87 additions and 19 deletions

View File

@ -14,8 +14,25 @@
# otherwise the container won't start) # otherwise the container won't start)
# sudo docker.io run -d -p 22 -p 25:25 -p 53:53/udp -p 443:443 -p 587:587 -p 993:993 box # sudo docker.io run -d -p 22 -p 25:25 -p 53:53/udp -p 443:443 -p 587:587 -p 993:993 box
FROM ubuntu:14.04 ###########################################
# We need a better starting image than docker's ubuntu image because that
# base image doesn't provide enough to run most Ubuntu services. See
# http://phusion.github.io/baseimage-docker/ for an explanation. They
# provide a better image, but their latest is for an earlier Ubuntu
# version. When they get to Ubuntu 14.04 we'll want to use:
#
# FROM phusion/baseimage:<version-based-on-14.04>
#
# Until then, use an upgraded image provided by @pjz, based on his
# PR: https://github.com/phusion/baseimage-docker/pull/64
FROM pjzz/phusion-baseimage:0.9.10
# based originally on ubuntu:14.04
# Dockerfile metadata.
MAINTAINER Joshua Tauberer (http://razor.occams.info) MAINTAINER Joshua Tauberer (http://razor.occams.info)
EXPOSE 22 25 53 443 587 993
# We can't know these values ahead of time, so set them to something # We can't know these values ahead of time, so set them to something
# obviously local. The start.sh script will need to be run again once # obviously local. The start.sh script will need to be run again once
@ -28,8 +45,8 @@ ENV PUBLIC_IP 192.168.200.1
ENV DISABLE_FIREWALL 1 ENV DISABLE_FIREWALL 1
# Our install will fail if SSH is installed and allows password-based authentication. # Our install will fail if SSH is installed and allows password-based authentication.
RUN DEBIAN_FRONTEND=noninteractive apt-get install -qq -y openssh-server # The base image already installs openssh-server. Just edit its configuration.
RUN sed -i /etc/ssh/sshd_config -e "s/^#PasswordAuthentication yes/PasswordAuthentication no/g" RUN sed -i -e "s/^#*\s*PasswordAuthentication \(yes\|no\)/PasswordAuthentication no/g" /etc/ssh/sshd_config
# Add this repo into the image so we have the configuration scripts. # Add this repo into the image so we have the configuration scripts.
ADD scripts /usr/local/mailinabox/scripts ADD scripts /usr/local/mailinabox/scripts
@ -37,9 +54,11 @@ ADD conf /usr/local/mailinabox/conf
ADD tools /usr/local/mailinabox/tools ADD tools /usr/local/mailinabox/tools
# Start the configuration. # Start the configuration.
RUN cd /usr/local/mailinabox; scripts/start.sh RUN cd /usr/local/mailinabox && scripts/start.sh
# How the instance is launched. # Configure services for docker.
ADD containers/docker /usr/local/mailinabox/containers/docker ADD containers/docker /usr/local/mailinabox/containers/docker
CMD bash /usr/local/mailinabox/containers/docker/start_services.sh RUN /usr/local/mailinabox/containers/docker/setup_services.sh
EXPOSE 22 25 53 443 587 993
# How the container is launched.
CMD bash /usr/local/mailinabox/containers/docker/container_start.sh

View File

@ -20,15 +20,6 @@ if grep "^PUBLIC_IP=192.168.200.1" /etc/mailinabox.conf > /dev/null; then
scripts/start.sh scripts/start.sh
fi fi
echo "Starting Mail-in-a-Box services..."
service nsd start
service postfix start
dovecot # it's integration with Upstart doesn't work in docker
service opendkim start
service nginx start
service php-fastcgi start
if [ -t 0 ] if [ -t 0 ]
then then
# This is an interactive shell. You get a command prompt within # This is an interactive shell. You get a command prompt within
@ -40,11 +31,11 @@ then
bash bash
else else
# This is a non-interactive shell. It loops forever to prevent # This is a non-interactive shell. Just display status. Because
# the docker container from stopping. # other services are running, the container remains running after
# this script exits.
# #
# You get here by omitting '-t' from the docker run arguments. # You get here by omitting '-t' from the docker run arguments.
echo "Your Mail-in-a-Box is running..." echo "Your Mail-in-a-Box is running..."
while true; do sleep 10; done
fi fi

View File

@ -0,0 +1,58 @@
#!/bin/bash
echo "Setting up Mail-in-a-Box services..."
SERVICES="nsd postfix dovecot opendkim nginx php-fastcgi"
for service in $SERVICES; do
mkdir -p /etc/service/$service
done
cat <<EORUN >/etc/service/nsd/run
#!/bin/sh
exec /usr/bin/nsd -d
EORUN
cat <<EORUN >/etc/service/postfix/run
#!/bin/sh
# from http://smarden.org/runit/runscripts.html#postfix
exec 1>&2
daemon_directory=/usr/lib/postfix \
command_directory=/usr/sbin \
config_directory=/etc/postfix \
queue_directory=/var/spool/postfix \
mail_owner=postfix \
setgid_group=postdrop \
/etc/postfix/postfix-script check || exit 1
exec /usr/lib/postfix/master
EORUN
cat <<EORUN >/etc/service/dovecot/run
#!/bin/sh
exec dovecot
EORUN
cat <<EORUN >/etc/service/opendkim/run
#!/bin/sh
exec opendkim -f -x /etc/opendkim.conf -u opendkim -P /var/run/opendkim/opendkim.pid
EORUN
echo "daemon off;" >> /etc/nginx/nginx.conf
cat <<EORUN >/etc/service/nginx/run
#!/bin/sh
exec nginx
EORUN
cat <<EORUN >/etc/service/php-fastcgi/run
#!/bin/bash
export PHP_FCGI_CHILDREN=4 PHP_FCGI_MAX_REQUESTS=1000
exec /usr/bin/php-cgi -q -b /tmp/php-fastcgi.www-data.sock -c /etc/php5/cgi/php.ini
EORUN
for service in $SERVICES; do
chmod a+x /etc/service/$service/run
done
echo "Your Mail-in-a-Box services are configured."