mirror of
https://github.com/Sabai-Technologies/sogo-docker.git
synced 2026-01-23 08:32:23 +00:00
initial commit
This commit is contained in:
commit
179be6694b
7 changed files with 266 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
.idea
|
||||
*.iml
|
||||
37
Dockerfile
Normal file
37
Dockerfile
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
FROM debian:stretch-slim
|
||||
|
||||
ENV \
|
||||
LC_ALL=C \
|
||||
LANG=C \
|
||||
DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
COPY ["script", "/usr/local/bin/"]
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
wget \
|
||||
mysql-client \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
gnupg \
|
||||
dirmngr
|
||||
|
||||
RUN mkdir /usr/share/doc/sogo \
|
||||
&& touch /usr/share/doc/sogo/empty.sh \
|
||||
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-key 0x810273C4 \
|
||||
&& echo "deb http://packages.inverse.ca/SOGo/nightly/4/debian/ stretch stretch" > /etc/apt/sources.list.d/sogo.list \
|
||||
&& apt-get update && apt-get install -y --force-yes \
|
||||
sogo \
|
||||
sogo-activesync \
|
||||
&& apt-get autoremove --purge \
|
||||
&& wget -qO- $(wget -nv -qO- https://api.github.com/repos/jwilder/dockerize/releases/latest \
|
||||
| grep -E 'browser_.*dockerize-linux-amd64' | cut -d\" -f4) | tar xzv -C /usr/local/bin/ \
|
||||
&& rm -rf /var/lib/apt/lists/* /var/log/* /tmp/* /var/tmp/* \
|
||||
&& chmod o+x -R /usr/local/bin/
|
||||
|
||||
EXPOSE 20000
|
||||
|
||||
VOLUME /usr/lib/GNUstep/SOGo/WebServerResources
|
||||
|
||||
USER sogo
|
||||
|
||||
CMD ["start.sh"]
|
||||
59
docker-compose.yml
Normal file
59
docker-compose.yml
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
version: '2'
|
||||
|
||||
services:
|
||||
sogo:
|
||||
build: .
|
||||
container_name: sogo
|
||||
ports:
|
||||
- 20000:20000
|
||||
environment:
|
||||
- MYSQL_SERVER=mariadb
|
||||
- MYSQL_ROOT_PASSWORD=test
|
||||
- MYSQL_USER=sogo
|
||||
- MYSQL_USER_PASSWORD=sogoPassword
|
||||
- MYSQL_DATABASE_NAME=sogo
|
||||
- SOGO_SOGoIMAPServer="imaps://imap.server.com:143/?tls=yes"
|
||||
- SOGO_SOGoSMTPServer=smtp.server.com
|
||||
- SOGO_SOGoMailDomain=server.com
|
||||
- SOGO_SOGoMailingMechanism=smtp
|
||||
- SOGO_SOGoSMTPAuthenticationType=PLAIN
|
||||
- SOGO_SOGoForceExternalLoginWithEmail=YES
|
||||
- SOGO_NGImap4ConnectionStringSeparator="."
|
||||
- SOGO_SOGoPasswordChangeEnabled=NO
|
||||
- SOGO_SOGoForwardEnabled=YES
|
||||
- SOGO_SOGoSieveScriptsEnabled=YES
|
||||
- SOGO_SOGoTimeZone=Europe/Paris
|
||||
- SOGO_WorkersCount=4
|
||||
- SOGO_SOGoCalendarDefaultRoles=("PublicDAndTViewer","ConfidentialDAndTViewer","PrivateDAndTViewer")
|
||||
- SOGO_SOGoUserSources=({
|
||||
canAuthenticate = YES;
|
||||
displayName = "SOGo Users";
|
||||
id = users; isAddressBook = YES;
|
||||
type = sql;
|
||||
userPasswordAlgorithm = md5;
|
||||
viewURL ="mysql://sogo:sogoPassword@mariadb:3306/sogo/sogo_users";
|
||||
KindFieldName = kind;
|
||||
MultipleBookingsFieldName = multiple_bookings;
|
||||
})
|
||||
|
||||
nginx:
|
||||
image: nginx
|
||||
container_name: nginx
|
||||
links:
|
||||
- sogo
|
||||
volumes_from:
|
||||
- sogo:ro
|
||||
ports:
|
||||
- 80:80
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
|
||||
mariadb:
|
||||
image: mariadb:10.1
|
||||
container_name: mariadb
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=test
|
||||
ports:
|
||||
- 3306:3306
|
||||
volumes:
|
||||
- "./data:/var/lib/mysql"
|
||||
88
nginx.conf
Normal file
88
nginx.conf
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
user root;
|
||||
worker_processes 5;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
root /usr/lib/GNUstep/SOGo/WebServerResources;
|
||||
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
|
||||
|
||||
access_log /dev/stdout;
|
||||
error_log /dev/stderr debug;
|
||||
|
||||
## requirement to create new calendars in Thunderbird ##
|
||||
proxy_http_version 1.1;
|
||||
|
||||
location = / {
|
||||
return 301 $scheme://$server_name/SOGo;
|
||||
allow all;
|
||||
}
|
||||
|
||||
location ^~/SOGo {
|
||||
proxy_pass http://sogo:20000;
|
||||
proxy_redirect `http://sogo:20000` default;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header x-webobjects-server-protocol HTTP/1.0;
|
||||
proxy_set_header x-webobjects-remote-host 127.0.0.1;
|
||||
proxy_set_header x-webobjects-server-name $server_name;
|
||||
proxy_set_header x-webobjects-server-url $scheme://$host;
|
||||
proxy_set_header x-webobjects-server-port $server_port;
|
||||
proxy_connect_timeout 90;
|
||||
proxy_send_timeout 90;
|
||||
proxy_read_timeout 90;
|
||||
proxy_buffer_size 4k;
|
||||
proxy_buffers 4 32k;
|
||||
proxy_busy_buffers_size 64k;
|
||||
proxy_temp_file_write_size 64k;
|
||||
client_max_body_size 50m;
|
||||
client_body_buffer_size 128k;
|
||||
break;
|
||||
}
|
||||
|
||||
location /SOGo.woa/WebServerResources/ {
|
||||
alias /usr/lib/GNUstep/SOGo/WebServerResources/;
|
||||
allow all;
|
||||
}
|
||||
|
||||
location /SOGo/WebServerResources/ {
|
||||
alias /usr/lib/GNUstep/SOGo/WebServerResources/;
|
||||
allow all;
|
||||
}
|
||||
|
||||
location (^/SOGo/so/ControlPanel/Products/([^/]*)/Resources/(.*)$) {
|
||||
alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
|
||||
}
|
||||
|
||||
location (^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$){
|
||||
alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
script/common.sh
Normal file
26
script/common.sh
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
log_info() {
|
||||
printf "$GREEN[$(date +"%F %T,%3N")] $1$NC\n"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
printf "$RED[$(date +"%F %T,%3N")] $1$NC\n"
|
||||
}
|
||||
|
||||
check_require() {
|
||||
if [[ -z ${2//[[:blank:]]/} ]]; then
|
||||
log_error "$1 is required"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
update_conf(){
|
||||
log_info "setting value for $1"
|
||||
defaults write sogod "$1" "$2"
|
||||
}
|
||||
40
script/mysql.sh
Normal file
40
script/mysql.sh
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
|
||||
source /usr/local/bin/common.sh
|
||||
|
||||
check_require "MYSQL_SERVER" $MYSQL_SERVER
|
||||
check_require "MYSQL_ROOT_PASSWORD" $MYSQL_ROOT_PASSWORD
|
||||
check_require "MYSQL_USER" $MYSQL_USER
|
||||
check_require "MYSQL_USER_PASSWORD" $MYSQL_USER_PASSWORD
|
||||
MYSQL_PORT=${MYSQL_PORT:-3306}
|
||||
MYSQL_DATABASE_NAME=${MYSQL_DATABASE_NAME:sogo}
|
||||
|
||||
wait_for_db() {
|
||||
log_info "Trying to connect to the DB server"
|
||||
DOCKERIZE_TIMEOUT=${DOCKERIZE_TIMEOUT:-"60s"}
|
||||
dockerize -timeout ${DOCKERIZE_TIMEOUT} -wait tcp://${MYSQL_SERVER}:${MYSQL_PORT:-3306}
|
||||
if [[ $? -ne 0 ]]; then
|
||||
log_error "Cannot connect to the DB server"
|
||||
exit 1
|
||||
fi
|
||||
log_info "Successfully connected to the DB server"
|
||||
}
|
||||
|
||||
init_db(){
|
||||
log_info "Checking if database exists"
|
||||
if [[ -z "`mysql -h$MYSQL_SERVER -P${MYSQL_PORT:-3306} -uroot -p$MYSQL_ROOT_PASSWORD -qfsBe "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='$MYSQL_USER'" 2>&1`" ]];then
|
||||
log_info "Creating database"
|
||||
mysql -h$MYSQL_SERVER -P$MYSQL_PORT -uroot -p$MYSQL_ROOT_PASSWORD -e "
|
||||
CREATE DATABASE $MYSQL_DATABASE_NAME CHARACTER SET='utf8';
|
||||
CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_USER_PASSWORD';
|
||||
GRANT ALL PRIVILEGES ON $MYSQL_DATABASE_NAME.* TO '$MYSQL_USER'@'%' WITH GRANT OPTION;
|
||||
FLUSH PRIVILEGES;"
|
||||
|
||||
else
|
||||
log_info "Database already exist"
|
||||
fi
|
||||
|
||||
update_conf "SOGoProfileURL" \"mysql://$MYSQL_USER:$MYSQL_USER_PASSWORD@$MYSQL_SERVER:$MYSQL_PORT/$MYSQL_DATABASE_NAME/sogo_user_profile\"
|
||||
update_conf "OCSFolderInfoURL" \"mysql://$MYSQL_USER:$MYSQL_USER_PASSWORD@$MYSQL_SERVER:$MYSQL_PORT/$MYSQL_DATABASE_NAME/sogo_folder_info\"
|
||||
update_conf "OCSSessionsFolderURL" \"mysql://$MYSQL_USER:$MYSQL_USER_PASSWORD@$MYSQL_SERVER:$MYSQL_PORT/$MYSQL_DATABASE_NAME/sogo_sessions_folder\"
|
||||
}
|
||||
14
script/start.sh
Normal file
14
script/start.sh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
source /usr/local/bin/common.sh
|
||||
source /usr/local/bin/mysql.sh
|
||||
|
||||
for conf in $(printenv| grep -i SOGO_ | cut -d= -f1);do
|
||||
update_conf "${conf:5}" "${!conf}"
|
||||
done
|
||||
|
||||
wait_for_db
|
||||
init_db
|
||||
|
||||
log_info "Launching SOGo"
|
||||
/usr/sbin/sogod -WONoDetach YES -WOPort 20000 -WOLogFile - -WOPidFile /tmp/sogo.pid
|
||||
Loading…
Add table
Add a link
Reference in a new issue