diff --git a/.examples/README.md b/.examples/README.md index c3f88f5..9e33436 100644 --- a/.examples/README.md +++ b/.examples/README.md @@ -16,25 +16,6 @@ The Dockerfiles use the default images as base image and build on top of it. Examples | Descriptions -------- | ------- [cron](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/cron) | uses supervisor to run the cron job inside the container (so no extra container is needed). -[smtp](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/smtp) | adds SMTP support to the Friendica container (necessary if you want to have mail support in Friendica). - -### SMTP settings - -The binary `ssmtp` is used for the `mail()` support of Friendica. - -You have to set the `--hostname/-h` parameter correctly to use the right domainname for the `mail()` command. - -You have to set a valid SMTP-MTA for the `SMTP` environment variable to enable mail support in Friendica. -A valid SMTP-MTA would be, for example, `mx.example.org`. - -The following environment variables are possible for the SMTP examples. - -- `SITENAME` The name of the Friendica node. (**required** - Default: `Testsite`) -- `SMTP` Address of the SMTP Mail-Gateway. (**required** - Default: `localhost`) -- `SMTP_FROM` Sender user-part of the address. (Default: `no-reply` - e.g. no-reply@friendica.local) -- `SMTP_AUTH_USER` Username for the SMTP Mail-Gateway. (Default: empty) -- `SMTP_AUTH_PASS` Password for the SMTP Mail-Gateway. (Default: empty) -- `SMTP_AUTH_METHOD` Authentication method for the SMTP Mail-Gateway. (Default: empty/plain text) ## docker-compose diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/Dockerfile b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/Dockerfile index 25f436d..a9eaeb8 100644 --- a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/Dockerfile +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/Dockerfile @@ -1,41 +1,4 @@ FROM friendica/server:apache -# entrypoint.sh and cron.sh dependencies -RUN set -ex; \ - \ - apt-get update; \ - apt-get install -y --no-install-recommends \ -# For mail() support - ssmtp \ - ; \ - rm -rf /var/lib/apt/lists/*; - -ENV SMTP localhost -ENV SMTP_FROM no-reply - -ENV SITENAME "Testsite" - -# Setup SSMTP -RUN set -ex; \ - sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd ;\ - sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd ;\ -# add possible mail-senders - {\ - echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" ;\ - echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" ;\ - } > /etc/ssmtp/revaliases;\ -# replace ssmtp.conf settings - {\ - echo "root=$SMTP_FROM@$HOSTNAME" ;\ - echo "hostname=$HOSTNAME" ;\ - echo "mailhub=$SMTP" ;\ - echo "FromLineOverride=YES" ;\ - [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" ;\ - [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" ;\ - [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" ;\ - [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" ;\ - [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" ;\ - } > /etc/ssmtp/ssmtp.conf; - RUN mkdir -p /usr/src/config COPY addon.ini.php /usr/src/config/ diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/db.env b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/db.env index 17c0d1e..44af555 100644 --- a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/db.env +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/db.env @@ -1,4 +1,4 @@ -MYSQL_PASSWORD= +MYSQL_PASSWORD=test MYSQL_DATABASE=friendica MYSQL_USER=friendica MYSQL_HOST=db diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/docker-compose.yml b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/docker-compose.yml index e8ff4d0..6be6f8b 100644 --- a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/docker-compose.yml +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/docker-compose.yml @@ -22,10 +22,10 @@ services: - friendica:/var/www/html environment: - FRIENDICA_ADMIN_MAIL= - - FRIENDICA_TZ= - - FRIENDICA_LANG= - - SITENAME= - - SMTP= + - FRIENDICA_TZ=Europe/Berlin + - FRIENDICA_LANG=de + - SITENAME=Testsite + - SMTP=smtp.philipp.info env_file: - db.env depends_on: @@ -40,9 +40,6 @@ services: volumes: - friendica:/var/www/html entrypoint: /cron.sh - environment: - - SITENAME= - - SMTP= depends_on: - db hostname: friendica.local diff --git a/.examples/dockerfiles/smtp/apache/Dockerfile b/.examples/dockerfiles/smtp/apache/Dockerfile deleted file mode 100644 index 0dd0cad..0000000 --- a/.examples/dockerfiles/smtp/apache/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -FROM friendica/server:apache - -# entrypoint.sh and cron.sh dependencies -RUN set -ex; \ - \ - apt-get update; \ - apt-get install -y --no-install-recommends \ -# For mail() support - ssmtp \ - ; \ - rm -rf /var/lib/apt/lists/*; - -ENV SMTP localhost -ENV SMTP_FROM no-reply - -ENV SITENAME "Testsite" - -# Setup SSMTP -RUN sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd ;\ - sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd ;\ -# add possible mail-senders - {\ - echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" ;\ - echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" ;\ - } > /etc/ssmtp/revaliases;\ -# replace ssmtp.conf settings - {\ - echo "root=$SMTP_FROM@$HOSTNAME" ;\ - echo "hostname=$HOSTNAME" ;\ - echo "mailhub=$SMTP" ;\ - echo "FromLineOverride=YES" ;\ - [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" ;\ - [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" ;\ - [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" ;\ - [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" ;\ - [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" ;\ - } > /etc/ssmtp/ssmtp.conf; diff --git a/.examples/dockerfiles/smtp/fpm-alpine/Dockerfile b/.examples/dockerfiles/smtp/fpm-alpine/Dockerfile deleted file mode 100644 index edc772d..0000000 --- a/.examples/dockerfiles/smtp/fpm-alpine/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -FROM friendica/server:fpm-alpine - -RUN set -ex; \ - apk add --no-cache \ - # For mail() support - ssmtp; - -ENV SMTP localhost -ENV SMTP_FROM no-reply - -ENV SITENAME "Testsite" - -# Setup SSMTP -RUN sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd ;\ - sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd ;\ -# add possible mail-senders - {\ - echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" ;\ - echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" ;\ - } > /etc/ssmtp/revaliases;\ -# replace ssmtp.conf settings - {\ - echo "root=$SMTP_FROM@$HOSTNAME" ;\ - echo "hostname=$HOSTNAME" ;\ - echo "mailhub=$SMTP" ;\ - echo "FromLineOverride=YES" ;\ - [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" ;\ - [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" ;\ - [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" ;\ - [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" ;\ - [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" ;\ - } > /etc/ssmtp/ssmtp.conf; diff --git a/.examples/dockerfiles/smtp/fpm/Dockerfile b/.examples/dockerfiles/smtp/fpm/Dockerfile deleted file mode 100644 index 268f38f..0000000 --- a/.examples/dockerfiles/smtp/fpm/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -FROM friendica/server:fpm - -# entrypoint.sh and cron.sh dependencies -RUN set -ex; \ - \ - apt-get update; \ - apt-get install -y --no-install-recommends \ -# For mail() support - ssmtp \ - ; \ - rm -rf /var/lib/apt/lists/*; - -ENV SMTP localhost -ENV SMTP_FROM no-reply - -ENV SITENAME "Testsite" - -# Setup SSMTP -RUN sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd ;\ - sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd ;\ -# add possible mail-senders - {\ - echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" ;\ - echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" ;\ - } > /etc/ssmtp/revaliases;\ -# replace ssmtp.conf settings - {\ - echo "root=$SMTP_FROM@$HOSTNAME" ;\ - echo "hostname=$HOSTNAME" ;\ - echo "mailhub=$SMTP" ;\ - echo "FromLineOverride=YES" ;\ - [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" ;\ - [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" ;\ - [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" ;\ - [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" ;\ - [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" ;\ - } > /etc/ssmtp/ssmtp.conf; diff --git a/2018.09/apache/Dockerfile b/2018.09/apache/Dockerfile index a4d4d2f..ec6efce 100644 --- a/2018.09/apache/Dockerfile +++ b/2018.09/apache/Dockerfile @@ -10,6 +10,8 @@ RUN set -ex; \ rsync \ bzip2 \ git \ + # mail() support + ssmtp \ ; \ rm -rf /var/lib/apt/lists/*; @@ -119,7 +121,7 @@ RUN set -ex; \ mkdir /usr/src/friendica/addon; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ rm friendica_addons.tar.gz; \ - /usr/src/friendica/bin/composer.phar install --no-plugins --no-scripts --no-dev -d /usr/src/friendica; + /usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica; ENTRYPOINT ["/entrypoint.sh"] CMD ["apache2-foreground"] diff --git a/2018.09/apache/entrypoint.sh b/2018.09/apache/entrypoint.sh index 75a5213..26bd8b6 100644 --- a/2018.09/apache/entrypoint.sh +++ b/2018.09/apache/entrypoint.sh @@ -15,10 +15,6 @@ version_greater() { [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] } -directory_empty() { - [ -z "$(ls -A "$1/")" ] -} - # clones the whole develop branch (Friendica and Addons) clone_develop() { friendica_git="${FRIENDICA_VERSION}" @@ -43,7 +39,40 @@ clone_develop() { echo "Download finished" - /usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica + /usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica +} + +setup_ssmtp() { + if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then + echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..." + + smtp_from=${SMTP_FROM:-no-reply} + + # Setup SSMTP + sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd + sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd + + # add possible mail-senders + { + echo "www-data:$smtp_from@$HOSTNAME:$SMTP" ; + echo "root::$smtp_from@$HOSTNAME:$SMTP" ; + } > /etc/ssmtp/revaliases; + + # replace ssmtp.conf settings + { + echo "root=:$smtp_from@$HOSTNAME" ; + echo "hostname=$HOSTNAME" ; + echo "mailhub=$SMTP" ; + echo "FromLineOverride=YES" ; + if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi + if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi + if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi + if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi + } > /etc/ssmtp/ssmtp.conf + + echo "Setup finished" + fi } # just check if we execute apache or php-fpm @@ -77,6 +106,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then fi fi + setup_ssmtp + if [ "$check" = true ]; then echo "Initializing Friendica $image_version ..." @@ -92,13 +123,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/ - # copy every *.ini.php from the config directory except they are already copied (in case of an upgrade) - for dir in config; do - if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then - rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/ - fi - done - # In case there is no .htaccess, copy it from the default dist file if [ ! -f "/var/www/html/.htaccess" ]; then cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess" diff --git a/2018.09/apache/upgrade.exclude b/2018.09/apache/upgrade.exclude index 732ba58..1185fa0 100644 --- a/2018.09/apache/upgrade.exclude +++ b/2018.09/apache/upgrade.exclude @@ -4,4 +4,4 @@ .htconfig.php .htaccess home.* -/config/ \ No newline at end of file +/config/local.ini.php \ No newline at end of file diff --git a/2018.09/fpm-alpine/Dockerfile b/2018.09/fpm-alpine/Dockerfile index 480987c..509f377 100644 --- a/2018.09/fpm-alpine/Dockerfile +++ b/2018.09/fpm-alpine/Dockerfile @@ -6,7 +6,9 @@ LABEL maintainer="Philipp Holzer " RUN set -ex; \ apk add --no-cache \ rsync \ - git; + git \ + # mail() support + ssmtp; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ @@ -102,7 +104,7 @@ RUN set -ex; \ mkdir /usr/src/friendica/addon; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ rm friendica_addons.tar.gz; \ - /usr/src/friendica/bin/composer.phar install --no-plugins --no-scripts --no-dev -d /usr/src/friendica; + /usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica; ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] diff --git a/2018.09/fpm-alpine/entrypoint.sh b/2018.09/fpm-alpine/entrypoint.sh index 75a5213..26bd8b6 100644 --- a/2018.09/fpm-alpine/entrypoint.sh +++ b/2018.09/fpm-alpine/entrypoint.sh @@ -15,10 +15,6 @@ version_greater() { [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] } -directory_empty() { - [ -z "$(ls -A "$1/")" ] -} - # clones the whole develop branch (Friendica and Addons) clone_develop() { friendica_git="${FRIENDICA_VERSION}" @@ -43,7 +39,40 @@ clone_develop() { echo "Download finished" - /usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica + /usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica +} + +setup_ssmtp() { + if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then + echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..." + + smtp_from=${SMTP_FROM:-no-reply} + + # Setup SSMTP + sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd + sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd + + # add possible mail-senders + { + echo "www-data:$smtp_from@$HOSTNAME:$SMTP" ; + echo "root::$smtp_from@$HOSTNAME:$SMTP" ; + } > /etc/ssmtp/revaliases; + + # replace ssmtp.conf settings + { + echo "root=:$smtp_from@$HOSTNAME" ; + echo "hostname=$HOSTNAME" ; + echo "mailhub=$SMTP" ; + echo "FromLineOverride=YES" ; + if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi + if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi + if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi + if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi + } > /etc/ssmtp/ssmtp.conf + + echo "Setup finished" + fi } # just check if we execute apache or php-fpm @@ -77,6 +106,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then fi fi + setup_ssmtp + if [ "$check" = true ]; then echo "Initializing Friendica $image_version ..." @@ -92,13 +123,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/ - # copy every *.ini.php from the config directory except they are already copied (in case of an upgrade) - for dir in config; do - if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then - rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/ - fi - done - # In case there is no .htaccess, copy it from the default dist file if [ ! -f "/var/www/html/.htaccess" ]; then cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess" diff --git a/2018.09/fpm-alpine/upgrade.exclude b/2018.09/fpm-alpine/upgrade.exclude index 732ba58..1185fa0 100644 --- a/2018.09/fpm-alpine/upgrade.exclude +++ b/2018.09/fpm-alpine/upgrade.exclude @@ -4,4 +4,4 @@ .htconfig.php .htaccess home.* -/config/ \ No newline at end of file +/config/local.ini.php \ No newline at end of file diff --git a/2018.09/fpm/Dockerfile b/2018.09/fpm/Dockerfile index aad9214..e6f066e 100644 --- a/2018.09/fpm/Dockerfile +++ b/2018.09/fpm/Dockerfile @@ -10,6 +10,8 @@ RUN set -ex; \ rsync \ bzip2 \ git \ + # mail() support + ssmtp \ ; \ rm -rf /var/lib/apt/lists/*; @@ -111,7 +113,7 @@ RUN set -ex; \ mkdir /usr/src/friendica/addon; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ rm friendica_addons.tar.gz; \ - /usr/src/friendica/bin/composer.phar install --no-plugins --no-scripts --no-dev -d /usr/src/friendica; + /usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica; ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] diff --git a/2018.09/fpm/entrypoint.sh b/2018.09/fpm/entrypoint.sh index 75a5213..26bd8b6 100644 --- a/2018.09/fpm/entrypoint.sh +++ b/2018.09/fpm/entrypoint.sh @@ -15,10 +15,6 @@ version_greater() { [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] } -directory_empty() { - [ -z "$(ls -A "$1/")" ] -} - # clones the whole develop branch (Friendica and Addons) clone_develop() { friendica_git="${FRIENDICA_VERSION}" @@ -43,7 +39,40 @@ clone_develop() { echo "Download finished" - /usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica + /usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica +} + +setup_ssmtp() { + if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then + echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..." + + smtp_from=${SMTP_FROM:-no-reply} + + # Setup SSMTP + sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd + sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd + + # add possible mail-senders + { + echo "www-data:$smtp_from@$HOSTNAME:$SMTP" ; + echo "root::$smtp_from@$HOSTNAME:$SMTP" ; + } > /etc/ssmtp/revaliases; + + # replace ssmtp.conf settings + { + echo "root=:$smtp_from@$HOSTNAME" ; + echo "hostname=$HOSTNAME" ; + echo "mailhub=$SMTP" ; + echo "FromLineOverride=YES" ; + if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi + if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi + if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi + if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi + } > /etc/ssmtp/ssmtp.conf + + echo "Setup finished" + fi } # just check if we execute apache or php-fpm @@ -77,6 +106,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then fi fi + setup_ssmtp + if [ "$check" = true ]; then echo "Initializing Friendica $image_version ..." @@ -92,13 +123,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/ - # copy every *.ini.php from the config directory except they are already copied (in case of an upgrade) - for dir in config; do - if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then - rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/ - fi - done - # In case there is no .htaccess, copy it from the default dist file if [ ! -f "/var/www/html/.htaccess" ]; then cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess" diff --git a/2018.09/fpm/upgrade.exclude b/2018.09/fpm/upgrade.exclude index 732ba58..1185fa0 100644 --- a/2018.09/fpm/upgrade.exclude +++ b/2018.09/fpm/upgrade.exclude @@ -4,4 +4,4 @@ .htconfig.php .htaccess home.* -/config/ \ No newline at end of file +/config/local.ini.php \ No newline at end of file diff --git a/2018.12-dev/apache/Dockerfile b/2018.12-dev/apache/Dockerfile index fb1ee2f..50fcd01 100644 --- a/2018.12-dev/apache/Dockerfile +++ b/2018.12-dev/apache/Dockerfile @@ -10,6 +10,8 @@ RUN set -ex; \ rsync \ bzip2 \ git \ + # mail() support + ssmtp \ ; \ rm -rf /var/lib/apt/lists/*; diff --git a/2018.12-dev/apache/entrypoint.sh b/2018.12-dev/apache/entrypoint.sh index 75a5213..26bd8b6 100644 --- a/2018.12-dev/apache/entrypoint.sh +++ b/2018.12-dev/apache/entrypoint.sh @@ -15,10 +15,6 @@ version_greater() { [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] } -directory_empty() { - [ -z "$(ls -A "$1/")" ] -} - # clones the whole develop branch (Friendica and Addons) clone_develop() { friendica_git="${FRIENDICA_VERSION}" @@ -43,7 +39,40 @@ clone_develop() { echo "Download finished" - /usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica + /usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica +} + +setup_ssmtp() { + if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then + echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..." + + smtp_from=${SMTP_FROM:-no-reply} + + # Setup SSMTP + sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd + sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd + + # add possible mail-senders + { + echo "www-data:$smtp_from@$HOSTNAME:$SMTP" ; + echo "root::$smtp_from@$HOSTNAME:$SMTP" ; + } > /etc/ssmtp/revaliases; + + # replace ssmtp.conf settings + { + echo "root=:$smtp_from@$HOSTNAME" ; + echo "hostname=$HOSTNAME" ; + echo "mailhub=$SMTP" ; + echo "FromLineOverride=YES" ; + if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi + if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi + if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi + if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi + } > /etc/ssmtp/ssmtp.conf + + echo "Setup finished" + fi } # just check if we execute apache or php-fpm @@ -77,6 +106,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then fi fi + setup_ssmtp + if [ "$check" = true ]; then echo "Initializing Friendica $image_version ..." @@ -92,13 +123,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/ - # copy every *.ini.php from the config directory except they are already copied (in case of an upgrade) - for dir in config; do - if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then - rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/ - fi - done - # In case there is no .htaccess, copy it from the default dist file if [ ! -f "/var/www/html/.htaccess" ]; then cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess" diff --git a/2018.12-dev/apache/upgrade.exclude b/2018.12-dev/apache/upgrade.exclude index 732ba58..1185fa0 100644 --- a/2018.12-dev/apache/upgrade.exclude +++ b/2018.12-dev/apache/upgrade.exclude @@ -4,4 +4,4 @@ .htconfig.php .htaccess home.* -/config/ \ No newline at end of file +/config/local.ini.php \ No newline at end of file diff --git a/2018.12-dev/fpm-alpine/Dockerfile b/2018.12-dev/fpm-alpine/Dockerfile index 8fb8ce1..aac87b6 100644 --- a/2018.12-dev/fpm-alpine/Dockerfile +++ b/2018.12-dev/fpm-alpine/Dockerfile @@ -6,7 +6,9 @@ LABEL maintainer="Philipp Holzer " RUN set -ex; \ apk add --no-cache \ rsync \ - git; + git \ + # mail() support + ssmtp; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ diff --git a/2018.12-dev/fpm-alpine/entrypoint.sh b/2018.12-dev/fpm-alpine/entrypoint.sh index 75a5213..26bd8b6 100644 --- a/2018.12-dev/fpm-alpine/entrypoint.sh +++ b/2018.12-dev/fpm-alpine/entrypoint.sh @@ -15,10 +15,6 @@ version_greater() { [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] } -directory_empty() { - [ -z "$(ls -A "$1/")" ] -} - # clones the whole develop branch (Friendica and Addons) clone_develop() { friendica_git="${FRIENDICA_VERSION}" @@ -43,7 +39,40 @@ clone_develop() { echo "Download finished" - /usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica + /usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica +} + +setup_ssmtp() { + if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then + echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..." + + smtp_from=${SMTP_FROM:-no-reply} + + # Setup SSMTP + sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd + sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd + + # add possible mail-senders + { + echo "www-data:$smtp_from@$HOSTNAME:$SMTP" ; + echo "root::$smtp_from@$HOSTNAME:$SMTP" ; + } > /etc/ssmtp/revaliases; + + # replace ssmtp.conf settings + { + echo "root=:$smtp_from@$HOSTNAME" ; + echo "hostname=$HOSTNAME" ; + echo "mailhub=$SMTP" ; + echo "FromLineOverride=YES" ; + if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi + if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi + if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi + if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi + } > /etc/ssmtp/ssmtp.conf + + echo "Setup finished" + fi } # just check if we execute apache or php-fpm @@ -77,6 +106,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then fi fi + setup_ssmtp + if [ "$check" = true ]; then echo "Initializing Friendica $image_version ..." @@ -92,13 +123,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/ - # copy every *.ini.php from the config directory except they are already copied (in case of an upgrade) - for dir in config; do - if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then - rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/ - fi - done - # In case there is no .htaccess, copy it from the default dist file if [ ! -f "/var/www/html/.htaccess" ]; then cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess" diff --git a/2018.12-dev/fpm-alpine/upgrade.exclude b/2018.12-dev/fpm-alpine/upgrade.exclude index 732ba58..1185fa0 100644 --- a/2018.12-dev/fpm-alpine/upgrade.exclude +++ b/2018.12-dev/fpm-alpine/upgrade.exclude @@ -4,4 +4,4 @@ .htconfig.php .htaccess home.* -/config/ \ No newline at end of file +/config/local.ini.php \ No newline at end of file diff --git a/2018.12-dev/fpm/Dockerfile b/2018.12-dev/fpm/Dockerfile index cac7281..de10310 100644 --- a/2018.12-dev/fpm/Dockerfile +++ b/2018.12-dev/fpm/Dockerfile @@ -10,6 +10,8 @@ RUN set -ex; \ rsync \ bzip2 \ git \ + # mail() support + ssmtp \ ; \ rm -rf /var/lib/apt/lists/*; diff --git a/2018.12-dev/fpm/entrypoint.sh b/2018.12-dev/fpm/entrypoint.sh index 75a5213..26bd8b6 100644 --- a/2018.12-dev/fpm/entrypoint.sh +++ b/2018.12-dev/fpm/entrypoint.sh @@ -15,10 +15,6 @@ version_greater() { [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] } -directory_empty() { - [ -z "$(ls -A "$1/")" ] -} - # clones the whole develop branch (Friendica and Addons) clone_develop() { friendica_git="${FRIENDICA_VERSION}" @@ -43,7 +39,40 @@ clone_develop() { echo "Download finished" - /usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica + /usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica +} + +setup_ssmtp() { + if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then + echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..." + + smtp_from=${SMTP_FROM:-no-reply} + + # Setup SSMTP + sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd + sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd + + # add possible mail-senders + { + echo "www-data:$smtp_from@$HOSTNAME:$SMTP" ; + echo "root::$smtp_from@$HOSTNAME:$SMTP" ; + } > /etc/ssmtp/revaliases; + + # replace ssmtp.conf settings + { + echo "root=:$smtp_from@$HOSTNAME" ; + echo "hostname=$HOSTNAME" ; + echo "mailhub=$SMTP" ; + echo "FromLineOverride=YES" ; + if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi + if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi + if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi + if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi + } > /etc/ssmtp/ssmtp.conf + + echo "Setup finished" + fi } # just check if we execute apache or php-fpm @@ -77,6 +106,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then fi fi + setup_ssmtp + if [ "$check" = true ]; then echo "Initializing Friendica $image_version ..." @@ -92,13 +123,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/ - # copy every *.ini.php from the config directory except they are already copied (in case of an upgrade) - for dir in config; do - if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then - rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/ - fi - done - # In case there is no .htaccess, copy it from the default dist file if [ ! -f "/var/www/html/.htaccess" ]; then cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess" diff --git a/2018.12-dev/fpm/upgrade.exclude b/2018.12-dev/fpm/upgrade.exclude index 732ba58..1185fa0 100644 --- a/2018.12-dev/fpm/upgrade.exclude +++ b/2018.12-dev/fpm/upgrade.exclude @@ -4,4 +4,4 @@ .htconfig.php .htaccess home.* -/config/ \ No newline at end of file +/config/local.ini.php \ No newline at end of file diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index a6f54f1..227873c 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -5,7 +5,9 @@ LABEL maintainer="Philipp Holzer " RUN set -ex; \ apk add --no-cache \ rsync \ - git; + git \ + # mail() support + ssmtp; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index 2735ae1..8af9bd9 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -9,6 +9,8 @@ RUN set -ex; \ rsync \ bzip2 \ git \ + # mail() support + ssmtp \ ; \ rm -rf /var/lib/apt/lists/*; diff --git a/README.md b/README.md index 948a3cb..5033aef 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,23 @@ Because Friendica links the administrator account to a specific mail address, yo ## Mail settings -see the [example](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/README.md#smtpsetting) +The binary `ssmtp` is used for the `mail()` support of Friendica. + +You have to set the `--hostname/-h` parameter correctly to use the right domainname for the `mail()` command. + +You have to set a valid SMTP-MTA for the `SMTP` environment variable to enable mail support in Friendica. +A valid SMTP-MTA would be, for example, `mx.example.org`. + +The following environment variables are possible for the SMTP examples. + +- `SITENAME` The name of the Friendica node. (**required**) +- `SMTP` Address of the SMTP Mail-Gateway. (**required**) +- `SMTP_FROM` Sender user-part of the address. (Default: `no-reply` - e.g. no-reply@friendica.local) +- `SMTP_TLS` Use TLS for connecting the SMTP Mail-Gateway. (Default: empty) +- `SMTP_STARTTLS` Use STARTTLS for connecting the SMTP Mail-Gateway. (Default: empty) +- `SMTP_AUTH_USER` Username for the SMTP Mail-Gateway. (Default: empty) +- `SMTP_AUTH_PASS` Password for the SMTP Mail-Gateway. (Default: empty) +- `SMTP_AUTH_METHOD` Authentication method for the SMTP Mail-Gateway. (Default: empty/plain text) ## Database settings diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 75a5213..26bd8b6 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -15,10 +15,6 @@ version_greater() { [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] } -directory_empty() { - [ -z "$(ls -A "$1/")" ] -} - # clones the whole develop branch (Friendica and Addons) clone_develop() { friendica_git="${FRIENDICA_VERSION}" @@ -43,7 +39,40 @@ clone_develop() { echo "Download finished" - /usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica + /usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica +} + +setup_ssmtp() { + if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then + echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..." + + smtp_from=${SMTP_FROM:-no-reply} + + # Setup SSMTP + sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd + sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd + + # add possible mail-senders + { + echo "www-data:$smtp_from@$HOSTNAME:$SMTP" ; + echo "root::$smtp_from@$HOSTNAME:$SMTP" ; + } > /etc/ssmtp/revaliases; + + # replace ssmtp.conf settings + { + echo "root=:$smtp_from@$HOSTNAME" ; + echo "hostname=$HOSTNAME" ; + echo "mailhub=$SMTP" ; + echo "FromLineOverride=YES" ; + if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi + if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi + if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi + if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi + if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi + } > /etc/ssmtp/ssmtp.conf + + echo "Setup finished" + fi } # just check if we execute apache or php-fpm @@ -77,6 +106,8 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then fi fi + setup_ssmtp + if [ "$check" = true ]; then echo "Initializing Friendica $image_version ..." @@ -92,13 +123,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/ - # copy every *.ini.php from the config directory except they are already copied (in case of an upgrade) - for dir in config; do - if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then - rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/ - fi - done - # In case there is no .htaccess, copy it from the default dist file if [ ! -f "/var/www/html/.htaccess" ]; then cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess" diff --git a/update.sh b/update.sh index 95cfc98..0b2a40d 100755 --- a/update.sh +++ b/update.sh @@ -30,7 +30,7 @@ declare -A pecl_versions=( ) declare -A install_extras=( - ['stable']='\nRUN set -ex; \\\n curl -fsSL -o friendica.tar.gz \\\n "https://github.com/friendica/friendica/archive/${FRIENDICA_VERSION}.tar.gz"; \\\n tar -xzf friendica.tar.gz -C /usr/src/; \\\n rm friendica.tar.gz; \\\n mv -f /usr/src/friendica-${FRIENDICA_VERSION}/ /usr/src/friendica; \\\n chmod 777 /usr/src/friendica/view/smarty3; \\\n curl -fsSL -o friendica_addons.tar.gz \\\n "https://github.com/friendica/friendica-addons/archive/${FRIENDICA_ADDONS}.tar.gz"; \\\n mkdir /usr/src/friendica/addon; \\\n tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \\\n rm friendica_addons.tar.gz; \\\n /usr/src/friendica/bin/composer.phar install --no-plugins --no-scripts --no-dev -d /usr/src/friendica;' + ['stable']='\nRUN set -ex; \\\n curl -fsSL -o friendica.tar.gz \\\n "https://github.com/friendica/friendica/archive/${FRIENDICA_VERSION}.tar.gz"; \\\n tar -xzf friendica.tar.gz -C /usr/src/; \\\n rm friendica.tar.gz; \\\n mv -f /usr/src/friendica-${FRIENDICA_VERSION}/ /usr/src/friendica; \\\n chmod 777 /usr/src/friendica/view/smarty3; \\\n curl -fsSL -o friendica_addons.tar.gz \\\n "https://github.com/friendica/friendica-addons/archive/${FRIENDICA_ADDONS}.tar.gz"; \\\n mkdir /usr/src/friendica/addon; \\\n tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \\\n rm friendica_addons.tar.gz; \\\n /usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica;' ['develop']='' ) diff --git a/upgrade.exclude b/upgrade.exclude index 732ba58..1185fa0 100644 --- a/upgrade.exclude +++ b/upgrade.exclude @@ -4,4 +4,4 @@ .htconfig.php .htaccess home.* -/config/ \ No newline at end of file +/config/local.ini.php \ No newline at end of file