mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 04:29:21 +03:00
Add docker support for development.
This commit is contained in:
parent
6e20d5fccc
commit
866b0ddc6d
11 changed files with 1088 additions and 709 deletions
233
.docker/mail/setup.sh
Executable file
233
.docker/mail/setup.sh
Executable file
|
|
@ -0,0 +1,233 @@
|
|||
#! /bin/sh
|
||||
|
||||
##
|
||||
# Wrapper for various setup scripts included in the docker-mailserver
|
||||
#
|
||||
|
||||
INFO=$(docker ps \
|
||||
--no-trunc \
|
||||
--format="{{.Image}}\t{{.Names}}\t{{.Command}}" | \
|
||||
grep "/bin/sh -c 'supervisord -c /etc/supervisor/supervisord.conf'")
|
||||
|
||||
IMAGE_NAME=$(echo $INFO | awk '{print $1}')
|
||||
CONTAINER_NAME=$(echo $INFO | awk '{print $2}')
|
||||
CONFIG_PATH="$(pwd)/config"
|
||||
|
||||
if [ -z "$IMAGE_NAME" ]; then
|
||||
IMAGE_NAME=tvial/docker-mailserver:latest
|
||||
fi
|
||||
|
||||
_inspect() {
|
||||
if _docker_image_exists "$IMAGE_NAME"; then
|
||||
echo "Image: $IMAGE_NAME"
|
||||
else
|
||||
echo "Image: '$IMAGE_NAME' can’t be found."
|
||||
fi
|
||||
if [ -n "$CONTAINER_NAME" ]; then
|
||||
echo "Container: $CONTAINER_NAME"
|
||||
else
|
||||
echo "Container: Not running, please start docker-mailserver."
|
||||
fi
|
||||
}
|
||||
|
||||
_usage() {
|
||||
echo "Usage: $0 [-i IMAGE_NAME] [-c CONTAINER_NAME] <subcommand> <subcommand> [args]
|
||||
|
||||
OPTIONS:
|
||||
|
||||
-i IMAGE_NAME The name of the docker-mailserver image, by default
|
||||
'tvial/docker-mailserver:latest'.
|
||||
-c CONTAINER_NAME The name of the running container.
|
||||
|
||||
-p PATH config folder path (default: $(pwd)/config)
|
||||
|
||||
SUBCOMMANDS:
|
||||
|
||||
email:
|
||||
|
||||
$0 email add <email> [<password>]
|
||||
$0 email update <email> [<password>]
|
||||
$0 email del <email>
|
||||
$0 email restrict <add|del|list> <send|receive> [<email>]
|
||||
$0 email list
|
||||
|
||||
alias:
|
||||
$0 alias add <email> <recipient>
|
||||
$0 alias del <email> <recipient>
|
||||
$0 alias list
|
||||
|
||||
config:
|
||||
|
||||
$0 config dkim
|
||||
$0 config ssl
|
||||
|
||||
debug:
|
||||
|
||||
$0 debug fetchmail
|
||||
$0 debug fail2ban [<unban> <ip-address>]
|
||||
$0 debug show-mail-logs
|
||||
$0 debug inspect
|
||||
$0 debug login <commands>
|
||||
"
|
||||
exit 1
|
||||
}
|
||||
|
||||
_docker_image_exists() {
|
||||
if docker history -q "$1" >/dev/null 2>&1; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
_docker_image() {
|
||||
if ! _docker_image_exists "$IMAGE_NAME"; then
|
||||
echo "Image '$IMAGE_NAME' not found. Pulling ..."
|
||||
docker pull "$IMAGE_NAME"
|
||||
fi
|
||||
docker run \
|
||||
--rm \
|
||||
-v "$CONFIG_PATH":/tmp/docker-mailserver \
|
||||
-ti "$IMAGE_NAME" $@
|
||||
}
|
||||
|
||||
_docker_container() {
|
||||
if [ -n "$CONTAINER_NAME" ]; then
|
||||
docker exec -ti "$CONTAINER_NAME" $@
|
||||
else
|
||||
echo "The docker-mailserver is not running!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
while getopts ":c:i:p:" OPT; do
|
||||
case $OPT in
|
||||
c)
|
||||
CONTAINER_NAME="$OPTARG"
|
||||
;;
|
||||
i)
|
||||
IMAGE_NAME="$OPTARG"
|
||||
;;
|
||||
p)
|
||||
case "$OPTARG" in
|
||||
/*)
|
||||
CONFIG_PATH="$OPTARG"
|
||||
;;
|
||||
*)
|
||||
CONFIG_PATH="$(pwd)/$OPTARG"
|
||||
;;
|
||||
esac
|
||||
if [ ! -d "$CONFIG_PATH" ]; then
|
||||
echo "Directory doesn't exist"
|
||||
_usage
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
|
||||
case $1 in
|
||||
|
||||
email)
|
||||
shift
|
||||
case $1 in
|
||||
add)
|
||||
shift
|
||||
_docker_image addmailuser $@
|
||||
;;
|
||||
update)
|
||||
shift
|
||||
_docker_image updatemailuser $@
|
||||
;;
|
||||
del)
|
||||
shift
|
||||
_docker_image delmailuser $@
|
||||
;;
|
||||
restrict)
|
||||
shift
|
||||
_docker_container restrict-access $@
|
||||
;;
|
||||
list)
|
||||
_docker_image listmailuser
|
||||
;;
|
||||
*)
|
||||
_usage
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
alias)
|
||||
shift
|
||||
case $1 in
|
||||
add)
|
||||
shift
|
||||
_docker_image addalias $@
|
||||
;;
|
||||
del)
|
||||
shift
|
||||
_docker_image delalias $@
|
||||
;;
|
||||
list)
|
||||
shift
|
||||
_docker_image listalias $@
|
||||
;;
|
||||
*)
|
||||
_usage
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
config)
|
||||
shift
|
||||
case $1 in
|
||||
dkim)
|
||||
_docker_image generate-dkim-config
|
||||
;;
|
||||
ssl)
|
||||
_docker_image generate-ssl-certificate
|
||||
;;
|
||||
*)
|
||||
_usage
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
debug)
|
||||
shift
|
||||
case $1 in
|
||||
fetchmail)
|
||||
_docker_image debug-fetchmail
|
||||
;;
|
||||
fail2ban)
|
||||
shift
|
||||
_docker_container fail2ban $@
|
||||
;;
|
||||
show-mail-logs)
|
||||
_docker_container cat /var/log/mail/mail.log
|
||||
;;
|
||||
inspect)
|
||||
_inspect
|
||||
;;
|
||||
login)
|
||||
shift
|
||||
if [ -z "$1" ]; then
|
||||
_docker_container /bin/bash
|
||||
else
|
||||
_docker_container /bin/bash -c "$@"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
_usage
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
*)
|
||||
_usage
|
||||
;;
|
||||
esac
|
||||
47
.docker/nginx/default.conf
Normal file
47
.docker/nginx/default.conf
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
server {
|
||||
listen 80 default;
|
||||
server_name localhost _;
|
||||
root /var/www;
|
||||
|
||||
index index.php index.html;
|
||||
|
||||
autoindex on;
|
||||
charset utf-8;
|
||||
client_max_body_size 500m;
|
||||
|
||||
gzip on;
|
||||
gzip_disable "msie6";
|
||||
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
|
||||
gzip_vary on;
|
||||
|
||||
access_log /var/log/nginx/default.access.log;
|
||||
error_log /var/log/nginx/default.error.log;
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location ~* favicon\.(ico|png)$ { access_log off; log_not_found off; }
|
||||
location = /browserconfig.xml { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
location = /humans.txt { access_log off; log_not_found off; }
|
||||
location = /apple-touch-icon.png { access_log off; log_not_found off; }
|
||||
location = /apple-touch-icon-precomposed.png { access_log off; log_not_found off; }
|
||||
location ~ /\.ht { deny all; return 404; }
|
||||
location ~ /\.git { deny all; return 404; }
|
||||
location ~ /\.svn { deny all; return 404; }
|
||||
|
||||
location ~* ^.+\.(?:jpe?g|gif|bmp|ico|png|css|js|swf)$ {
|
||||
expires 30d;
|
||||
access_log off;
|
||||
add_header Pragma public;
|
||||
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
|
||||
}
|
||||
|
||||
location ~ \.php(/|$) {
|
||||
include fastcgi_params;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param HTTPS off;
|
||||
fastcgi_pass php:9000;
|
||||
}
|
||||
}
|
||||
5
.docker/node/Dockerfile
Normal file
5
.docker/node/Dockerfile
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
FROM node:8.4-alpine
|
||||
|
||||
RUN yarn global add gulp@3.9.1
|
||||
|
||||
CMD ["node", "--version"]
|
||||
27
.docker/php/Dockerfile
Normal file
27
.docker/php/Dockerfile
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
FROM php:7.1-fpm
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
RUN apt-get install -y \
|
||||
git unzip wget zip curl mlocate \
|
||||
libmcrypt-dev libicu-dev libpcre3-dev libicu-dev \
|
||||
build-essential chrpath libssl-dev \
|
||||
libxft-dev libfreetype6 libfreetype6-dev \
|
||||
libpng-dev libjpeg62-turbo-dev \
|
||||
libfontconfig1 libfontconfig1-dev libzip-dev
|
||||
|
||||
RUN docker-php-ext-configure intl && \
|
||||
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
|
||||
docker-php-ext-install opcache pdo_mysql mcrypt zip intl gd
|
||||
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
RUN curl --location --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit.phar && chmod +x /usr/local/bin/phpunit
|
||||
|
||||
RUN apt-get -y autoremove && apt-get clean
|
||||
|
||||
RUN sed -i '/^;catch_workers_output/ccatch_workers_output = yes' '/usr/local/etc/php-fpm.d/www.conf'
|
||||
|
||||
EXPOSE 9000
|
||||
|
||||
CMD ["php-fpm"]
|
||||
8
.docker/php/rainloop.ini
Normal file
8
.docker/php/rainloop.ini
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
date.timezone = UTC
|
||||
upload_max_filesize = 1G
|
||||
post_max_size = 1G
|
||||
|
||||
# log_errors = On
|
||||
# display_errors = On
|
||||
# error_reporting = E_ALL
|
||||
# error_log = /dev/stderr
|
||||
Loading…
Add table
Add a link
Reference in a new issue