Add docker support for development.

This commit is contained in:
RainLoop 2018-02-27 01:59:21 +03:00 committed by RainLoop Team
parent 6e20d5fccc
commit 866b0ddc6d
11 changed files with 1088 additions and 709 deletions

233
.docker/mail/setup.sh Executable file
View 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' cant 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

View 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
View 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
View 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
View 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

4
.gitignore vendored
View file

@ -19,9 +19,11 @@
/build/dist
/build/tmp
/build/docker
/.docker/.cache
/.docker/mail/config
/dist
/data
.DS_Store
/tests/fix.php
/MULTIPLY
/include.php
/include.php

47
Makefile Normal file
View file

@ -0,0 +1,47 @@
#!make
rebuild: stop
docker-compose build --no-cache
up:
docker-compose up -d
@$(MAKE) status
stop:
docker-compose stop
@$(MAKE) status
down:
docker-compose down
restart:
@$(MAKE) stop
@$(MAKE) up
status:
@docker-compose ps
console-node:
@docker-compose run --no-deps --rm node sh
console-php:
@docker-compose exec php sh
console:
@$(MAKE) console-node
logs:
@docker-compose logs --tail=100 -f
logs-db:
@docker-compose logs --tail=100 -f db
logs-php:
@docker-compose logs --tail=100 -f php
logs-node:
@docker-compose logs --tail=100 -f node
logs-nginx:
@docker-compose logs --tail=100 -f nginx
logs-mail:
@docker-compose logs --tail=100 -f mail
rl-build:
@docker-compose run --no-deps --rm node gulp all
rl-build-pro:
@docker-compose run --no-deps --rm node gulp all --pro

View file

@ -1,24 +1,83 @@
version: '2'
services:
node:
image: node:8.4-alpine
working_dir: /usr/app
command: sh -c 'yarn install && yarn global add gulp@3.9.1 && gulp all:docker'
mail:
image: tvial/docker-mailserver:latest
hostname: mail
container_name: rl.mail
domainname: domain.com
restart: always
ports:
- 25:25
- 143:143
volumes:
- ./dev:/usr/app/dev
- ./rainloop:/usr/app/rainloop
- ./assets:/usr/app/assets
- ./vendors:/usr/app/vendors
- ./build/owncloud:/usr/app/build/owncloud
- ./dist:/usr/app/dist
- maildata:/var/mail
- mailstate:/var/mail-state
- ./.docker/mail/config/:/tmp/docker-mailserver/
environment:
- ENABLE_SPAMASSASSIN=0
- ENABLE_CLAMAV=0
- ENABLE_FAIL2BAN=0
- ENABLE_POSTGREY=0
- ENABLE_MANAGESIEVE=1
- ONE_DIR=1
- DMS_DEBUG=0
cap_add:
- NET_ADMIN
- SYS_PTRACE
db:
image: mysql:5.7
hostname: db
container_name: rl.db
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: rainloop
MYSQL_PASSWORD: rainloop
MYSQL_DATABASE: rainloop
volumes:
- mysql:/var/lib/mysql
- ./.docker/.cache/mysql/tmp:/tmp
php:
build:
context: ./.docker/php
hostname: php
container_name: rl.php
expose:
- 9000
depends_on:
- db
- mail
volumes:
- ./:/var/www
- ./.docker/php/rainloop.ini:/usr/local/etc/php/conf.d/rainloop.ini
- ./.docker/.cache/php/tmp:/tmp
node:
build:
context: ./.docker/node
hostname: node
container_name: rl.node
working_dir: /var/www
command: sh -c 'yarn install'
volumes:
- ./:/var/www
- ./.docker/.cache/node/tmp:/tmp
nginx:
image: nginx:latest
hostname: nginx
container_name: rl.nginx
depends_on:
- php
ports:
- 80:80
volumes:
- ./:/var/www
- ./.docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
- ./.docker/.cache/nginx/tmp:/tmp
- ./.eslintrc.js:/usr/app/.eslintrc.js
- ./gulpfile.js:/usr/app/gulpfile.js
- ./index.php:/usr/app/index.php
- ./package.json:/usr/app/package.json
- ./webpack.config.builder.js:/usr/app/webpack.config.builder.js
- ./webpack.config.js:/usr/app/webpack.config.js
- ./yarn.lock:/usr/app/yarn.lock
- ./build/docker/node_modules:/usr/app/node_modules
- ./build/docker/tmp:/tmp
volumes:
mysql:
driver: local
maildata:
driver: local
mailstate:
driver: local

