diff --git a/Dockerfile b/Dockerfile index 26cc580..9f99ccc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,17 @@ FROM alpine:3.4 -MAINTAINER Wonderfall +MAINTAINER Wonderfall MAINTAINER Hardware -ARG GPG_rainloop="3B79 7ECE 694F 3B7B 70F3 11A4 ED7C 49D9 87DA 4591" +ARG GPG_FINGERPRINT="3B79 7ECE 694F 3B7B 70F3 11A4 ED7C 49D9 87DA 4591" -ENV GID=991 UID=991 +ENV UID=991 GID=991 RUN echo "@commuedge https://nl.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ && apk -U add \ gnupg \ nginx \ - supervisor \ - tini@commuedge \ + s6 \ + su-exec \ php7-fpm@commuedge \ php7-curl@commuedge \ php7-iconv@commuedge \ @@ -32,7 +32,7 @@ RUN echo "@commuedge https://nl.alpinelinux.org/alpine/edge/community" >> /etc/a && FINGERPRINT="$(LANG=C gpg --verify rainloop-community-latest.zip.asc rainloop-community-latest.zip 2>&1 \ | sed -n "s#Primary key fingerprint: \(.*\)#\1#p")" \ && if [ -z "${FINGERPRINT}" ]; then echo "Warning! Invalid GPG signature!" && exit 1; fi \ - && if [ "${FINGERPRINT}" != "${GPG_rainloop}" ]; then echo "Warning! Wrong GPG fingerprint!" && exit 1; fi \ + && if [ "${FINGERPRINT}" != "${GPG_FINGERPRINT}" ]; then echo "Warning! Wrong GPG fingerprint!" && exit 1; fi \ && echo "All seems good, now unzipping rainloop-community-latest.zip..." \ && mkdir /rainloop && unzip -q /tmp/rainloop-community-latest.zip -d /rainloop \ && find /rainloop -type d -exec chmod 755 {} \; \ @@ -42,11 +42,13 @@ RUN echo "@commuedge https://nl.alpinelinux.org/alpine/edge/community" >> /etc/a COPY nginx.conf /etc/nginx/nginx.conf COPY php-fpm.conf /etc/php7/php-fpm.conf -COPY supervisord.conf /etc/supervisor/supervisord.conf -COPY startup /usr/local/bin/startup +COPY s6.d /etc/s6.d +COPY run.sh /usr/local/bin/run.sh -RUN chmod +x /usr/local/bin/startup +RUN chmod +x /usr/local/bin/run.sh /etc/s6.d/*/* /etc/s6.d/.s6-svscan/* VOLUME /rainloop/data -EXPOSE 80 -CMD ["/sbin/tini","--","startup"] + +EXPOSE 8888 + +CMD ["run.sh"] diff --git a/README.md b/README.md index 05ae530..97b6f07 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,32 @@ ![](https://i.goopics.net/nI.png) +### What is this ? + Rainloop is a simple, modern & fast web-based client. More details on the [official website](http://www.rainloop.net/). ### Features -- Based on Alpine 3.3 + +- Lightweight & secure image (no root process) +- Based on Alpine 3.4 - Latest Rainloop **Community Edition** (stable) - Contacts (DB) : sqlite, or mysql (server not built-in) +- With Nginx and PHP7 -### How to use +### Build-time variables -``` -docker run -d \ - --name rainloop \ - --link mariadb:mariadb \ # Optional - -v /mnt/docker/rainloop:/rainloop/data \ - hardware/rainloop -``` +- **GPG_FINGERPRINT** : fingerprint of signing key + +### Ports + +- **8888** + +### Environment variables + +| Variable | Description | Type | Default value | +| -------- | ----------- | ---- | ------------- | +| **GID** | rainloop user id | *optional* | 991 +| **UID** | rainloop group id | *optional* | 991 ### Reverse proxy example with nginx @@ -27,15 +37,6 @@ https://github.com/hardware/mailserver/wiki/Reverse-proxy-configuration https://github.com/hardware/mailserver/wiki/Rainloop-initial-configuration -#### Build-time variables - -- **GPG_rainloop** : fingerprint of signing key - -### Environment variables - -- **UID** : rainloop user id (*optional*, default: 991) -- **GID** : rainloop group id (*optional*, default: 991) - ### Docker-compose #### Docker-compose.yml @@ -48,7 +49,7 @@ rainloop: volumes: - /mnt/docker/rainloop:/rainloop/data -# if using mysql as contacts database : +# if using mariadb as contacts database : mariadb: image: mariadb:10.1 @@ -66,4 +67,4 @@ mariadb: ``` docker-compose up -d -``` \ No newline at end of file +``` diff --git a/nginx.conf b/nginx.conf index ef0f579..5438bec 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,6 +1,5 @@ -user rainloop; worker_processes auto; -pid /var/run/nginx.pid; +pid /tmp/nginx.pid; daemon off; events { @@ -13,7 +12,7 @@ http { default_type application/octet-stream; access_log off; - error_log /var/log/nginx/error.log error; + error_log /tmp/ngx_error.log error; sendfile on; keepalive_timeout 15; @@ -23,6 +22,12 @@ http { tcp_nodelay on; server_tokens off; + fastcgi_temp_path /tmp/fastcgi 1 2; + client_body_temp_path /tmp/client_body 1 2; + proxy_temp_path /tmp/proxy 1 2; + uwsgi_temp_path /tmp/uwsgi 1 2; + scgi_temp_path /tmp/scgi 1 2; + gzip on; gzip_comp_level 5; gzip_min_length 512; @@ -47,7 +52,7 @@ http { image/svg+xml; server { - listen 80; + listen 8888; root /rainloop; index index.php; charset utf-8; @@ -61,12 +66,12 @@ http { } location ~* \.php$ { - try_files $uri =404; fastcgi_index index.php; - fastcgi_pass unix:/var/run/php-fpm.sock; + fastcgi_pass unix:/tmp/php-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } + } } diff --git a/php-fpm.conf b/php-fpm.conf index bd3f372..f636044 100644 --- a/php-fpm.conf +++ b/php-fpm.conf @@ -2,11 +2,7 @@ daemonize = no [www] -user = rainloop -group = rainloop -listen = /var/run/php-fpm.sock -listen.owner = rainloop -listen.group = rainloop +listen = /tmp/php-fpm.sock pm = dynamic pm.max_children = 5 pm.start_servers = 2 diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..7363eb0 --- /dev/null +++ b/run.sh @@ -0,0 +1,3 @@ +#!/bin/sh +chown -R $UID:$GID /rainloop /etc/nginx /etc/php7 /var/log /var/lib/nginx /tmp /etc/s6.d +exec su-exec $UID:$GID /bin/s6-svscan /etc/s6.d diff --git a/s6.d/.s6-svscan/finish b/s6.d/.s6-svscan/finish new file mode 100644 index 0000000..039e4d0 --- /dev/null +++ b/s6.d/.s6-svscan/finish @@ -0,0 +1,2 @@ +#!/bin/sh +exit 0 diff --git a/s6.d/nginx/run b/s6.d/nginx/run new file mode 100644 index 0000000..eaf8049 --- /dev/null +++ b/s6.d/nginx/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec nginx diff --git a/s6.d/php/run b/s6.d/php/run new file mode 100644 index 0000000..e238021 --- /dev/null +++ b/s6.d/php/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec php-fpm7 diff --git a/startup b/startup deleted file mode 100644 index 7e03684..0000000 --- a/startup +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# Create user and group -addgroup -g ${GID} rainloop && adduser -h /rainloop -s /bin/sh -D -G rainloop -u ${UID} rainloop - -# Set permissions -chown -R rainloop:rainloop /rainloop /var/lib/nginx - -# RUN ! -supervisord -c /etc/supervisor/supervisord.conf diff --git a/supervisord.conf b/supervisord.conf deleted file mode 100644 index a65aaf9..0000000 --- a/supervisord.conf +++ /dev/null @@ -1,10 +0,0 @@ -[supervisord] -logfile = /tmp/supervisord.log -pidfile = /tmp/supervisord.pid -nodaemon=true - -[program:php-fpm] -command=php-fpm7 - -[program:nginx] -command=nginx