File diff suppressed because it is too large Load diff

View file

@ -3,8 +3,8 @@
"title": "RainLoop Webmail",
"description": "Simple, modern & fast web-based email client",
"private": true,
"version": "1.11.3",
"ownCloudVersion": "5.0.5",
"version": "1.12.0",
"ownCloudVersion": "5.1.0",
"homepage": "http://rainloop.net",
"main": "gulpfile.js",
"author": {

View file

@ -1698,11 +1698,7 @@ elliptic@^6.0.0:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.0"
email-addresses@3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/email-addresses/-/email-addresses-3.0.1.tgz#c1fc20c189e7f96d4012d375db5feaccdd24391c"
emailjs-addressparser@^1.0.1:
emailjs-addressparser@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/emailjs-addressparser/-/emailjs-addressparser-1.0.1.tgz#8b19b38f6ee67ba176a31a97f45678dc12e549cf"
@ -3173,20 +3169,12 @@ istextorbinary@1.0.2:
binaryextensions "~1.0.0"
textextensions "~1.0.0"
jasmine-reporters@~0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/jasmine-reporters/-/jasmine-reporters-0.2.1.tgz#395f6e5170692de1a966cd95a70d7a37bf3f2bc3"
jquery-backstretch@2.1.16:
version "2.1.16"
resolved "https://registry.yarnpkg.com/jquery-backstretch/-/jquery-backstretch-2.1.16.tgz#4ee7547dcb85cf69eed2639cac0c9131651dc5e7"
dependencies:
jquery "^3.1.1"
jquery-lazyload@1.9.7:
version "1.9.7"
resolved "https://registry.yarnpkg.com/jquery-lazyload/-/jquery-lazyload-1.9.7.tgz#9982b388c533c0b611214b3c5aaa0b9fede071f7"
jquery-mousewheel@3.1.13:
version "3.1.13"
resolved "https://registry.yarnpkg.com/jquery-mousewheel/-/jquery-mousewheel-3.1.13.tgz#06f0335f16e353a695e7206bf50503cb523a6ee5"
@ -3303,25 +3291,18 @@ klaw@^1.0.0:
optionalDependencies:
graceful-fs "^4.1.9"
"knockout-projections@github:stevesanderson/knockout-projections#v1.1.0":
version "1.1.0"
resolved "https://codeload.github.com/stevesanderson/knockout-projections/tar.gz/01cb07b27b305c0240de7aa92687110e68432706"
dependencies:
jasmine-reporters "~0.2.1"
knockout "~3.0.0"
knockout-sortable@0.14.1:
version "0.14.1"
resolved "https://registry.yarnpkg.com/knockout-sortable/-/knockout-sortable-0.14.1.tgz#bdf40412451969729d0dd37c61bb7333cdd46e1e"
knockout-transformations@2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/knockout-transformations/-/knockout-transformations-2.1.0.tgz#c9a9148dbe1649dc00518eccea704379aadb0097"
knockout@3.4.2:
version "3.4.2"
resolved "https://registry.yarnpkg.com/knockout/-/knockout-3.4.2.tgz#e87958de77ad1e936f7ce645bab8b5d7c456d937"
knockout@~3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/knockout/-/knockout-3.0.0.tgz#fd8d43ee446237cde7df650f5c7dbcf68ae49a80"
lazy-cache@^1.0.3:
version "1.0.4"
resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e"