From 6ea2875ebf882849f3376187a6ed2758f1709b10 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Fri, 18 May 2018 21:20:22 +0200 Subject: [PATCH 01/16] Init the Friendica Docker Repository - Added develop images (apache, fpm, fpm-alpine) - Added stable images 3.6 (apache, fpm, fpm-alpine) - Added .travis.yml for testing --- .editorconfig | 10 ++ .gitattributes | 2 + .gitignore | 20 +++ .travis.yml | 25 +++ README.md | 85 ++++++++- develop/apache/Dockerfile | 106 +++++++++++ develop/apache/bin/friendica | 152 ++++++++++++++++ develop/apache/config/htconfig.php | 104 +++++++++++ develop/apache/cron.sh | 4 + develop/apache/entrypoint.sh | 7 + develop/fpm-alpine/Dockerfile | 86 +++++++++ develop/fpm-alpine/bin/friendica | 152 ++++++++++++++++ develop/fpm-alpine/config/htconfig.php | 104 +++++++++++ develop/fpm-alpine/cron.sh | 4 + develop/fpm-alpine/entrypoint.sh | 7 + develop/fpm/Dockerfile | 97 ++++++++++ develop/fpm/bin/friendica | 152 ++++++++++++++++ develop/fpm/config/htconfig.php | 104 +++++++++++ develop/fpm/cron.sh | 4 + develop/fpm/entrypoint.sh | 7 + friendica.svg | 240 +++++++++++++++++++++++++ stable/apache/Dockerfile | 119 ++++++++++++ stable/apache/bin/friendica | 152 ++++++++++++++++ stable/apache/config/htconfig.php | 104 +++++++++++ stable/apache/cron.sh | 4 + stable/apache/entrypoint.sh | 7 + stable/fpm-alpine/Dockerfile | 99 ++++++++++ stable/fpm-alpine/bin/friendica | 152 ++++++++++++++++ stable/fpm-alpine/config/htconfig.php | 104 +++++++++++ stable/fpm-alpine/cron.sh | 4 + stable/fpm-alpine/entrypoint.sh | 7 + stable/fpm/Dockerfile | 110 ++++++++++++ stable/fpm/bin/friendica | 152 ++++++++++++++++ stable/fpm/config/htconfig.php | 104 +++++++++++ stable/fpm/cron.sh | 4 + stable/fpm/entrypoint.sh | 7 + 36 files changed, 2598 insertions(+), 3 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 develop/apache/Dockerfile create mode 100644 develop/apache/bin/friendica create mode 100644 develop/apache/config/htconfig.php create mode 100644 develop/apache/cron.sh create mode 100644 develop/apache/entrypoint.sh create mode 100644 develop/fpm-alpine/Dockerfile create mode 100644 develop/fpm-alpine/bin/friendica create mode 100644 develop/fpm-alpine/config/htconfig.php create mode 100644 develop/fpm-alpine/cron.sh create mode 100644 develop/fpm-alpine/entrypoint.sh create mode 100644 develop/fpm/Dockerfile create mode 100644 develop/fpm/bin/friendica create mode 100644 develop/fpm/config/htconfig.php create mode 100644 develop/fpm/cron.sh create mode 100644 develop/fpm/entrypoint.sh create mode 100644 friendica.svg create mode 100644 stable/apache/Dockerfile create mode 100644 stable/apache/bin/friendica create mode 100644 stable/apache/config/htconfig.php create mode 100644 stable/apache/cron.sh create mode 100644 stable/apache/entrypoint.sh create mode 100644 stable/fpm-alpine/Dockerfile create mode 100644 stable/fpm-alpine/bin/friendica create mode 100644 stable/fpm-alpine/config/htconfig.php create mode 100644 stable/fpm-alpine/cron.sh create mode 100644 stable/fpm-alpine/entrypoint.sh create mode 100644 stable/fpm/Dockerfile create mode 100644 stable/fpm/bin/friendica create mode 100644 stable/fpm/config/htconfig.php create mode 100644 stable/fpm/cron.sh create mode 100644 stable/fpm/entrypoint.sh diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ea90f8c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +# editorconfig tool configuration +# see http://editorconfig.org for docs + +root = true + +[*] +charset = utf-8 +end_of_line = lf +trim_trailing_whitespaces = true +indent_style = tab \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8725c74 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Disable LF normalization for all files +* -text \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9166a87 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +favicon.* +\#* +*.log +*.out +*.version* +favicon.* +*~ +robots.txt + + +#ignore config files from eclipse, we don't want IDE files in our repository +.project +.buildpath +.externalToolBuilders +.settings +#ignore OSX .DS_Store files +.DS_Store + +#ignore config files from JetBrains +/.idea \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2c91b23 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +language: bash +services: docker + +env: + - VARIANT=stable/apache + - VARIANT=stable/fpm + - VARIANT=stable/fpm-alpine + - VARIANT=develop/apache + - VARIANT=develop/fpm + - VARIANT=develop/fpm-alpine + +install: + - git clone https://github.com/docker-library/official-images.git ~/official-images + +before_script: + - env | sort + - cd "$VARIANT" + - slash='/'; image="friendica:${VARIANT//$slash/-\" + +script: + - docker build -t "$image" . + - ~/official-images/test/run.sh "$image" + +after_script: + - docker images \ No newline at end of file diff --git a/README.md b/README.md index 90e212a..e89ef01 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,82 @@ -# Docker Image for Friendica - -This repository holds the official Docker Image for [Friendica](https://friendi.ca) +# Docker Image for Friendica + +This repository holds the official Docker Image for [Friendica](https://friendi.ca) + +# What is Friendica? + +Friendica is a decentralised communications platform that integrates social communication. Our platform links to independent social projects and corporate services. + +![logo](https://cdn.rawgit.com/nupplaphil/friendica-docker/c59f235f/friendica.svg) + +# How to use this image +The images are designed to be used in a micro-service environment. There are two types of the image you can choose from. + +The `apache` tag contains a full Friendica installation including an apache web server. It is designed to be easy to use and gets you running pretty fast. This is also the default for the `latest` tag and version tags that are not further specified. + +The second option is a `fpm` container. It is based on the [php-fpm](https://hub.docker.com/_/php/) image and runs a fastCGI-Process that serves your Friendica server. To use this image it must be combined with any Webserver that can proxy the http requests to the FastCGI-port of the container. + +## Using the apache image +You need at least one other mariadb/mysql-container to link it to Friendica + +The apache image contains a webserver and exposes port 80. To start the container type: +```console +$ docker run -d -p 8080:80 --link some-mysql:mysql friendica +``` + +Now you can access the Friendica installation wizard at http://localhost:8080/ from your host system. + +## Using the fpm image +To use the fpm image you need an additional web server that can proxy http-request to the fpm-port of the container. For fpm connection this container exposes port 9000. In most cases you might want use another container or your host as proxy. +If you use your host you can address your Friendica container directly on port 9000. If you use another container, make sure that you add them to the same docker network (via `docker run --network ...` or a `docker-compose` file). +In both cases you don't want to map the fpm port to you host. + +```console +$ docker run -d friendica:fpm +``` + +As the fastCGI-Process is not capable of serving static files (style sheets, images, ...) the webserver needs access to these files. This can be achieved with the `volumes-from` option. You can find more information in the docker-compose section. + +## Using an external database +By default the `latest` container uses a local MySQL-Database for data storage, but the Friendica setup wizard (appears on first run) allows connecting to an existing MySQL/MariaDB database. You can also link a database container, e. g. `--link my-mysql:mysql`, and then use `mysql` as the database host on setup. More info is in the docker-compose section. + +## Persistent data +The Friendica installation and all data beyond what lives in the database (file uploads, etc) is stored in the [unnamed docker volume](https://docs.docker.com/engine/tutorials/dockervolumes/#adding-a-data-volume) volume `/var/www/html`. The docker daemon will store that data within the docker directory `/var/lib/docker/volumes/...`. That means your data is saved even if the container crashes, is stopped or deleted. + +To make your data persistent to upgrading and get access for backups is using named docker volume or mount a host folder. To achieve this you need one volume for your database container and Friendica. + +Friendica: +- `/var/www/html/` folder where all Friendica data lives +```console +$ docker run -d \ +-v friendica-vol-1:/var/www/html \ +friendica +``` + +Database: +- `/var/lib/mysql` MySQL / MariaDB Data +```console +$ docker run -d \ +-v mysql-vol-1:/var/lib/mysql \ +mariadb +``` + +## Auto configuration via environment variables +The Friendica image supports auto configuration via environment variables. You can preconfigure everything that is asked on the install page on first run. + +- `AUTOINSTALL` if `true`, the automatic configuration will start (Default: `false`) + +__MYSQL/MariaDB__: +- `MYSQL_USERNAME` Username for the database user using mysql / mariadb. +- `MYSQL_PASSWORD` Password for the database user using mysql / mariadb. +- `MYSQL_DATABASE` Name of the database using mysql / mariadb. +- `MYSQL_HOST` Hostname of the database server using mysql / mariadb. +- `MYSQL_PORT` Port of the database server using mysql / mariadb. + +You can also predefine the following `.htconfig.php` values: +- `MAILNAME` E-Mail address of the administrator +- `TZ` The default localization of the Friendica server +- `LANGUAGE` The default language of the Friendica server +- `SITENAME` The default name of the Friendica server + +# Questions / Issues +If you got any questions or problems using the image, please visit our [Github Repository](https://github.com/friendica/docker) and write an issue. \ No newline at end of file diff --git a/develop/apache/Dockerfile b/develop/apache/Dockerfile new file mode 100644 index 0000000..caa4387 --- /dev/null +++ b/develop/apache/Dockerfile @@ -0,0 +1,106 @@ +FROM php:7.1-apache +LABEL maintainer="Philipp Holzer " + +ENV IMAGICK_PECL 3.4.3 +ENV AUTOINSTALL false + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + rsync \ + bzip2 \ + busybox-static \ + git \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + \ + mkdir -p /var/spool/cron/crontabs; \ + echo '*/10 * * * * cd /var/www/html && php -f bin/worker.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://friendi.ca/resources/requirements/ +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libxml2-dev \ + mysql-client \ + bash \ + autoconf \ + g++ \ + make \ + openssl \ + libssl-dev \ + libpng12-0 \ + libpng12-dev \ + libjpeg62-turbo-dev \ + libtool \ + libmcrypt4 \ + libmcrypt-dev \ + imagemagick \ + libmagick++-dev \ + libgraphicsmagick1-dev \ + libfreetype6 \ + libfreetype6-dev \ + librsvg2-2 \ + libcurl4-openssl-dev \ + curl \ + ; \ + \ + debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ + pecl install imagick-${IMAGICK_PECL}; \ + docker-php-ext-enable imagick; \ + pecl clear-cache \ + ; \ + docker-php-ext-configure gd \ + --with-gd \ + --enable-gd-native-ttf \ + --with-freetype-dir=/usr/include/ \ + --with-png-dir=/usr/include/ \ + --with-jpeg-dir=/usr/include/ \ + ; \ + docker-php-ext-install -j 4 curl pdo pdo_mysql xml gd zip opcache mbstring posix ctype json iconv mcrypt \ + ; \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +RUN chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + +RUN a2enmod rewrite remoteip ;\ + {\ + echo RemoteIPHeader X-Real-IP ;\ + echo RemoteIPTrustedProxy 10.0.0.0/8 ;\ + echo RemoteIPTrustedProxy 172.16.0.0/12 ;\ + echo RemoteIPTrustedProxy 192.168.0.0/16 ;\ + } > /etc/apache2/conf-available/remoteip.conf;\ + a2enconf remoteip + +ENV FRIENDICA_VERSION develop +ENV ADDONS_VERSION develop + +COPY bin/* /usr/local/bin/ +COPY config/* /usr/src/config/ +COPY *.sh / +RUN chmod +x /*.sh +RUN chmod +x /usr/local/bin/* + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["apache2-foreground"] \ No newline at end of file diff --git a/develop/apache/bin/friendica b/develop/apache/bin/friendica new file mode 100644 index 0000000..3f42591 --- /dev/null +++ b/develop/apache/bin/friendica @@ -0,0 +1,152 @@ +#!/bin/sh +set -eu + +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} + +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + dir="${1:-$SOURCEDIR}" + friendica="${2:-$FRIENDICA_VERSION}" + addons="${3:-$FRIENDICA_ADDONS}" + + echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" + + git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica + chmod 777 ${dir}/friendica/view/smarty3 + mkdir ${dir}/friendica/addon + git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon +} + +# help of this shell script +friendica_help() { + echo "Usage: friendica []" + echo "" + echo "Commands:" + echo " console Executes an command in the Friendica console" + echo " composer Executes the composer.phar executable for Friendica" + echo " install Installs Friendica" + echo " update Updates Friendica" + exit 1 +} + +# executes the Friendica console +console() { + cd ${WORKDIR} + php "${WORKDIR}/bin/console.php" "$@" +} + +# executes the composer.phar binary of Friendica +composer() { + if [ -f ${WORKDIR}/bin/composer.phar ]; then + run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}" + fi +} + +copy_sources() { + installed_version="0.0.0.0" + if [ -f ${WORKDIR}/VERSION ]; then + installed_version="$(cat ${WORKDIR}/VERSION)" + fi + + image_version="0.0.0.0" + if [ -f ${SOURCEDIR}/friendica/VERSION ]; then + image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" + elif [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + echo "Friendica command '$1' failed, because of no valid combination of source and version" + return; + fi + + if version_greater "$installed_version" "$image_version"; then + echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + + echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'" + rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ + fi +} + +# install Friendica +install() { + if [ -f ${WORKDIR}/VERSION ]; then + # If there is a given installation of Friendica and we should not update it => exit + # We have to explicit update Friendica to avoid breaking something + return + fi + + copy_sources + + echo "Installing Friendica" + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + + if [ ! -f ${WORKDIR}/.htconfig.php ] && + [ -f ${SOURCEDIR}/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr ${WORKDIR}/view/smarty3/compiled + fi +} + +update() { + if [ ! -f ${WORKDIR}/VERSION ]; then + # We want to update a given installation + # if there is no installation, exit + return + fi + + copy_sources + + echo "Upgrading Friendica" + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "update" + fi + console "dbstructure update" +} + +if [ $# -eq 0 ]; then + friendica_help +fi + +case "$1" in + install) shift; install "$@";; + update) shift; update "$@" ;; + console) shift; console "$@" ;; + composer) shift; composer "$@" ;; + *) friendica_help ;; +esac diff --git a/develop/apache/config/htconfig.php b/develop/apache/config/htconfig.php new file mode 100644 index 0000000..fb8180f --- /dev/null +++ b/develop/apache/config/htconfig.php @@ -0,0 +1,104 @@ +config['system']['db_charset'] = "utf8mb4"; + +// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". +// It can be changed later and only applies to timestamps for anonymous viewers. + +if (!empty(getenv('TZ'))) { + $default_timezone = getenv('TZ'); +} else { + $default_timezone = 'America/Los_Angeles'; +} + +// Default system language +if (!empty(getenv('LANGUAGE'))) { + $a->config['system']['language'] = getenv('LANGUAGE'); +} else { + $a->config['system']['language'] = 'en'; +} + +// What is your site name? +if (!empty(getenv('SITENAME'))) { + $a->config['sitename'] = getenv('SITENAME'); +} else { + $a->config['sitename'] = "Friendica Social Network"; +} + +// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED. +// Be certain to create your own personal account before setting +// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on +// the registration page. REGISTER_APPROVE requires you set 'admin_email' +// to the email address of an already registered person who can authorise +// and/or approve/deny the request. + +// In order to perform system administration via the admin panel, admin_email +// must precisely match the email address of the person logged in. + +$a->config['register_policy'] = REGISTER_OPEN; +$a->config['register_text'] = ''; +if (!empty(getenv('MAILNAME'))) { + $a->config['admin_email'] = getenv('MAILNAME'); +} else { + $a->config['admin_email'] = ''; +} + +// Maximum size of an imported message, 0 is unlimited + +$a->config['max_import_size'] = 200000; + +// maximum size of uploaded photos + +$a->config['system']['maximagesize'] = 800000; + +// Location of PHP command line processor + +$a->config['php_path'] = 'php'; + +// Server-to-server private message encryption (RINO) is allowed by default. +// set to 0 to disable, 1 to enable + +$a->config['system']['rino_encrypt'] = 1; + +// allowed themes (change this from admin panel after installation) + +$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero,smoothly'; + +// default system theme + +$a->config['system']['theme'] = 'vier'; + + +// By default allow pseudonyms + +$a->config['system']['no_regfullname'] = true; + +//Deny public access to the local directory +//$a->config['system']['block_local_dir'] = false; + +// Location of the global directory +$a->config['system']['directory'] = 'https://dir.friendica.social'; + +// Allowed protocols in link URLs; HTTP protocols always are accepted +$a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid', 'gopher']; + +// Authentication cookie lifetime, in days +$a->config['system']['auth_cookie_lifetime'] = 7; diff --git a/develop/apache/cron.sh b/develop/apache/cron.sh new file mode 100644 index 0000000..b368336 --- /dev/null +++ b/develop/apache/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file diff --git a/develop/apache/entrypoint.sh b/develop/apache/entrypoint.sh new file mode 100644 index 0000000..90d6839 --- /dev/null +++ b/develop/apache/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu + +# Check if Friendica needs to get installed +friendica install + +exec "$@" \ No newline at end of file diff --git a/develop/fpm-alpine/Dockerfile b/develop/fpm-alpine/Dockerfile new file mode 100644 index 0000000..c36fdbe --- /dev/null +++ b/develop/fpm-alpine/Dockerfile @@ -0,0 +1,86 @@ +FROM php:7.1-fpm-alpine +LABEL maintainer="Philipp Holzer " + +ENV IMAGICK_PECL 3.4.3 +ENV AUTOINSTALL false + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apk add --no-cache \ + rsync \ + git \ + ; \ + \ + rm /var/spool/cron/crontabs/root; \ + echo '*/10 * * * * cd /var/www/html && php -f bin/worker.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://friendi.ca/resources/requirements/ +RUN set -ex; \ + \ + apk add -U --no-cache --virtual .build-deps \ + libxml2-dev \ + mysql-client \ + bash \ + autoconf \ + g++ \ + make \ + openssl \ + openssl-dev \ + libpng \ + libpng-dev \ + libjpeg-turbo-dev \ + imagemagick-dev \ + imagemagick \ + libtool \ + libmcrypt \ + libmcrypt-dev \ + freetype \ + libpng \ + libjpeg-turbo-dev \ + freetype-dev \ + librsvg \ + libcurl \ + curl \ + curl-dev \ + rsync \ + bzip2 \ + ; \ + pecl install imagick-${IMAGICK_PECL}; \ + docker-php-ext-enable imagick; \ + pecl clear-cache; \ + docker-php-ext-configure gd \ + --with-gd \ + --enable-gd-native-ttf \ + --with-freetype-dir=/usr/include/ \ + --with-png-dir=/usr/include/ \ + --with-jpeg-dir=/usr/include/ \ + ; \ + docker-php-ext-install -j 4 curl pdo pdo_mysql xml gd zip opcache mbstring posix ctype json iconv mcrypt; \ + \ + runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )"; \ + apk add --virtual .friendica-phpext-rundeps $runDeps; \ + apk del .build-deps; + +RUN chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + +ENV FRIENDICA_VERSION develop +ENV ADDONS_VERSION develop + +COPY bin/* /usr/local/bin/ +COPY config/* /usr/src/config/ +COPY *.sh / +RUN chmod +x /*.sh +RUN chmod +x /usr/local/bin/* + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["php-fpm"] \ No newline at end of file diff --git a/develop/fpm-alpine/bin/friendica b/develop/fpm-alpine/bin/friendica new file mode 100644 index 0000000..3f42591 --- /dev/null +++ b/develop/fpm-alpine/bin/friendica @@ -0,0 +1,152 @@ +#!/bin/sh +set -eu + +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} + +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + dir="${1:-$SOURCEDIR}" + friendica="${2:-$FRIENDICA_VERSION}" + addons="${3:-$FRIENDICA_ADDONS}" + + echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" + + git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica + chmod 777 ${dir}/friendica/view/smarty3 + mkdir ${dir}/friendica/addon + git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon +} + +# help of this shell script +friendica_help() { + echo "Usage: friendica []" + echo "" + echo "Commands:" + echo " console Executes an command in the Friendica console" + echo " composer Executes the composer.phar executable for Friendica" + echo " install Installs Friendica" + echo " update Updates Friendica" + exit 1 +} + +# executes the Friendica console +console() { + cd ${WORKDIR} + php "${WORKDIR}/bin/console.php" "$@" +} + +# executes the composer.phar binary of Friendica +composer() { + if [ -f ${WORKDIR}/bin/composer.phar ]; then + run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}" + fi +} + +copy_sources() { + installed_version="0.0.0.0" + if [ -f ${WORKDIR}/VERSION ]; then + installed_version="$(cat ${WORKDIR}/VERSION)" + fi + + image_version="0.0.0.0" + if [ -f ${SOURCEDIR}/friendica/VERSION ]; then + image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" + elif [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + echo "Friendica command '$1' failed, because of no valid combination of source and version" + return; + fi + + if version_greater "$installed_version" "$image_version"; then + echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + + echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'" + rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ + fi +} + +# install Friendica +install() { + if [ -f ${WORKDIR}/VERSION ]; then + # If there is a given installation of Friendica and we should not update it => exit + # We have to explicit update Friendica to avoid breaking something + return + fi + + copy_sources + + echo "Installing Friendica" + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + + if [ ! -f ${WORKDIR}/.htconfig.php ] && + [ -f ${SOURCEDIR}/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr ${WORKDIR}/view/smarty3/compiled + fi +} + +update() { + if [ ! -f ${WORKDIR}/VERSION ]; then + # We want to update a given installation + # if there is no installation, exit + return + fi + + copy_sources + + echo "Upgrading Friendica" + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "update" + fi + console "dbstructure update" +} + +if [ $# -eq 0 ]; then + friendica_help +fi + +case "$1" in + install) shift; install "$@";; + update) shift; update "$@" ;; + console) shift; console "$@" ;; + composer) shift; composer "$@" ;; + *) friendica_help ;; +esac diff --git a/develop/fpm-alpine/config/htconfig.php b/develop/fpm-alpine/config/htconfig.php new file mode 100644 index 0000000..fb8180f --- /dev/null +++ b/develop/fpm-alpine/config/htconfig.php @@ -0,0 +1,104 @@ +config['system']['db_charset'] = "utf8mb4"; + +// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". +// It can be changed later and only applies to timestamps for anonymous viewers. + +if (!empty(getenv('TZ'))) { + $default_timezone = getenv('TZ'); +} else { + $default_timezone = 'America/Los_Angeles'; +} + +// Default system language +if (!empty(getenv('LANGUAGE'))) { + $a->config['system']['language'] = getenv('LANGUAGE'); +} else { + $a->config['system']['language'] = 'en'; +} + +// What is your site name? +if (!empty(getenv('SITENAME'))) { + $a->config['sitename'] = getenv('SITENAME'); +} else { + $a->config['sitename'] = "Friendica Social Network"; +} + +// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED. +// Be certain to create your own personal account before setting +// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on +// the registration page. REGISTER_APPROVE requires you set 'admin_email' +// to the email address of an already registered person who can authorise +// and/or approve/deny the request. + +// In order to perform system administration via the admin panel, admin_email +// must precisely match the email address of the person logged in. + +$a->config['register_policy'] = REGISTER_OPEN; +$a->config['register_text'] = ''; +if (!empty(getenv('MAILNAME'))) { + $a->config['admin_email'] = getenv('MAILNAME'); +} else { + $a->config['admin_email'] = ''; +} + +// Maximum size of an imported message, 0 is unlimited + +$a->config['max_import_size'] = 200000; + +// maximum size of uploaded photos + +$a->config['system']['maximagesize'] = 800000; + +// Location of PHP command line processor + +$a->config['php_path'] = 'php'; + +// Server-to-server private message encryption (RINO) is allowed by default. +// set to 0 to disable, 1 to enable + +$a->config['system']['rino_encrypt'] = 1; + +// allowed themes (change this from admin panel after installation) + +$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero,smoothly'; + +// default system theme + +$a->config['system']['theme'] = 'vier'; + + +// By default allow pseudonyms + +$a->config['system']['no_regfullname'] = true; + +//Deny public access to the local directory +//$a->config['system']['block_local_dir'] = false; + +// Location of the global directory +$a->config['system']['directory'] = 'https://dir.friendica.social'; + +// Allowed protocols in link URLs; HTTP protocols always are accepted +$a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid', 'gopher']; + +// Authentication cookie lifetime, in days +$a->config['system']['auth_cookie_lifetime'] = 7; diff --git a/develop/fpm-alpine/cron.sh b/develop/fpm-alpine/cron.sh new file mode 100644 index 0000000..b368336 --- /dev/null +++ b/develop/fpm-alpine/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file diff --git a/develop/fpm-alpine/entrypoint.sh b/develop/fpm-alpine/entrypoint.sh new file mode 100644 index 0000000..90d6839 --- /dev/null +++ b/develop/fpm-alpine/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu + +# Check if Friendica needs to get installed +friendica install + +exec "$@" \ No newline at end of file diff --git a/develop/fpm/Dockerfile b/develop/fpm/Dockerfile new file mode 100644 index 0000000..d56a1ca --- /dev/null +++ b/develop/fpm/Dockerfile @@ -0,0 +1,97 @@ +FROM php:7.1-fpm +LABEL maintainer="Philipp Holzer " + +ENV IMAGICK_PECL 3.4.3 +ENV AUTOINSTALL false + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + rsync \ + bzip2 \ + busybox-static \ + git \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + \ + mkdir -p /var/spool/cron/crontabs; \ + echo '*/10 * * * * cd /var/www/html && php -f bin/worker.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://friendi.ca/resources/requirements/ +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libxml2-dev \ + mysql-client \ + bash \ + autoconf \ + g++ \ + make \ + openssl \ + libssl-dev \ + libpng12-0 \ + libpng12-dev \ + libjpeg62-turbo-dev \ + libtool \ + libmcrypt4 \ + libmcrypt-dev \ + imagemagick \ + libmagick++-dev \ + libgraphicsmagick1-dev \ + libfreetype6 \ + libfreetype6-dev \ + librsvg2-2 \ + libcurl4-openssl-dev \ + curl \ + ; \ + \ + debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ + pecl install imagick-${IMAGICK_PECL}; \ + docker-php-ext-enable imagick; \ + pecl clear-cache \ + ; \ + docker-php-ext-configure gd \ + --with-gd \ + --enable-gd-native-ttf \ + --with-freetype-dir=/usr/include/ \ + --with-png-dir=/usr/include/ \ + --with-jpeg-dir=/usr/include/ \ + ; \ + docker-php-ext-install -j 4 curl pdo pdo_mysql xml gd zip opcache mbstring posix ctype json iconv mcrypt \ + ; \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +RUN chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + +ENV FRIENDICA_VERSION develop +ENV ADDONS_VERSION develop + +COPY bin/* /usr/local/bin/ +COPY config/* /usr/src/config/ +COPY *.sh / +RUN chmod +x /*.sh +RUN chmod +x /usr/local/bin/* + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["php-fpm"] \ No newline at end of file diff --git a/develop/fpm/bin/friendica b/develop/fpm/bin/friendica new file mode 100644 index 0000000..3f42591 --- /dev/null +++ b/develop/fpm/bin/friendica @@ -0,0 +1,152 @@ +#!/bin/sh +set -eu + +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} + +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + dir="${1:-$SOURCEDIR}" + friendica="${2:-$FRIENDICA_VERSION}" + addons="${3:-$FRIENDICA_ADDONS}" + + echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" + + git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica + chmod 777 ${dir}/friendica/view/smarty3 + mkdir ${dir}/friendica/addon + git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon +} + +# help of this shell script +friendica_help() { + echo "Usage: friendica []" + echo "" + echo "Commands:" + echo " console Executes an command in the Friendica console" + echo " composer Executes the composer.phar executable for Friendica" + echo " install Installs Friendica" + echo " update Updates Friendica" + exit 1 +} + +# executes the Friendica console +console() { + cd ${WORKDIR} + php "${WORKDIR}/bin/console.php" "$@" +} + +# executes the composer.phar binary of Friendica +composer() { + if [ -f ${WORKDIR}/bin/composer.phar ]; then + run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}" + fi +} + +copy_sources() { + installed_version="0.0.0.0" + if [ -f ${WORKDIR}/VERSION ]; then + installed_version="$(cat ${WORKDIR}/VERSION)" + fi + + image_version="0.0.0.0" + if [ -f ${SOURCEDIR}/friendica/VERSION ]; then + image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" + elif [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + echo "Friendica command '$1' failed, because of no valid combination of source and version" + return; + fi + + if version_greater "$installed_version" "$image_version"; then + echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + + echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'" + rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ + fi +} + +# install Friendica +install() { + if [ -f ${WORKDIR}/VERSION ]; then + # If there is a given installation of Friendica and we should not update it => exit + # We have to explicit update Friendica to avoid breaking something + return + fi + + copy_sources + + echo "Installing Friendica" + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + + if [ ! -f ${WORKDIR}/.htconfig.php ] && + [ -f ${SOURCEDIR}/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr ${WORKDIR}/view/smarty3/compiled + fi +} + +update() { + if [ ! -f ${WORKDIR}/VERSION ]; then + # We want to update a given installation + # if there is no installation, exit + return + fi + + copy_sources + + echo "Upgrading Friendica" + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "update" + fi + console "dbstructure update" +} + +if [ $# -eq 0 ]; then + friendica_help +fi + +case "$1" in + install) shift; install "$@";; + update) shift; update "$@" ;; + console) shift; console "$@" ;; + composer) shift; composer "$@" ;; + *) friendica_help ;; +esac diff --git a/develop/fpm/config/htconfig.php b/develop/fpm/config/htconfig.php new file mode 100644 index 0000000..fb8180f --- /dev/null +++ b/develop/fpm/config/htconfig.php @@ -0,0 +1,104 @@ +config['system']['db_charset'] = "utf8mb4"; + +// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". +// It can be changed later and only applies to timestamps for anonymous viewers. + +if (!empty(getenv('TZ'))) { + $default_timezone = getenv('TZ'); +} else { + $default_timezone = 'America/Los_Angeles'; +} + +// Default system language +if (!empty(getenv('LANGUAGE'))) { + $a->config['system']['language'] = getenv('LANGUAGE'); +} else { + $a->config['system']['language'] = 'en'; +} + +// What is your site name? +if (!empty(getenv('SITENAME'))) { + $a->config['sitename'] = getenv('SITENAME'); +} else { + $a->config['sitename'] = "Friendica Social Network"; +} + +// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED. +// Be certain to create your own personal account before setting +// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on +// the registration page. REGISTER_APPROVE requires you set 'admin_email' +// to the email address of an already registered person who can authorise +// and/or approve/deny the request. + +// In order to perform system administration via the admin panel, admin_email +// must precisely match the email address of the person logged in. + +$a->config['register_policy'] = REGISTER_OPEN; +$a->config['register_text'] = ''; +if (!empty(getenv('MAILNAME'))) { + $a->config['admin_email'] = getenv('MAILNAME'); +} else { + $a->config['admin_email'] = ''; +} + +// Maximum size of an imported message, 0 is unlimited + +$a->config['max_import_size'] = 200000; + +// maximum size of uploaded photos + +$a->config['system']['maximagesize'] = 800000; + +// Location of PHP command line processor + +$a->config['php_path'] = 'php'; + +// Server-to-server private message encryption (RINO) is allowed by default. +// set to 0 to disable, 1 to enable + +$a->config['system']['rino_encrypt'] = 1; + +// allowed themes (change this from admin panel after installation) + +$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero,smoothly'; + +// default system theme + +$a->config['system']['theme'] = 'vier'; + + +// By default allow pseudonyms + +$a->config['system']['no_regfullname'] = true; + +//Deny public access to the local directory +//$a->config['system']['block_local_dir'] = false; + +// Location of the global directory +$a->config['system']['directory'] = 'https://dir.friendica.social'; + +// Allowed protocols in link URLs; HTTP protocols always are accepted +$a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid', 'gopher']; + +// Authentication cookie lifetime, in days +$a->config['system']['auth_cookie_lifetime'] = 7; diff --git a/develop/fpm/cron.sh b/develop/fpm/cron.sh new file mode 100644 index 0000000..b368336 --- /dev/null +++ b/develop/fpm/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file diff --git a/develop/fpm/entrypoint.sh b/develop/fpm/entrypoint.sh new file mode 100644 index 0000000..90d6839 --- /dev/null +++ b/develop/fpm/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu + +# Check if Friendica needs to get installed +friendica install + +exec "$@" \ No newline at end of file diff --git a/friendica.svg b/friendica.svg new file mode 100644 index 0000000..2105ef3 --- /dev/null +++ b/friendica.svg @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/stable/apache/Dockerfile b/stable/apache/Dockerfile new file mode 100644 index 0000000..b78dcfb --- /dev/null +++ b/stable/apache/Dockerfile @@ -0,0 +1,119 @@ +FROM php:7.1-apache +LABEL maintainer="Philipp Holzer " + +ENV IMAGICK_PECL 3.4.3 +ENV AUTOINSTALL false + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + rsync \ + bzip2 \ + busybox-static \ + git \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + \ + mkdir -p /var/spool/cron/crontabs; \ + echo '*/10 * * * * cd /var/www/html && php -f bin/worker.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://friendi.ca/resources/requirements/ +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libxml2-dev \ + mysql-client \ + bash \ + autoconf \ + g++ \ + make \ + openssl \ + libssl-dev \ + libpng12-0 \ + libpng12-dev \ + libjpeg62-turbo-dev \ + libtool \ + libmcrypt4 \ + libmcrypt-dev \ + imagemagick \ + libmagick++-dev \ + libgraphicsmagick1-dev \ + libfreetype6 \ + libfreetype6-dev \ + librsvg2-2 \ + libcurl4-openssl-dev \ + curl \ + ; \ + \ + debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ + pecl install imagick-${IMAGICK_PECL}; \ + docker-php-ext-enable imagick; \ + pecl clear-cache \ + ; \ + docker-php-ext-configure gd \ + --with-gd \ + --enable-gd-native-ttf \ + --with-freetype-dir=/usr/include/ \ + --with-png-dir=/usr/include/ \ + --with-jpeg-dir=/usr/include/ \ + ; \ + docker-php-ext-install -j 4 curl pdo pdo_mysql xml gd zip opcache mbstring posix ctype json iconv mcrypt \ + ; \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +RUN chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + +RUN a2enmod rewrite remoteip ;\ + {\ + echo RemoteIPHeader X-Real-IP ;\ + echo RemoteIPTrustedProxy 10.0.0.0/8 ;\ + echo RemoteIPTrustedProxy 172.16.0.0/12 ;\ + echo RemoteIPTrustedProxy 192.168.0.0/16 ;\ + } > /etc/apache2/conf-available/remoteip.conf;\ + a2enconf remoteip + +ENV FRIENDICA_VERSION 3.6 +ENV ADDONS_VERSION 3.6 + +RUN set -ex; \ + curl -fsSL -o friendica.tar.gz \ + "https://github.com/friendica/friendica/releases/download/${FRIENDICA_VERSION}/friendica-full-${FRIENDICA_VERSION}.tar.gz"; \ + tar -xzf friendica.tar.gz -C /usr/src/; \ + rm friendica.tar.gz; \ + mv -f /usr/src/friendica-${FRIENDICA_VERSION}/ /usr/src/friendica; \ + chmod 777 /usr/src/friendica/view/smarty3; \ + curl -fsSL -o friendica_addons.tar.gz \ + "https://github.com/friendica/friendica-addons/archive/${ADDONS_VERSION}.tar.gz"; \ + mkdir /usr/src/friendica/addon; \ + tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ + rm friendica_addons.tar.gz; + +COPY bin/* /usr/local/bin/ +COPY config/* /usr/src/config/ +COPY *.sh / +RUN chmod +x /*.sh +RUN chmod +x /usr/local/bin/* + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["apache2-foreground"] \ No newline at end of file diff --git a/stable/apache/bin/friendica b/stable/apache/bin/friendica new file mode 100644 index 0000000..3f42591 --- /dev/null +++ b/stable/apache/bin/friendica @@ -0,0 +1,152 @@ +#!/bin/sh +set -eu + +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} + +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + dir="${1:-$SOURCEDIR}" + friendica="${2:-$FRIENDICA_VERSION}" + addons="${3:-$FRIENDICA_ADDONS}" + + echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" + + git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica + chmod 777 ${dir}/friendica/view/smarty3 + mkdir ${dir}/friendica/addon + git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon +} + +# help of this shell script +friendica_help() { + echo "Usage: friendica []" + echo "" + echo "Commands:" + echo " console Executes an command in the Friendica console" + echo " composer Executes the composer.phar executable for Friendica" + echo " install Installs Friendica" + echo " update Updates Friendica" + exit 1 +} + +# executes the Friendica console +console() { + cd ${WORKDIR} + php "${WORKDIR}/bin/console.php" "$@" +} + +# executes the composer.phar binary of Friendica +composer() { + if [ -f ${WORKDIR}/bin/composer.phar ]; then + run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}" + fi +} + +copy_sources() { + installed_version="0.0.0.0" + if [ -f ${WORKDIR}/VERSION ]; then + installed_version="$(cat ${WORKDIR}/VERSION)" + fi + + image_version="0.0.0.0" + if [ -f ${SOURCEDIR}/friendica/VERSION ]; then + image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" + elif [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + echo "Friendica command '$1' failed, because of no valid combination of source and version" + return; + fi + + if version_greater "$installed_version" "$image_version"; then + echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + + echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'" + rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ + fi +} + +# install Friendica +install() { + if [ -f ${WORKDIR}/VERSION ]; then + # If there is a given installation of Friendica and we should not update it => exit + # We have to explicit update Friendica to avoid breaking something + return + fi + + copy_sources + + echo "Installing Friendica" + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + + if [ ! -f ${WORKDIR}/.htconfig.php ] && + [ -f ${SOURCEDIR}/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr ${WORKDIR}/view/smarty3/compiled + fi +} + +update() { + if [ ! -f ${WORKDIR}/VERSION ]; then + # We want to update a given installation + # if there is no installation, exit + return + fi + + copy_sources + + echo "Upgrading Friendica" + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "update" + fi + console "dbstructure update" +} + +if [ $# -eq 0 ]; then + friendica_help +fi + +case "$1" in + install) shift; install "$@";; + update) shift; update "$@" ;; + console) shift; console "$@" ;; + composer) shift; composer "$@" ;; + *) friendica_help ;; +esac diff --git a/stable/apache/config/htconfig.php b/stable/apache/config/htconfig.php new file mode 100644 index 0000000..fb8180f --- /dev/null +++ b/stable/apache/config/htconfig.php @@ -0,0 +1,104 @@ +config['system']['db_charset'] = "utf8mb4"; + +// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". +// It can be changed later and only applies to timestamps for anonymous viewers. + +if (!empty(getenv('TZ'))) { + $default_timezone = getenv('TZ'); +} else { + $default_timezone = 'America/Los_Angeles'; +} + +// Default system language +if (!empty(getenv('LANGUAGE'))) { + $a->config['system']['language'] = getenv('LANGUAGE'); +} else { + $a->config['system']['language'] = 'en'; +} + +// What is your site name? +if (!empty(getenv('SITENAME'))) { + $a->config['sitename'] = getenv('SITENAME'); +} else { + $a->config['sitename'] = "Friendica Social Network"; +} + +// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED. +// Be certain to create your own personal account before setting +// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on +// the registration page. REGISTER_APPROVE requires you set 'admin_email' +// to the email address of an already registered person who can authorise +// and/or approve/deny the request. + +// In order to perform system administration via the admin panel, admin_email +// must precisely match the email address of the person logged in. + +$a->config['register_policy'] = REGISTER_OPEN; +$a->config['register_text'] = ''; +if (!empty(getenv('MAILNAME'))) { + $a->config['admin_email'] = getenv('MAILNAME'); +} else { + $a->config['admin_email'] = ''; +} + +// Maximum size of an imported message, 0 is unlimited + +$a->config['max_import_size'] = 200000; + +// maximum size of uploaded photos + +$a->config['system']['maximagesize'] = 800000; + +// Location of PHP command line processor + +$a->config['php_path'] = 'php'; + +// Server-to-server private message encryption (RINO) is allowed by default. +// set to 0 to disable, 1 to enable + +$a->config['system']['rino_encrypt'] = 1; + +// allowed themes (change this from admin panel after installation) + +$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero,smoothly'; + +// default system theme + +$a->config['system']['theme'] = 'vier'; + + +// By default allow pseudonyms + +$a->config['system']['no_regfullname'] = true; + +//Deny public access to the local directory +//$a->config['system']['block_local_dir'] = false; + +// Location of the global directory +$a->config['system']['directory'] = 'https://dir.friendica.social'; + +// Allowed protocols in link URLs; HTTP protocols always are accepted +$a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid', 'gopher']; + +// Authentication cookie lifetime, in days +$a->config['system']['auth_cookie_lifetime'] = 7; diff --git a/stable/apache/cron.sh b/stable/apache/cron.sh new file mode 100644 index 0000000..b368336 --- /dev/null +++ b/stable/apache/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file diff --git a/stable/apache/entrypoint.sh b/stable/apache/entrypoint.sh new file mode 100644 index 0000000..90d6839 --- /dev/null +++ b/stable/apache/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu + +# Check if Friendica needs to get installed +friendica install + +exec "$@" \ No newline at end of file diff --git a/stable/fpm-alpine/Dockerfile b/stable/fpm-alpine/Dockerfile new file mode 100644 index 0000000..75a66d6 --- /dev/null +++ b/stable/fpm-alpine/Dockerfile @@ -0,0 +1,99 @@ +FROM php:7.1-fpm-alpine +LABEL maintainer="Philipp Holzer " + +ENV IMAGICK_PECL 3.4.3 +ENV AUTOINSTALL false + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apk add --no-cache \ + rsync \ + git \ + ; \ + \ + rm /var/spool/cron/crontabs/root; \ + echo '*/10 * * * * cd /var/www/html && php -f bin/worker.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://friendi.ca/resources/requirements/ +RUN set -ex; \ + \ + apk add -U --no-cache --virtual .build-deps \ + libxml2-dev \ + mysql-client \ + bash \ + autoconf \ + g++ \ + make \ + openssl \ + openssl-dev \ + libpng \ + libpng-dev \ + libjpeg-turbo-dev \ + imagemagick-dev \ + imagemagick \ + libtool \ + libmcrypt \ + libmcrypt-dev \ + freetype \ + libpng \ + libjpeg-turbo-dev \ + freetype-dev \ + librsvg \ + libcurl \ + curl \ + curl-dev \ + rsync \ + bzip2 \ + ; \ + pecl install imagick-${IMAGICK_PECL}; \ + docker-php-ext-enable imagick; \ + pecl clear-cache; \ + docker-php-ext-configure gd \ + --with-gd \ + --enable-gd-native-ttf \ + --with-freetype-dir=/usr/include/ \ + --with-png-dir=/usr/include/ \ + --with-jpeg-dir=/usr/include/ \ + ; \ + docker-php-ext-install -j 4 curl pdo pdo_mysql xml gd zip opcache mbstring posix ctype json iconv mcrypt; \ + \ + runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )"; \ + apk add --virtual .friendica-phpext-rundeps $runDeps; \ + apk del .build-deps; + +RUN chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + +ENV FRIENDICA_VERSION 3.6 +ENV ADDONS_VERSION 3.6 + +RUN set -ex; \ + curl -fsSL -o friendica.tar.gz \ + "https://github.com/friendica/friendica/releases/download/${FRIENDICA_VERSION}/friendica-full-${FRIENDICA_VERSION}.tar.gz"; \ + tar -xzf friendica.tar.gz -C /usr/src/; \ + rm friendica.tar.gz; \ + mv -f /usr/src/friendica-${FRIENDICA_VERSION}/ /usr/src/friendica; \ + chmod 777 /usr/src/friendica/view/smarty3; \ + curl -fsSL -o friendica_addons.tar.gz \ + "https://github.com/friendica/friendica-addons/archive/${ADDONS_VERSION}.tar.gz"; \ + mkdir /usr/src/friendica/addon; \ + tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ + rm friendica_addons.tar.gz; + +COPY bin/* /usr/local/bin/ +COPY config/* /usr/src/config/ +COPY *.sh / +RUN chmod +x /*.sh +RUN chmod +x /usr/local/bin/* + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["php-fpm"] \ No newline at end of file diff --git a/stable/fpm-alpine/bin/friendica b/stable/fpm-alpine/bin/friendica new file mode 100644 index 0000000..3f42591 --- /dev/null +++ b/stable/fpm-alpine/bin/friendica @@ -0,0 +1,152 @@ +#!/bin/sh +set -eu + +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} + +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + dir="${1:-$SOURCEDIR}" + friendica="${2:-$FRIENDICA_VERSION}" + addons="${3:-$FRIENDICA_ADDONS}" + + echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" + + git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica + chmod 777 ${dir}/friendica/view/smarty3 + mkdir ${dir}/friendica/addon + git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon +} + +# help of this shell script +friendica_help() { + echo "Usage: friendica []" + echo "" + echo "Commands:" + echo " console Executes an command in the Friendica console" + echo " composer Executes the composer.phar executable for Friendica" + echo " install Installs Friendica" + echo " update Updates Friendica" + exit 1 +} + +# executes the Friendica console +console() { + cd ${WORKDIR} + php "${WORKDIR}/bin/console.php" "$@" +} + +# executes the composer.phar binary of Friendica +composer() { + if [ -f ${WORKDIR}/bin/composer.phar ]; then + run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}" + fi +} + +copy_sources() { + installed_version="0.0.0.0" + if [ -f ${WORKDIR}/VERSION ]; then + installed_version="$(cat ${WORKDIR}/VERSION)" + fi + + image_version="0.0.0.0" + if [ -f ${SOURCEDIR}/friendica/VERSION ]; then + image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" + elif [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + echo "Friendica command '$1' failed, because of no valid combination of source and version" + return; + fi + + if version_greater "$installed_version" "$image_version"; then + echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + + echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'" + rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ + fi +} + +# install Friendica +install() { + if [ -f ${WORKDIR}/VERSION ]; then + # If there is a given installation of Friendica and we should not update it => exit + # We have to explicit update Friendica to avoid breaking something + return + fi + + copy_sources + + echo "Installing Friendica" + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + + if [ ! -f ${WORKDIR}/.htconfig.php ] && + [ -f ${SOURCEDIR}/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr ${WORKDIR}/view/smarty3/compiled + fi +} + +update() { + if [ ! -f ${WORKDIR}/VERSION ]; then + # We want to update a given installation + # if there is no installation, exit + return + fi + + copy_sources + + echo "Upgrading Friendica" + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "update" + fi + console "dbstructure update" +} + +if [ $# -eq 0 ]; then + friendica_help +fi + +case "$1" in + install) shift; install "$@";; + update) shift; update "$@" ;; + console) shift; console "$@" ;; + composer) shift; composer "$@" ;; + *) friendica_help ;; +esac diff --git a/stable/fpm-alpine/config/htconfig.php b/stable/fpm-alpine/config/htconfig.php new file mode 100644 index 0000000..fb8180f --- /dev/null +++ b/stable/fpm-alpine/config/htconfig.php @@ -0,0 +1,104 @@ +config['system']['db_charset'] = "utf8mb4"; + +// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". +// It can be changed later and only applies to timestamps for anonymous viewers. + +if (!empty(getenv('TZ'))) { + $default_timezone = getenv('TZ'); +} else { + $default_timezone = 'America/Los_Angeles'; +} + +// Default system language +if (!empty(getenv('LANGUAGE'))) { + $a->config['system']['language'] = getenv('LANGUAGE'); +} else { + $a->config['system']['language'] = 'en'; +} + +// What is your site name? +if (!empty(getenv('SITENAME'))) { + $a->config['sitename'] = getenv('SITENAME'); +} else { + $a->config['sitename'] = "Friendica Social Network"; +} + +// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED. +// Be certain to create your own personal account before setting +// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on +// the registration page. REGISTER_APPROVE requires you set 'admin_email' +// to the email address of an already registered person who can authorise +// and/or approve/deny the request. + +// In order to perform system administration via the admin panel, admin_email +// must precisely match the email address of the person logged in. + +$a->config['register_policy'] = REGISTER_OPEN; +$a->config['register_text'] = ''; +if (!empty(getenv('MAILNAME'))) { + $a->config['admin_email'] = getenv('MAILNAME'); +} else { + $a->config['admin_email'] = ''; +} + +// Maximum size of an imported message, 0 is unlimited + +$a->config['max_import_size'] = 200000; + +// maximum size of uploaded photos + +$a->config['system']['maximagesize'] = 800000; + +// Location of PHP command line processor + +$a->config['php_path'] = 'php'; + +// Server-to-server private message encryption (RINO) is allowed by default. +// set to 0 to disable, 1 to enable + +$a->config['system']['rino_encrypt'] = 1; + +// allowed themes (change this from admin panel after installation) + +$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero,smoothly'; + +// default system theme + +$a->config['system']['theme'] = 'vier'; + + +// By default allow pseudonyms + +$a->config['system']['no_regfullname'] = true; + +//Deny public access to the local directory +//$a->config['system']['block_local_dir'] = false; + +// Location of the global directory +$a->config['system']['directory'] = 'https://dir.friendica.social'; + +// Allowed protocols in link URLs; HTTP protocols always are accepted +$a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid', 'gopher']; + +// Authentication cookie lifetime, in days +$a->config['system']['auth_cookie_lifetime'] = 7; diff --git a/stable/fpm-alpine/cron.sh b/stable/fpm-alpine/cron.sh new file mode 100644 index 0000000..b368336 --- /dev/null +++ b/stable/fpm-alpine/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file diff --git a/stable/fpm-alpine/entrypoint.sh b/stable/fpm-alpine/entrypoint.sh new file mode 100644 index 0000000..90d6839 --- /dev/null +++ b/stable/fpm-alpine/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu + +# Check if Friendica needs to get installed +friendica install + +exec "$@" \ No newline at end of file diff --git a/stable/fpm/Dockerfile b/stable/fpm/Dockerfile new file mode 100644 index 0000000..779b621 --- /dev/null +++ b/stable/fpm/Dockerfile @@ -0,0 +1,110 @@ +FROM php:7.1-fpm +LABEL maintainer="Philipp Holzer " + +ENV IMAGICK_PECL 3.4.3 +ENV AUTOINSTALL false + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + rsync \ + bzip2 \ + busybox-static \ + git \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + \ + mkdir -p /var/spool/cron/crontabs; \ + echo '*/10 * * * * cd /var/www/html && php -f bin/worker.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://friendi.ca/resources/requirements/ +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libxml2-dev \ + mysql-client \ + bash \ + autoconf \ + g++ \ + make \ + openssl \ + libssl-dev \ + libpng12-0 \ + libpng12-dev \ + libjpeg62-turbo-dev \ + libtool \ + libmcrypt4 \ + libmcrypt-dev \ + imagemagick \ + libmagick++-dev \ + libgraphicsmagick1-dev \ + libfreetype6 \ + libfreetype6-dev \ + librsvg2-2 \ + libcurl4-openssl-dev \ + curl \ + ; \ + \ + debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ + pecl install imagick-${IMAGICK_PECL}; \ + docker-php-ext-enable imagick; \ + pecl clear-cache \ + ; \ + docker-php-ext-configure gd \ + --with-gd \ + --enable-gd-native-ttf \ + --with-freetype-dir=/usr/include/ \ + --with-png-dir=/usr/include/ \ + --with-jpeg-dir=/usr/include/ \ + ; \ + docker-php-ext-install -j 4 curl pdo pdo_mysql xml gd zip opcache mbstring posix ctype json iconv mcrypt \ + ; \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +RUN chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + +ENV FRIENDICA_VERSION 3.6 +ENV ADDONS_VERSION 3.6 + +RUN set -ex; \ + curl -fsSL -o friendica.tar.gz \ + "https://github.com/friendica/friendica/releases/download/${FRIENDICA_VERSION}/friendica-full-${FRIENDICA_VERSION}.tar.gz"; \ + tar -xzf friendica.tar.gz -C /usr/src/; \ + rm friendica.tar.gz; \ + mv -f /usr/src/friendica-${FRIENDICA_VERSION}/ /usr/src/friendica; \ + chmod 777 /usr/src/friendica/view/smarty3; \ + curl -fsSL -o friendica_addons.tar.gz \ + "https://github.com/friendica/friendica-addons/archive/${ADDONS_VERSION}.tar.gz"; \ + mkdir /usr/src/friendica/addon; \ + tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ + rm friendica_addons.tar.gz; + +COPY bin/* /usr/local/bin/ +COPY config/* /usr/src/config/ +COPY *.sh / +RUN chmod +x /*.sh +RUN chmod +x /usr/local/bin/* + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["php-fpm"] \ No newline at end of file diff --git a/stable/fpm/bin/friendica b/stable/fpm/bin/friendica new file mode 100644 index 0000000..3f42591 --- /dev/null +++ b/stable/fpm/bin/friendica @@ -0,0 +1,152 @@ +#!/bin/sh +set -eu + +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} + +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + dir="${1:-$SOURCEDIR}" + friendica="${2:-$FRIENDICA_VERSION}" + addons="${3:-$FRIENDICA_ADDONS}" + + echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" + + git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica + chmod 777 ${dir}/friendica/view/smarty3 + mkdir ${dir}/friendica/addon + git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon +} + +# help of this shell script +friendica_help() { + echo "Usage: friendica []" + echo "" + echo "Commands:" + echo " console Executes an command in the Friendica console" + echo " composer Executes the composer.phar executable for Friendica" + echo " install Installs Friendica" + echo " update Updates Friendica" + exit 1 +} + +# executes the Friendica console +console() { + cd ${WORKDIR} + php "${WORKDIR}/bin/console.php" "$@" +} + +# executes the composer.phar binary of Friendica +composer() { + if [ -f ${WORKDIR}/bin/composer.phar ]; then + run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}" + fi +} + +copy_sources() { + installed_version="0.0.0.0" + if [ -f ${WORKDIR}/VERSION ]; then + installed_version="$(cat ${WORKDIR}/VERSION)" + fi + + image_version="0.0.0.0" + if [ -f ${SOURCEDIR}/friendica/VERSION ]; then + image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" + elif [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + echo "Friendica command '$1' failed, because of no valid combination of source and version" + return; + fi + + if version_greater "$installed_version" "$image_version"; then + echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + + echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'" + rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ + fi +} + +# install Friendica +install() { + if [ -f ${WORKDIR}/VERSION ]; then + # If there is a given installation of Friendica and we should not update it => exit + # We have to explicit update Friendica to avoid breaking something + return + fi + + copy_sources + + echo "Installing Friendica" + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + + if [ ! -f ${WORKDIR}/.htconfig.php ] && + [ -f ${SOURCEDIR}/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr ${WORKDIR}/view/smarty3/compiled + fi +} + +update() { + if [ ! -f ${WORKDIR}/VERSION ]; then + # We want to update a given installation + # if there is no installation, exit + return + fi + + copy_sources + + echo "Upgrading Friendica" + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "update" + fi + console "dbstructure update" +} + +if [ $# -eq 0 ]; then + friendica_help +fi + +case "$1" in + install) shift; install "$@";; + update) shift; update "$@" ;; + console) shift; console "$@" ;; + composer) shift; composer "$@" ;; + *) friendica_help ;; +esac diff --git a/stable/fpm/config/htconfig.php b/stable/fpm/config/htconfig.php new file mode 100644 index 0000000..fb8180f --- /dev/null +++ b/stable/fpm/config/htconfig.php @@ -0,0 +1,104 @@ +config['system']['db_charset'] = "utf8mb4"; + +// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". +// It can be changed later and only applies to timestamps for anonymous viewers. + +if (!empty(getenv('TZ'))) { + $default_timezone = getenv('TZ'); +} else { + $default_timezone = 'America/Los_Angeles'; +} + +// Default system language +if (!empty(getenv('LANGUAGE'))) { + $a->config['system']['language'] = getenv('LANGUAGE'); +} else { + $a->config['system']['language'] = 'en'; +} + +// What is your site name? +if (!empty(getenv('SITENAME'))) { + $a->config['sitename'] = getenv('SITENAME'); +} else { + $a->config['sitename'] = "Friendica Social Network"; +} + +// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED. +// Be certain to create your own personal account before setting +// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on +// the registration page. REGISTER_APPROVE requires you set 'admin_email' +// to the email address of an already registered person who can authorise +// and/or approve/deny the request. + +// In order to perform system administration via the admin panel, admin_email +// must precisely match the email address of the person logged in. + +$a->config['register_policy'] = REGISTER_OPEN; +$a->config['register_text'] = ''; +if (!empty(getenv('MAILNAME'))) { + $a->config['admin_email'] = getenv('MAILNAME'); +} else { + $a->config['admin_email'] = ''; +} + +// Maximum size of an imported message, 0 is unlimited + +$a->config['max_import_size'] = 200000; + +// maximum size of uploaded photos + +$a->config['system']['maximagesize'] = 800000; + +// Location of PHP command line processor + +$a->config['php_path'] = 'php'; + +// Server-to-server private message encryption (RINO) is allowed by default. +// set to 0 to disable, 1 to enable + +$a->config['system']['rino_encrypt'] = 1; + +// allowed themes (change this from admin panel after installation) + +$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero,smoothly'; + +// default system theme + +$a->config['system']['theme'] = 'vier'; + + +// By default allow pseudonyms + +$a->config['system']['no_regfullname'] = true; + +//Deny public access to the local directory +//$a->config['system']['block_local_dir'] = false; + +// Location of the global directory +$a->config['system']['directory'] = 'https://dir.friendica.social'; + +// Allowed protocols in link URLs; HTTP protocols always are accepted +$a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid', 'gopher']; + +// Authentication cookie lifetime, in days +$a->config['system']['auth_cookie_lifetime'] = 7; diff --git a/stable/fpm/cron.sh b/stable/fpm/cron.sh new file mode 100644 index 0000000..b368336 --- /dev/null +++ b/stable/fpm/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file diff --git a/stable/fpm/entrypoint.sh b/stable/fpm/entrypoint.sh new file mode 100644 index 0000000..90d6839 --- /dev/null +++ b/stable/fpm/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu + +# Check if Friendica needs to get installed +friendica install + +exec "$@" \ No newline at end of file From bd2fb340d2587cc06d70295668b7b4dd57aa17d0 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Fri, 18 May 2018 21:23:21 +0200 Subject: [PATCH 02/16] Fixed .travis.yml config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2c91b23..0694495 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ install: before_script: - env | sort - cd "$VARIANT" - - slash='/'; image="friendica:${VARIANT//$slash/-\" + - slash='/'; image="friendica:${VARIANT//$slash/-}" script: - docker build -t "$image" . From 57afa34813b13533793038bfca6d05f59d3751b5 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sat, 19 May 2018 13:14:49 +0200 Subject: [PATCH 03/16] Fixed composer.phar "update" to "install" (because in both cases, we use "install") --- develop/apache/bin/friendica | 2 +- develop/fpm-alpine/bin/friendica | 2 +- develop/fpm/bin/friendica | 2 +- stable/apache/bin/friendica | 2 +- stable/fpm-alpine/bin/friendica | 2 +- stable/fpm/bin/friendica | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/develop/apache/bin/friendica b/develop/apache/bin/friendica index 3f42591..3bc63e7 100644 --- a/develop/apache/bin/friendica +++ b/develop/apache/bin/friendica @@ -134,7 +134,7 @@ update() { echo "Upgrading Friendica" if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "update" + composer "install" fi console "dbstructure update" } diff --git a/develop/fpm-alpine/bin/friendica b/develop/fpm-alpine/bin/friendica index 3f42591..3bc63e7 100644 --- a/develop/fpm-alpine/bin/friendica +++ b/develop/fpm-alpine/bin/friendica @@ -134,7 +134,7 @@ update() { echo "Upgrading Friendica" if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "update" + composer "install" fi console "dbstructure update" } diff --git a/develop/fpm/bin/friendica b/develop/fpm/bin/friendica index 3f42591..3bc63e7 100644 --- a/develop/fpm/bin/friendica +++ b/develop/fpm/bin/friendica @@ -134,7 +134,7 @@ update() { echo "Upgrading Friendica" if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "update" + composer "install" fi console "dbstructure update" } diff --git a/stable/apache/bin/friendica b/stable/apache/bin/friendica index 3f42591..3bc63e7 100644 --- a/stable/apache/bin/friendica +++ b/stable/apache/bin/friendica @@ -134,7 +134,7 @@ update() { echo "Upgrading Friendica" if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "update" + composer "install" fi console "dbstructure update" } diff --git a/stable/fpm-alpine/bin/friendica b/stable/fpm-alpine/bin/friendica index 3f42591..3bc63e7 100644 --- a/stable/fpm-alpine/bin/friendica +++ b/stable/fpm-alpine/bin/friendica @@ -134,7 +134,7 @@ update() { echo "Upgrading Friendica" if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "update" + composer "install" fi console "dbstructure update" } diff --git a/stable/fpm/bin/friendica b/stable/fpm/bin/friendica index 3f42591..3bc63e7 100644 --- a/stable/fpm/bin/friendica +++ b/stable/fpm/bin/friendica @@ -134,7 +134,7 @@ update() { echo "Upgrading Friendica" if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "update" + composer "install" fi console "dbstructure update" } From 0826aaefa9cc584ff948d6917ff755c92d5c5816 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 20 May 2018 15:44:03 +0200 Subject: [PATCH 04/16] Improvements and Examples - Adding `sendmail` feature to `apache` and `fpm` - Adding section `.examples/dockerfiles` - Adding section `.examples/dockerfiles/cron` to combine app & external cron-jobs - Adding section `.examples/dockerfiles/smtp` for further SMTP-settings --- .examples/dockerfiles/cron/apache/Dockerfile | 17 ++++++ .../dockerfiles/cron/apache/supervisord.conf | 22 +++++++ .examples/dockerfiles/cron/fpm/Dockerfile | 17 ++++++ .../dockerfiles/cron/fpm/supervisord.conf | 22 +++++++ .examples/dockerfiles/smtp/README.md | 24 ++++++++ .examples/dockerfiles/smtp/apache/Dockerfile | 9 +++ .../dockerfiles/smtp/apache/smtp-config.sh | 45 ++++++++++++++ .../dockerfiles/smtp/fpm-alpine/Dockerfile | 15 +++++ .examples/dockerfiles/smtp/fpm/Dockerfile | 9 +++ .examples/dockerfiles/smtp/fpm/smtp-config.sh | 45 ++++++++++++++ README.md | 61 +++++++++++++++---- develop/apache/Dockerfile | 6 ++ develop/apache/bin/friendica | 18 ++++++ develop/apache/cron.sh | 2 +- develop/apache/entrypoint.sh | 3 +- develop/fpm-alpine/Dockerfile | 4 ++ develop/fpm-alpine/bin/friendica | 18 ++++++ develop/fpm-alpine/cron.sh | 2 +- develop/fpm-alpine/entrypoint.sh | 3 +- develop/fpm/Dockerfile | 6 ++ develop/fpm/bin/friendica | 18 ++++++ develop/fpm/cron.sh | 2 +- develop/fpm/entrypoint.sh | 3 +- stable/apache/Dockerfile | 8 ++- stable/apache/bin/friendica | 18 ++++++ stable/apache/cron.sh | 2 +- stable/apache/entrypoint.sh | 3 +- stable/fpm-alpine/Dockerfile | 4 ++ stable/fpm-alpine/bin/friendica | 18 ++++++ stable/fpm-alpine/cron.sh | 2 +- stable/fpm-alpine/entrypoint.sh | 3 +- stable/fpm/Dockerfile | 8 ++- stable/fpm/bin/friendica | 18 ++++++ stable/fpm/cron.sh | 2 +- stable/fpm/entrypoint.sh | 3 +- 35 files changed, 434 insertions(+), 26 deletions(-) create mode 100644 .examples/dockerfiles/cron/apache/Dockerfile create mode 100644 .examples/dockerfiles/cron/apache/supervisord.conf create mode 100644 .examples/dockerfiles/cron/fpm/Dockerfile create mode 100644 .examples/dockerfiles/cron/fpm/supervisord.conf create mode 100644 .examples/dockerfiles/smtp/README.md create mode 100644 .examples/dockerfiles/smtp/apache/Dockerfile create mode 100644 .examples/dockerfiles/smtp/apache/smtp-config.sh create mode 100644 .examples/dockerfiles/smtp/fpm-alpine/Dockerfile create mode 100644 .examples/dockerfiles/smtp/fpm/Dockerfile create mode 100644 .examples/dockerfiles/smtp/fpm/smtp-config.sh diff --git a/.examples/dockerfiles/cron/apache/Dockerfile b/.examples/dockerfiles/cron/apache/Dockerfile new file mode 100644 index 0000000..5875232 --- /dev/null +++ b/.examples/dockerfiles/cron/apache/Dockerfile @@ -0,0 +1,17 @@ +FROM friendica:apache + +ENV AUTOINSTALL true +ENV MARIADB_VERSION 10.3 + +RUN set -ex; \ + ; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + supervisor \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + mkdir /var/log/supervisord /var/run/supervisord + +COPY ./supervisord.conf /etc/supervisor/supervisord.conf + +CMD ["/usr/bin/supervisord"] \ No newline at end of file diff --git a/.examples/dockerfiles/cron/apache/supervisord.conf b/.examples/dockerfiles/cron/apache/supervisord.conf new file mode 100644 index 0000000..40757b2 --- /dev/null +++ b/.examples/dockerfiles/cron/apache/supervisord.conf @@ -0,0 +1,22 @@ +[supervisord] +nodaemon=true +logfile=/var/log/supervisord/supervisord.log +pidfile=/var/run/supervisord/supervisord.pid +childlogdir=/var/log/supervisord/ +logfile_maxbytes=50MB ; maximum size of logfile before rotation +logfile_backups=10 ; number of backed up logfiles +loglevel=error + +[program:apache2] +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +command=apache2-foreground + +[program:cron] +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +command=/cron.sh \ No newline at end of file diff --git a/.examples/dockerfiles/cron/fpm/Dockerfile b/.examples/dockerfiles/cron/fpm/Dockerfile new file mode 100644 index 0000000..34f42cf --- /dev/null +++ b/.examples/dockerfiles/cron/fpm/Dockerfile @@ -0,0 +1,17 @@ +FROM friendica:fpm + +ENV AUTOINSTALL true +ENV MARIADB_VERSION 10.3 + +RUN set -ex; \ + ; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + supervisor \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + mkdir /var/log/supervisord /var/run/supervisord + +COPY ./supervisord.conf /etc/supervisor/supervisord.conf + +CMD ["/usr/bin/supervisord"] \ No newline at end of file diff --git a/.examples/dockerfiles/cron/fpm/supervisord.conf b/.examples/dockerfiles/cron/fpm/supervisord.conf new file mode 100644 index 0000000..40757b2 --- /dev/null +++ b/.examples/dockerfiles/cron/fpm/supervisord.conf @@ -0,0 +1,22 @@ +[supervisord] +nodaemon=true +logfile=/var/log/supervisord/supervisord.log +pidfile=/var/run/supervisord/supervisord.pid +childlogdir=/var/log/supervisord/ +logfile_maxbytes=50MB ; maximum size of logfile before rotation +logfile_backups=10 ; number of backed up logfiles +loglevel=error + +[program:apache2] +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +command=apache2-foreground + +[program:cron] +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +command=/cron.sh \ No newline at end of file diff --git a/.examples/dockerfiles/smtp/README.md b/.examples/dockerfiles/smtp/README.md new file mode 100644 index 0000000..3bf9a6d --- /dev/null +++ b/.examples/dockerfiles/smtp/README.md @@ -0,0 +1,24 @@ +# SMTP section + +In this subfolder are examples how to add SMTP support to the Friendica docker images. + +Each directory represents the image-version of the Dockerfile. +It uses the stable-branches of the Friendica Dockerfiles out-of-the-box. +So if you want to use the develop-branch, you have to add the prefix `develop-` at the `FROM`clause (e.g. `FROM friendica:apache` -> `FROM friendica:develop-apache`) + +- `SMTP_HOST` The host/IP of the SMTP-MTA + +## Custom SMTP Settings + +Currently, only `apache` and `fpm` supports custom SMTP settings. +You **have** to set `SMTP_TYPE` to `custom` for other settings than `SMTP_HOST` (default: `simple`) + +### SMTP Authentication +- `SMTP_USERNAME` Username for the SMTP-MTA user to authenticate. +- `SMTP_PASSWORD` Password for the SMTP-MTA user to authenticate. + +### Additional settings +- `SMTP_PORT` The port of the SMTP-MTA (default: `25`) +- `SMTP_AUTH` The authentication string for the SMTP-MTA (default: `A p`) +- `SMTP_TRUST_AUTH_MECH` The trusted authentication mechanism for the SMTP-MTA (default: `EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN`) +- `SMTP_AUTH_MECH` The authentication mechanism for the SMTP-MTA (default: `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN`) \ No newline at end of file diff --git a/.examples/dockerfiles/smtp/apache/Dockerfile b/.examples/dockerfiles/smtp/apache/Dockerfile new file mode 100644 index 0000000..fd442d1 --- /dev/null +++ b/.examples/dockerfiles/smtp/apache/Dockerfile @@ -0,0 +1,9 @@ +FROM friendica:apache + +# simple = using an smtp without any credentials (mostly in local networks) +# custom = you need to set host, port, auth_options, authinfo (e.g. for GMX support) +ENV SMTP_TYPE simple + +COPY *.sh / +RUN chmod +x /*.sh +RUN /smtp-config.sh \ No newline at end of file diff --git a/.examples/dockerfiles/smtp/apache/smtp-config.sh b/.examples/dockerfiles/smtp/apache/smtp-config.sh new file mode 100644 index 0000000..9fa076d --- /dev/null +++ b/.examples/dockerfiles/smtp/apache/smtp-config.sh @@ -0,0 +1,45 @@ +#!/bin/sh +set -eu + +IFS=\n + +SMTP_TYPE=${SMTP_TYPE:-simple} + +# config options +SMTP_HOST=${SMTP_HOST:-'localhost'} +SMTP_PORT=${SMTP_PORT:-'25'} +SMTP_AUTH=${SMTP_AUTH:-'A p'} +SMTP_TRUST_AUTH_MECH=${SMTP_TRUST_AUTH_MECH:-'EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN'} +SMTP_AUTH_MECH=${SMTP_AUTH_MECH:-'EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN'} + +SMTP_USERNAME=${SMTP_USERNAME:-''} +SMTP_PASSWORD=${SMTP_PASSWORD:-''} + +smtp_simple() { + sed -i '/MAILER_DEFINITIONS/i define(`SMART_HOST'\'',`'$SMTP_HOST''\'')dnl/' /etc/mail/sendmail.mc +} + +smtp_custom() { + cd /etc/mail + mkdir -m 700 authinfo + cd authinfo/ + echo 'Authinfo: "U:www-data" "I:'$SMTP_USERNAME'" "P:'$SMTP_PASSWORD'"' > auth_file + makemap hash auth < auth_file + + sed -i '/MAILER_DEFINITIONS/i \ +define(`SMART_HOST'\'',`'$SMTP_HOST''\'')dnl \ +define(`RELAY_MAILER_ARGS'\'', `TCP '$SMTP_HOST' '$SMTP_PORT''\'')dnl \ +define(`ESMTP_MAILER_ARGS'\'', `TCP '$SMTP_HOST' '$SMTP_PORT''\'')dnl \ +define(`confAUTH_OPTIONS'\'', `'$SMTP_AUTH''\'')dnl \ +TRUST_AUTH_MECH(`'$SMTP_TRUST_AUTH_MECH''\'')dnl \ +define(`confAUTH_MECHANISMS'\'', `'$SMTP_AUTH_MECH''\'')dnl \ +FEATURE(`authinfo'\'',`hash -o /etc/mail/authinfo/auth.db'\'')dnl' /etc/mail/sendmail.mc +} + +case $SMTP_TYPE in + simple) smtp_simple ;; + custom) smtp_custom ;; + *) + echo "Unknown SMTP-Type '$SMTP_TYPE'" + exit 1 +esac \ No newline at end of file diff --git a/.examples/dockerfiles/smtp/fpm-alpine/Dockerfile b/.examples/dockerfiles/smtp/fpm-alpine/Dockerfile new file mode 100644 index 0000000..7942bbe --- /dev/null +++ b/.examples/dockerfiles/smtp/fpm-alpine/Dockerfile @@ -0,0 +1,15 @@ +FROM friendica:develop-fpm-alpine + +RUN set -ex; \ + \ + apk add --no-cache \ + ssmtp \ + ; \ + # disable the current mailhub + sed -i "s|mailhub=|#mailhub= |g" /etc/ssmtp/ssmtp.conf; \ + # enable the new mailhub + echo "mailhub=${:-localhost}" >> /etc/ssmtp/ssmtp.conf;SMTP_HOST + +# simple = using an smtp without any credentials (mostly in local networks) +# custom = you need to set host, port, auth_options, authinfo (e.g. for GMX support) +ENV SMTP_TYPE simple \ No newline at end of file diff --git a/.examples/dockerfiles/smtp/fpm/Dockerfile b/.examples/dockerfiles/smtp/fpm/Dockerfile new file mode 100644 index 0000000..99a6f24 --- /dev/null +++ b/.examples/dockerfiles/smtp/fpm/Dockerfile @@ -0,0 +1,9 @@ +FROM friendica:develop-fpm + +# simple = using an smtp without any credentials (mostly in local networks) +# custom = you need to set host, port, auth_options, authinfo (e.g. for GMX support) +ENV SMTP_TYPE simple + +COPY *.sh / +RUN chmod +x /*.sh +RUN /smtp-config.sh \ No newline at end of file diff --git a/.examples/dockerfiles/smtp/fpm/smtp-config.sh b/.examples/dockerfiles/smtp/fpm/smtp-config.sh new file mode 100644 index 0000000..9fa076d --- /dev/null +++ b/.examples/dockerfiles/smtp/fpm/smtp-config.sh @@ -0,0 +1,45 @@ +#!/bin/sh +set -eu + +IFS=\n + +SMTP_TYPE=${SMTP_TYPE:-simple} + +# config options +SMTP_HOST=${SMTP_HOST:-'localhost'} +SMTP_PORT=${SMTP_PORT:-'25'} +SMTP_AUTH=${SMTP_AUTH:-'A p'} +SMTP_TRUST_AUTH_MECH=${SMTP_TRUST_AUTH_MECH:-'EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN'} +SMTP_AUTH_MECH=${SMTP_AUTH_MECH:-'EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN'} + +SMTP_USERNAME=${SMTP_USERNAME:-''} +SMTP_PASSWORD=${SMTP_PASSWORD:-''} + +smtp_simple() { + sed -i '/MAILER_DEFINITIONS/i define(`SMART_HOST'\'',`'$SMTP_HOST''\'')dnl/' /etc/mail/sendmail.mc +} + +smtp_custom() { + cd /etc/mail + mkdir -m 700 authinfo + cd authinfo/ + echo 'Authinfo: "U:www-data" "I:'$SMTP_USERNAME'" "P:'$SMTP_PASSWORD'"' > auth_file + makemap hash auth < auth_file + + sed -i '/MAILER_DEFINITIONS/i \ +define(`SMART_HOST'\'',`'$SMTP_HOST''\'')dnl \ +define(`RELAY_MAILER_ARGS'\'', `TCP '$SMTP_HOST' '$SMTP_PORT''\'')dnl \ +define(`ESMTP_MAILER_ARGS'\'', `TCP '$SMTP_HOST' '$SMTP_PORT''\'')dnl \ +define(`confAUTH_OPTIONS'\'', `'$SMTP_AUTH''\'')dnl \ +TRUST_AUTH_MECH(`'$SMTP_TRUST_AUTH_MECH''\'')dnl \ +define(`confAUTH_MECHANISMS'\'', `'$SMTP_AUTH_MECH''\'')dnl \ +FEATURE(`authinfo'\'',`hash -o /etc/mail/authinfo/auth.db'\'')dnl' /etc/mail/sendmail.mc +} + +case $SMTP_TYPE in + simple) smtp_simple ;; + custom) smtp_custom ;; + *) + echo "Unknown SMTP-Type '$SMTP_TYPE'" + exit 1 +esac \ No newline at end of file diff --git a/README.md b/README.md index e89ef01..bea235b 100644 --- a/README.md +++ b/README.md @@ -4,19 +4,25 @@ This repository holds the official Docker Image for [Friendica](https://friendi. # What is Friendica? -Friendica is a decentralised communications platform that integrates social communication. Our platform links to independent social projects and corporate services. +Friendica is a decentralised communications platform that integrates social communication. +Our platform links to independent social projects and corporate services. ![logo](https://cdn.rawgit.com/nupplaphil/friendica-docker/c59f235f/friendica.svg) # How to use this image -The images are designed to be used in a micro-service environment. There are two types of the image you can choose from. +The images are designed to be used in a micro-service environment. +There are two types of the image you can choose from. -The `apache` tag contains a full Friendica installation including an apache web server. It is designed to be easy to use and gets you running pretty fast. This is also the default for the `latest` tag and version tags that are not further specified. +The `apache` tag contains a full Friendica installation including an apache web server. +It is designed to be easy to use and gets you running pretty fast. +This is also the default for the `latest` tag and version tags that are not further specified. -The second option is a `fpm` container. It is based on the [php-fpm](https://hub.docker.com/_/php/) image and runs a fastCGI-Process that serves your Friendica server. To use this image it must be combined with any Webserver that can proxy the http requests to the FastCGI-port of the container. +The second option is a `fpm` container. +It is based on the [php-fpm](https://hub.docker.com/_/php/) image and runs a fastCGI-Process that serves your Friendica server. +To use this image it must be combined with any Webserver that can proxy the http requests to the FastCGI-port of the container. ## Using the apache image -You need at least one other mariadb/mysql-container to link it to Friendica +You need at least one other mariadb/mysql-container to link it to Friendica. The apache image contains a webserver and exposes port 80. To start the container type: ```console @@ -26,23 +32,53 @@ $ docker run -d -p 8080:80 --link some-mysql:mysql friendica Now you can access the Friendica installation wizard at http://localhost:8080/ from your host system. ## Using the fpm image -To use the fpm image you need an additional web server that can proxy http-request to the fpm-port of the container. For fpm connection this container exposes port 9000. In most cases you might want use another container or your host as proxy. -If you use your host you can address your Friendica container directly on port 9000. If you use another container, make sure that you add them to the same docker network (via `docker run --network ...` or a `docker-compose` file). +To use the fpm image you need an additional web server that can proxy http-request to the fpm-port of the container. For fpm connection this container exposes port 9000. +In most cases you might want use another container or your host as proxy. +If you use your host you can address your Friendica container directly on port 9000. +If you use another container, make sure that you add them to the same docker network (via `docker run --network ...` or a `docker-compose` file). In both cases you don't want to map the fpm port to you host. ```console $ docker run -d friendica:fpm ``` -As the fastCGI-Process is not capable of serving static files (style sheets, images, ...) the webserver needs access to these files. This can be achieved with the `volumes-from` option. You can find more information in the docker-compose section. +As the fastCGI-Process is not capable of serving static files (style sheets, images, ...) the webserver needs access to these files. +This can be achieved with the `volumes-from` option. +You can find more information in the docker-compose section. + +## Using the cron job + +There are three options to enable the cron-job for Friendica: +- Using the default Image and activate the cron-job (see [Installation](https://friendi.ca/resources/installation/), sector `Activating scheduled tasks`) +- Using the default image (apache, fpm, fpm-alpine) and use **two** container (one for cron and one for the main app) +- Using one of the additional, prepared [`dockerfiles`](https://github.com/friendica/docker/tree/master/.examples/dockerfiles) + +## Using sendmail for E-Mail support + +You have to set the `--hostname/-h` parameter correctly to make the `mail()` command use the right domainname of it's e-mail. +Currently, the command `sendmail` will be used for the `mail()` support of Friendica. + +Be aware that in production environment, you normally have an external MTA (or a SmartHost) for correctly signing and routing your e-mails. +See the Dockerfiles at [`smtp`](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/smtp) for examples how to configure it. + +### `apache` and `fpm` image +`sendmail` is used as a SMTP MTA for standalone usage and it works out-of-the-box. + +### `fpm-alpine` image +For alpine, there is no "standalone" mail-service available. +Therefore you **have** to setup a SMTP MTA. ## Using an external database -By default the `latest` container uses a local MySQL-Database for data storage, but the Friendica setup wizard (appears on first run) allows connecting to an existing MySQL/MariaDB database. You can also link a database container, e. g. `--link my-mysql:mysql`, and then use `mysql` as the database host on setup. More info is in the docker-compose section. +By default the `latest` container uses a local MySQL-Database for data storage, but the Friendica setup wizard (appears on first run) allows connecting to an existing MySQL/MariaDB database. +You can also link a database container, e. g. `--link my-mysql:mysql`, and then use `mysql` as the database host on setup. ## Persistent data -The Friendica installation and all data beyond what lives in the database (file uploads, etc) is stored in the [unnamed docker volume](https://docs.docker.com/engine/tutorials/dockervolumes/#adding-a-data-volume) volume `/var/www/html`. The docker daemon will store that data within the docker directory `/var/lib/docker/volumes/...`. That means your data is saved even if the container crashes, is stopped or deleted. +The Friendica installation and all data beyond what lives in the database (file uploads, etc) is stored in the [unnamed docker volume](https://docs.docker.com/engine/tutorials/dockervolumes/#adding-a-data-volume) volume `/var/www/html`. +The docker daemon will store that data within the docker directory `/var/lib/docker/volumes/...`. +That means your data is saved even if the container crashes, is stopped or deleted. -To make your data persistent to upgrading and get access for backups is using named docker volume or mount a host folder. To achieve this you need one volume for your database container and Friendica. +To make your data persistent to upgrading and get access for backups is using named docker volume or mount a host folder. +To achieve this you need one volume for your database container and Friendica. Friendica: - `/var/www/html/` folder where all Friendica data lives @@ -61,7 +97,8 @@ mariadb ``` ## Auto configuration via environment variables -The Friendica image supports auto configuration via environment variables. You can preconfigure everything that is asked on the install page on first run. +The Friendica image supports auto configuration via environment variables. +You can preconfigure everything that is asked on the install page on first run. - `AUTOINSTALL` if `true`, the automatic configuration will start (Default: `false`) diff --git a/develop/apache/Dockerfile b/develop/apache/Dockerfile index caa4387..9de57f1 100644 --- a/develop/apache/Dockerfile +++ b/develop/apache/Dockerfile @@ -13,6 +13,8 @@ RUN set -ex; \ bzip2 \ busybox-static \ git \ +# For mail() support + sendmail \ ; \ rm -rf /var/lib/apt/lists/*; \ \ @@ -93,6 +95,10 @@ RUN a2enmod rewrite remoteip ;\ } > /etc/apache2/conf-available/remoteip.conf;\ a2enconf remoteip +RUN {\ + echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ + } > /usr/local/etc/php/conf.d/sendmail.ini; + ENV FRIENDICA_VERSION develop ENV ADDONS_VERSION develop diff --git a/develop/apache/bin/friendica b/develop/apache/bin/friendica index 3bc63e7..8deda9e 100644 --- a/develop/apache/bin/friendica +++ b/develop/apache/bin/friendica @@ -30,6 +30,9 @@ clone_develop() { echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" + # Removing the whole directory first + rm -fr ${dir}/friendica + git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica chmod 777 ${dir}/friendica/view/smarty3 mkdir ${dir}/friendica/addon @@ -139,6 +142,20 @@ update() { console "dbstructure update" } +sendmail() { + if [ ! -f /etc/init.d/sendmail ]; then + # If sendmail isn't installed, exit this method + return + fi + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + echo "Starting sendmail for Mail-Support" + /etc/init.d/sendmail start +} + if [ $# -eq 0 ]; then friendica_help fi @@ -148,5 +165,6 @@ case "$1" in update) shift; update "$@" ;; console) shift; console "$@" ;; composer) shift; composer "$@" ;; + sendmail) shift; sendmail "$@" ;; *) friendica_help ;; esac diff --git a/develop/apache/cron.sh b/develop/apache/cron.sh index b368336..4dfa411 100644 --- a/develop/apache/cron.sh +++ b/develop/apache/cron.sh @@ -1,4 +1,4 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/develop/apache/entrypoint.sh b/develop/apache/entrypoint.sh index 90d6839..1f03315 100644 --- a/develop/apache/entrypoint.sh +++ b/develop/apache/entrypoint.sh @@ -3,5 +3,6 @@ set -eu # Check if Friendica needs to get installed friendica install +friendica sendmail -exec "$@" \ No newline at end of file +exec "$@" diff --git a/develop/fpm-alpine/Dockerfile b/develop/fpm-alpine/Dockerfile index c36fdbe..3083d43 100644 --- a/develop/fpm-alpine/Dockerfile +++ b/develop/fpm-alpine/Dockerfile @@ -73,6 +73,10 @@ RUN chown -R www-data:root /var/www; \ VOLUME /var/www/html +RUN {\ + echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ + } > /usr/local/etc/php/conf.d/sendmail.ini; + ENV FRIENDICA_VERSION develop ENV ADDONS_VERSION develop diff --git a/develop/fpm-alpine/bin/friendica b/develop/fpm-alpine/bin/friendica index 3bc63e7..8deda9e 100644 --- a/develop/fpm-alpine/bin/friendica +++ b/develop/fpm-alpine/bin/friendica @@ -30,6 +30,9 @@ clone_develop() { echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" + # Removing the whole directory first + rm -fr ${dir}/friendica + git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica chmod 777 ${dir}/friendica/view/smarty3 mkdir ${dir}/friendica/addon @@ -139,6 +142,20 @@ update() { console "dbstructure update" } +sendmail() { + if [ ! -f /etc/init.d/sendmail ]; then + # If sendmail isn't installed, exit this method + return + fi + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + echo "Starting sendmail for Mail-Support" + /etc/init.d/sendmail start +} + if [ $# -eq 0 ]; then friendica_help fi @@ -148,5 +165,6 @@ case "$1" in update) shift; update "$@" ;; console) shift; console "$@" ;; composer) shift; composer "$@" ;; + sendmail) shift; sendmail "$@" ;; *) friendica_help ;; esac diff --git a/develop/fpm-alpine/cron.sh b/develop/fpm-alpine/cron.sh index b368336..4dfa411 100644 --- a/develop/fpm-alpine/cron.sh +++ b/develop/fpm-alpine/cron.sh @@ -1,4 +1,4 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/develop/fpm-alpine/entrypoint.sh b/develop/fpm-alpine/entrypoint.sh index 90d6839..1f03315 100644 --- a/develop/fpm-alpine/entrypoint.sh +++ b/develop/fpm-alpine/entrypoint.sh @@ -3,5 +3,6 @@ set -eu # Check if Friendica needs to get installed friendica install +friendica sendmail -exec "$@" \ No newline at end of file +exec "$@" diff --git a/develop/fpm/Dockerfile b/develop/fpm/Dockerfile index d56a1ca..eee77ed 100644 --- a/develop/fpm/Dockerfile +++ b/develop/fpm/Dockerfile @@ -13,6 +13,8 @@ RUN set -ex; \ bzip2 \ busybox-static \ git \ +# For mail() support + sendmail \ ; \ rm -rf /var/lib/apt/lists/*; \ \ @@ -84,6 +86,10 @@ RUN chown -R www-data:root /var/www; \ VOLUME /var/www/html +RUN {\ + echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ + } > /usr/local/etc/php/conf.d/sendmail.ini; + ENV FRIENDICA_VERSION develop ENV ADDONS_VERSION develop diff --git a/develop/fpm/bin/friendica b/develop/fpm/bin/friendica index 3bc63e7..8deda9e 100644 --- a/develop/fpm/bin/friendica +++ b/develop/fpm/bin/friendica @@ -30,6 +30,9 @@ clone_develop() { echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" + # Removing the whole directory first + rm -fr ${dir}/friendica + git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica chmod 777 ${dir}/friendica/view/smarty3 mkdir ${dir}/friendica/addon @@ -139,6 +142,20 @@ update() { console "dbstructure update" } +sendmail() { + if [ ! -f /etc/init.d/sendmail ]; then + # If sendmail isn't installed, exit this method + return + fi + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + echo "Starting sendmail for Mail-Support" + /etc/init.d/sendmail start +} + if [ $# -eq 0 ]; then friendica_help fi @@ -148,5 +165,6 @@ case "$1" in update) shift; update "$@" ;; console) shift; console "$@" ;; composer) shift; composer "$@" ;; + sendmail) shift; sendmail "$@" ;; *) friendica_help ;; esac diff --git a/develop/fpm/cron.sh b/develop/fpm/cron.sh index b368336..4dfa411 100644 --- a/develop/fpm/cron.sh +++ b/develop/fpm/cron.sh @@ -1,4 +1,4 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/develop/fpm/entrypoint.sh b/develop/fpm/entrypoint.sh index 90d6839..1f03315 100644 --- a/develop/fpm/entrypoint.sh +++ b/develop/fpm/entrypoint.sh @@ -3,5 +3,6 @@ set -eu # Check if Friendica needs to get installed friendica install +friendica sendmail -exec "$@" \ No newline at end of file +exec "$@" diff --git a/stable/apache/Dockerfile b/stable/apache/Dockerfile index b78dcfb..87e88b1 100644 --- a/stable/apache/Dockerfile +++ b/stable/apache/Dockerfile @@ -13,6 +13,8 @@ RUN set -ex; \ bzip2 \ busybox-static \ git \ +# For mail() support + sendmail \ ; \ rm -rf /var/lib/apt/lists/*; \ \ @@ -93,6 +95,10 @@ RUN a2enmod rewrite remoteip ;\ } > /etc/apache2/conf-available/remoteip.conf;\ a2enconf remoteip +RUN {\ + echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ + } > /usr/local/etc/php/conf.d/sendmail.ini; + ENV FRIENDICA_VERSION 3.6 ENV ADDONS_VERSION 3.6 @@ -116,4 +122,4 @@ RUN chmod +x /*.sh RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] -CMD ["apache2-foreground"] \ No newline at end of file +CMD ["apache2-foreground"] diff --git a/stable/apache/bin/friendica b/stable/apache/bin/friendica index 3bc63e7..8deda9e 100644 --- a/stable/apache/bin/friendica +++ b/stable/apache/bin/friendica @@ -30,6 +30,9 @@ clone_develop() { echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" + # Removing the whole directory first + rm -fr ${dir}/friendica + git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica chmod 777 ${dir}/friendica/view/smarty3 mkdir ${dir}/friendica/addon @@ -139,6 +142,20 @@ update() { console "dbstructure update" } +sendmail() { + if [ ! -f /etc/init.d/sendmail ]; then + # If sendmail isn't installed, exit this method + return + fi + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + echo "Starting sendmail for Mail-Support" + /etc/init.d/sendmail start +} + if [ $# -eq 0 ]; then friendica_help fi @@ -148,5 +165,6 @@ case "$1" in update) shift; update "$@" ;; console) shift; console "$@" ;; composer) shift; composer "$@" ;; + sendmail) shift; sendmail "$@" ;; *) friendica_help ;; esac diff --git a/stable/apache/cron.sh b/stable/apache/cron.sh index b368336..4dfa411 100644 --- a/stable/apache/cron.sh +++ b/stable/apache/cron.sh @@ -1,4 +1,4 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/stable/apache/entrypoint.sh b/stable/apache/entrypoint.sh index 90d6839..1f03315 100644 --- a/stable/apache/entrypoint.sh +++ b/stable/apache/entrypoint.sh @@ -3,5 +3,6 @@ set -eu # Check if Friendica needs to get installed friendica install +friendica sendmail -exec "$@" \ No newline at end of file +exec "$@" diff --git a/stable/fpm-alpine/Dockerfile b/stable/fpm-alpine/Dockerfile index 75a66d6..793bc75 100644 --- a/stable/fpm-alpine/Dockerfile +++ b/stable/fpm-alpine/Dockerfile @@ -73,6 +73,10 @@ RUN chown -R www-data:root /var/www; \ VOLUME /var/www/html +RUN {\ + echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ + } > /usr/local/etc/php/conf.d/sendmail.ini; + ENV FRIENDICA_VERSION 3.6 ENV ADDONS_VERSION 3.6 diff --git a/stable/fpm-alpine/bin/friendica b/stable/fpm-alpine/bin/friendica index 3bc63e7..8deda9e 100644 --- a/stable/fpm-alpine/bin/friendica +++ b/stable/fpm-alpine/bin/friendica @@ -30,6 +30,9 @@ clone_develop() { echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" + # Removing the whole directory first + rm -fr ${dir}/friendica + git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica chmod 777 ${dir}/friendica/view/smarty3 mkdir ${dir}/friendica/addon @@ -139,6 +142,20 @@ update() { console "dbstructure update" } +sendmail() { + if [ ! -f /etc/init.d/sendmail ]; then + # If sendmail isn't installed, exit this method + return + fi + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + echo "Starting sendmail for Mail-Support" + /etc/init.d/sendmail start +} + if [ $# -eq 0 ]; then friendica_help fi @@ -148,5 +165,6 @@ case "$1" in update) shift; update "$@" ;; console) shift; console "$@" ;; composer) shift; composer "$@" ;; + sendmail) shift; sendmail "$@" ;; *) friendica_help ;; esac diff --git a/stable/fpm-alpine/cron.sh b/stable/fpm-alpine/cron.sh index b368336..4dfa411 100644 --- a/stable/fpm-alpine/cron.sh +++ b/stable/fpm-alpine/cron.sh @@ -1,4 +1,4 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/stable/fpm-alpine/entrypoint.sh b/stable/fpm-alpine/entrypoint.sh index 90d6839..1f03315 100644 --- a/stable/fpm-alpine/entrypoint.sh +++ b/stable/fpm-alpine/entrypoint.sh @@ -3,5 +3,6 @@ set -eu # Check if Friendica needs to get installed friendica install +friendica sendmail -exec "$@" \ No newline at end of file +exec "$@" diff --git a/stable/fpm/Dockerfile b/stable/fpm/Dockerfile index 779b621..b99361a 100644 --- a/stable/fpm/Dockerfile +++ b/stable/fpm/Dockerfile @@ -13,6 +13,8 @@ RUN set -ex; \ bzip2 \ busybox-static \ git \ +# For mail() support + sendmail \ ; \ rm -rf /var/lib/apt/lists/*; \ \ @@ -84,6 +86,10 @@ RUN chown -R www-data:root /var/www; \ VOLUME /var/www/html +RUN {\ + echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ + } > /usr/local/etc/php/conf.d/sendmail.ini; + ENV FRIENDICA_VERSION 3.6 ENV ADDONS_VERSION 3.6 @@ -107,4 +113,4 @@ RUN chmod +x /*.sh RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] -CMD ["php-fpm"] \ No newline at end of file +CMD ["php-fpm"] diff --git a/stable/fpm/bin/friendica b/stable/fpm/bin/friendica index 3bc63e7..8deda9e 100644 --- a/stable/fpm/bin/friendica +++ b/stable/fpm/bin/friendica @@ -30,6 +30,9 @@ clone_develop() { echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" + # Removing the whole directory first + rm -fr ${dir}/friendica + git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica chmod 777 ${dir}/friendica/view/smarty3 mkdir ${dir}/friendica/addon @@ -139,6 +142,20 @@ update() { console "dbstructure update" } +sendmail() { + if [ ! -f /etc/init.d/sendmail ]; then + # If sendmail isn't installed, exit this method + return + fi + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + echo "Starting sendmail for Mail-Support" + /etc/init.d/sendmail start +} + if [ $# -eq 0 ]; then friendica_help fi @@ -148,5 +165,6 @@ case "$1" in update) shift; update "$@" ;; console) shift; console "$@" ;; composer) shift; composer "$@" ;; + sendmail) shift; sendmail "$@" ;; *) friendica_help ;; esac diff --git a/stable/fpm/cron.sh b/stable/fpm/cron.sh index b368336..4dfa411 100644 --- a/stable/fpm/cron.sh +++ b/stable/fpm/cron.sh @@ -1,4 +1,4 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/stable/fpm/entrypoint.sh b/stable/fpm/entrypoint.sh index 90d6839..1f03315 100644 --- a/stable/fpm/entrypoint.sh +++ b/stable/fpm/entrypoint.sh @@ -3,5 +3,6 @@ set -eu # Check if Friendica needs to get installed friendica install +friendica sendmail -exec "$@" \ No newline at end of file +exec "$@" From 2125efd5f628396629e27485b9f4031b762daf27 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 20 May 2018 16:18:55 +0200 Subject: [PATCH 05/16] Bugfix SMTP Dockerfile for fpm-alpine - Typo & forgot ENV variable --- .examples/dockerfiles/smtp/fpm-alpine/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.examples/dockerfiles/smtp/fpm-alpine/Dockerfile b/.examples/dockerfiles/smtp/fpm-alpine/Dockerfile index 7942bbe..d226c8b 100644 --- a/.examples/dockerfiles/smtp/fpm-alpine/Dockerfile +++ b/.examples/dockerfiles/smtp/fpm-alpine/Dockerfile @@ -1,5 +1,8 @@ FROM friendica:develop-fpm-alpine +# at least you HAVE to set one SMTP_HOST (normally something like mail.example.org) +ENV SMTP_HOST mail + RUN set -ex; \ \ apk add --no-cache \ @@ -8,7 +11,7 @@ RUN set -ex; \ # disable the current mailhub sed -i "s|mailhub=|#mailhub= |g" /etc/ssmtp/ssmtp.conf; \ # enable the new mailhub - echo "mailhub=${:-localhost}" >> /etc/ssmtp/ssmtp.conf;SMTP_HOST + echo "mailhub=${SMTP_HOST:-localhost}" >> /etc/ssmtp/ssmtp.conf; # simple = using an smtp without any credentials (mostly in local networks) # custom = you need to set host, port, auth_options, authinfo (e.g. for GMX support) From 7e2bfa10c435ffd31dcee805408996f907d28e79 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 20 May 2018 16:34:47 +0200 Subject: [PATCH 06/16] `friendica` cli improvement `friendica update` now pulls the latest git changes of the develop-branch --- develop/apache/bin/friendica | 12 +++++++----- develop/fpm-alpine/bin/friendica | 12 +++++++----- develop/fpm/bin/friendica | 12 +++++++----- stable/apache/bin/friendica | 12 +++++++----- stable/fpm-alpine/bin/friendica | 12 +++++++----- stable/fpm/bin/friendica | 12 +++++++----- 6 files changed, 42 insertions(+), 30 deletions(-) diff --git a/develop/apache/bin/friendica b/develop/apache/bin/friendica index 8deda9e..8bad6ad 100644 --- a/develop/apache/bin/friendica +++ b/develop/apache/bin/friendica @@ -54,7 +54,8 @@ friendica_help() { # executes the Friendica console console() { cd ${WORKDIR} - php "${WORKDIR}/bin/console.php" "$@" + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + php "${WORKDIR}/bin/console.php" $@ } # executes the composer.phar binary of Friendica @@ -70,15 +71,16 @@ copy_sources() { installed_version="$(cat ${WORKDIR}/VERSION)" fi + if [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + fi + image_version="0.0.0.0" if [ -f ${SOURCEDIR}/friendica/VERSION ]; then image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" - elif [ "$FRIENDICA_VERSION" = "develop" ]; then - clone_develop - image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" else # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because of no valid combination of source and version" + echo "Friendica command '$1' failed, because of no version found" return; fi diff --git a/develop/fpm-alpine/bin/friendica b/develop/fpm-alpine/bin/friendica index 8deda9e..8bad6ad 100644 --- a/develop/fpm-alpine/bin/friendica +++ b/develop/fpm-alpine/bin/friendica @@ -54,7 +54,8 @@ friendica_help() { # executes the Friendica console console() { cd ${WORKDIR} - php "${WORKDIR}/bin/console.php" "$@" + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + php "${WORKDIR}/bin/console.php" $@ } # executes the composer.phar binary of Friendica @@ -70,15 +71,16 @@ copy_sources() { installed_version="$(cat ${WORKDIR}/VERSION)" fi + if [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + fi + image_version="0.0.0.0" if [ -f ${SOURCEDIR}/friendica/VERSION ]; then image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" - elif [ "$FRIENDICA_VERSION" = "develop" ]; then - clone_develop - image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" else # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because of no valid combination of source and version" + echo "Friendica command '$1' failed, because of no version found" return; fi diff --git a/develop/fpm/bin/friendica b/develop/fpm/bin/friendica index 8deda9e..8bad6ad 100644 --- a/develop/fpm/bin/friendica +++ b/develop/fpm/bin/friendica @@ -54,7 +54,8 @@ friendica_help() { # executes the Friendica console console() { cd ${WORKDIR} - php "${WORKDIR}/bin/console.php" "$@" + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + php "${WORKDIR}/bin/console.php" $@ } # executes the composer.phar binary of Friendica @@ -70,15 +71,16 @@ copy_sources() { installed_version="$(cat ${WORKDIR}/VERSION)" fi + if [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + fi + image_version="0.0.0.0" if [ -f ${SOURCEDIR}/friendica/VERSION ]; then image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" - elif [ "$FRIENDICA_VERSION" = "develop" ]; then - clone_develop - image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" else # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because of no valid combination of source and version" + echo "Friendica command '$1' failed, because of no version found" return; fi diff --git a/stable/apache/bin/friendica b/stable/apache/bin/friendica index 8deda9e..8bad6ad 100644 --- a/stable/apache/bin/friendica +++ b/stable/apache/bin/friendica @@ -54,7 +54,8 @@ friendica_help() { # executes the Friendica console console() { cd ${WORKDIR} - php "${WORKDIR}/bin/console.php" "$@" + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + php "${WORKDIR}/bin/console.php" $@ } # executes the composer.phar binary of Friendica @@ -70,15 +71,16 @@ copy_sources() { installed_version="$(cat ${WORKDIR}/VERSION)" fi + if [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + fi + image_version="0.0.0.0" if [ -f ${SOURCEDIR}/friendica/VERSION ]; then image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" - elif [ "$FRIENDICA_VERSION" = "develop" ]; then - clone_develop - image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" else # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because of no valid combination of source and version" + echo "Friendica command '$1' failed, because of no version found" return; fi diff --git a/stable/fpm-alpine/bin/friendica b/stable/fpm-alpine/bin/friendica index 8deda9e..8bad6ad 100644 --- a/stable/fpm-alpine/bin/friendica +++ b/stable/fpm-alpine/bin/friendica @@ -54,7 +54,8 @@ friendica_help() { # executes the Friendica console console() { cd ${WORKDIR} - php "${WORKDIR}/bin/console.php" "$@" + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + php "${WORKDIR}/bin/console.php" $@ } # executes the composer.phar binary of Friendica @@ -70,15 +71,16 @@ copy_sources() { installed_version="$(cat ${WORKDIR}/VERSION)" fi + if [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + fi + image_version="0.0.0.0" if [ -f ${SOURCEDIR}/friendica/VERSION ]; then image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" - elif [ "$FRIENDICA_VERSION" = "develop" ]; then - clone_develop - image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" else # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because of no valid combination of source and version" + echo "Friendica command '$1' failed, because of no version found" return; fi diff --git a/stable/fpm/bin/friendica b/stable/fpm/bin/friendica index 8deda9e..8bad6ad 100644 --- a/stable/fpm/bin/friendica +++ b/stable/fpm/bin/friendica @@ -54,7 +54,8 @@ friendica_help() { # executes the Friendica console console() { cd ${WORKDIR} - php "${WORKDIR}/bin/console.php" "$@" + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + php "${WORKDIR}/bin/console.php" $@ } # executes the composer.phar binary of Friendica @@ -70,15 +71,16 @@ copy_sources() { installed_version="$(cat ${WORKDIR}/VERSION)" fi + if [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + fi + image_version="0.0.0.0" if [ -f ${SOURCEDIR}/friendica/VERSION ]; then image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" - elif [ "$FRIENDICA_VERSION" = "develop" ]; then - clone_develop - image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" else # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because of no valid combination of source and version" + echo "Friendica command '$1' failed, because of no version found" return; fi From a6d069de070a39444fac54f7af6177b4e794d0fe Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 20 May 2018 16:51:55 +0200 Subject: [PATCH 07/16] Added documentation about Update & the friendica shell in `README.md` --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index bea235b..bc040cd 100644 --- a/README.md +++ b/README.md @@ -115,5 +115,36 @@ You can also predefine the following `.htconfig.php` values: - `LANGUAGE` The default language of the Friendica server - `SITENAME` The default name of the Friendica server +## Updating Friendica + +There are differences between the [stable](https://github.com/friendica/docker/tree/master/stable/) and the [develop](https://github.com/friendica/docker/tree/master/develop/) branches. + +They have both in common that normally we do not automatically overwrite your working directory with the new version. +Instead you need to explicit run `friendica update` for the node for updating files&database. + +## Updating stable +You have to pull the latest image from the hub (`docker pull friendica`). + +## Updating develop +You don't need to pull the image for each commit in [friendica](https://github.com/friendica/friendica/). +Instead you can just update your node with `friendica update`. +It will clone the latest Friendica version and copy it to your working directory. + +# The `friendica` CLI + +To make the usage of the Dockerimages smooth, we created a little CLI. +It wraps the common commands for Friendica and adds new commands. + +You can call it with +```console +$ docker exec -ti friendica_running_node friendica \ +``` + +Commands: +- `console` Executes an command in the Friendica console (`bin/console.php` wrapper) +- `composer` Executes the composer.phar executable for Friendica (`bin/composer.phar` wrapper) +- `install` Installs Friendica on a empty environment (gets called automatically during first start) +- `update` Updates Friendica on a **existing** environment + # Questions / Issues If you got any questions or problems using the image, please visit our [Github Repository](https://github.com/friendica/docker) and write an issue. \ No newline at end of file From 3aebb1ac08eca24899613bb5a8a32f0ef2691dd2 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 20 May 2018 16:54:57 +0200 Subject: [PATCH 08/16] Replaced every "exit" in the `friendica` CLI with "return" This should possibly fix the Travis.yml test --- develop/apache/bin/friendica | 4 ++-- develop/fpm-alpine/bin/friendica | 4 ++-- develop/fpm/bin/friendica | 4 ++-- stable/apache/bin/friendica | 4 ++-- stable/fpm-alpine/bin/friendica | 4 ++-- stable/fpm/bin/friendica | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/develop/apache/bin/friendica b/develop/apache/bin/friendica index 8bad6ad..66233c1 100644 --- a/develop/apache/bin/friendica +++ b/develop/apache/bin/friendica @@ -48,7 +48,7 @@ friendica_help() { echo " composer Executes the composer.phar executable for Friendica" echo " install Installs Friendica" echo " update Updates Friendica" - exit 1 + return } # executes the Friendica console @@ -86,7 +86,7 @@ copy_sources() { if version_greater "$installed_version" "$image_version"; then echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - exit 1; + return; fi if version_greater "$image_version" "$installed_version"; then diff --git a/develop/fpm-alpine/bin/friendica b/develop/fpm-alpine/bin/friendica index 8bad6ad..66233c1 100644 --- a/develop/fpm-alpine/bin/friendica +++ b/develop/fpm-alpine/bin/friendica @@ -48,7 +48,7 @@ friendica_help() { echo " composer Executes the composer.phar executable for Friendica" echo " install Installs Friendica" echo " update Updates Friendica" - exit 1 + return } # executes the Friendica console @@ -86,7 +86,7 @@ copy_sources() { if version_greater "$installed_version" "$image_version"; then echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - exit 1; + return; fi if version_greater "$image_version" "$installed_version"; then diff --git a/develop/fpm/bin/friendica b/develop/fpm/bin/friendica index 8bad6ad..66233c1 100644 --- a/develop/fpm/bin/friendica +++ b/develop/fpm/bin/friendica @@ -48,7 +48,7 @@ friendica_help() { echo " composer Executes the composer.phar executable for Friendica" echo " install Installs Friendica" echo " update Updates Friendica" - exit 1 + return } # executes the Friendica console @@ -86,7 +86,7 @@ copy_sources() { if version_greater "$installed_version" "$image_version"; then echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - exit 1; + return; fi if version_greater "$image_version" "$installed_version"; then diff --git a/stable/apache/bin/friendica b/stable/apache/bin/friendica index 8bad6ad..66233c1 100644 --- a/stable/apache/bin/friendica +++ b/stable/apache/bin/friendica @@ -48,7 +48,7 @@ friendica_help() { echo " composer Executes the composer.phar executable for Friendica" echo " install Installs Friendica" echo " update Updates Friendica" - exit 1 + return } # executes the Friendica console @@ -86,7 +86,7 @@ copy_sources() { if version_greater "$installed_version" "$image_version"; then echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - exit 1; + return; fi if version_greater "$image_version" "$installed_version"; then diff --git a/stable/fpm-alpine/bin/friendica b/stable/fpm-alpine/bin/friendica index 8bad6ad..66233c1 100644 --- a/stable/fpm-alpine/bin/friendica +++ b/stable/fpm-alpine/bin/friendica @@ -48,7 +48,7 @@ friendica_help() { echo " composer Executes the composer.phar executable for Friendica" echo " install Installs Friendica" echo " update Updates Friendica" - exit 1 + return } # executes the Friendica console @@ -86,7 +86,7 @@ copy_sources() { if version_greater "$installed_version" "$image_version"; then echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - exit 1; + return; fi if version_greater "$image_version" "$installed_version"; then diff --git a/stable/fpm/bin/friendica b/stable/fpm/bin/friendica index 8bad6ad..66233c1 100644 --- a/stable/fpm/bin/friendica +++ b/stable/fpm/bin/friendica @@ -48,7 +48,7 @@ friendica_help() { echo " composer Executes the composer.phar executable for Friendica" echo " install Installs Friendica" echo " update Updates Friendica" - exit 1 + return } # executes the Friendica console @@ -86,7 +86,7 @@ copy_sources() { if version_greater "$installed_version" "$image_version"; then echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - exit 1; + return; fi if version_greater "$image_version" "$installed_version"; then From 0f93be95e88c5b73ecc1e2a0d0b8d4a7954c33a8 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 20 May 2018 20:02:01 +0200 Subject: [PATCH 09/16] README.md fix --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bc040cd..a70cf09 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,8 @@ $ docker run -d -p 8080:80 --link some-mysql:mysql friendica Now you can access the Friendica installation wizard at http://localhost:8080/ from your host system. ## Using the fpm image -To use the fpm image you need an additional web server that can proxy http-request to the fpm-port of the container. For fpm connection this container exposes port 9000. +To use the fpm image you need an additional web server that can proxy http-request to the fpm-port of the container. +For fpm connection this container exposes port 9000. In most cases you might want use another container or your host as proxy. If you use your host you can address your Friendica container directly on port 9000. If you use another container, make sure that you add them to the same docker network (via `docker run --network ...` or a `docker-compose` file). From 532fa98ff6b3098cde3e636011f6748e38e1d119 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 20 May 2018 20:02:58 +0200 Subject: [PATCH 10/16] README.md fix --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a70cf09..aa5e59f 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ To use this image it must be combined with any Webserver that can proxy the http ## Using the apache image You need at least one other mariadb/mysql-container to link it to Friendica. -The apache image contains a webserver and exposes port 80. To start the container type: +The apache image contains a webserver and exposes port 80. +To start the container type: ```console $ docker run -d -p 8080:80 --link some-mysql:mysql friendica ``` From c8069b2d5462965d87d131e62b7f4c2c4826e475 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 20 May 2018 20:16:22 +0200 Subject: [PATCH 11/16] Added travis build-status to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index aa5e59f..09e61cc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Docker Image for Friendica +[![Build Status Travis](https://travis-ci.org/friendica/docker.svg?branch=master)](https://travis-ci.org/friendica/docker) This repository holds the official Docker Image for [Friendica](https://friendi.ca) From eb7399e6f2fff7c72c5d66412a31c6dcad51402f Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 20 May 2018 21:55:54 +0200 Subject: [PATCH 12/16] Fixing travis tests - deleting `friendica` binary (not usable in docker environments) - adding the business logic to `entrypoint.sh` - quiet installation of Friendica (reason for Travis-fails!) --- README.md | 22 +--- develop/apache/Dockerfile | 2 - develop/apache/bin/friendica | 172 ------------------------------- develop/apache/cron.sh | 2 +- develop/apache/entrypoint.sh | 107 ++++++++++++++++++- develop/fpm-alpine/Dockerfile | 2 - develop/fpm-alpine/bin/friendica | 172 ------------------------------- develop/fpm-alpine/cron.sh | 2 +- develop/fpm-alpine/entrypoint.sh | 107 ++++++++++++++++++- develop/fpm/Dockerfile | 2 - develop/fpm/bin/friendica | 172 ------------------------------- develop/fpm/cron.sh | 2 +- develop/fpm/entrypoint.sh | 107 ++++++++++++++++++- stable/apache/Dockerfile | 2 - stable/apache/bin/friendica | 172 ------------------------------- stable/apache/cron.sh | 2 +- stable/apache/entrypoint.sh | 107 ++++++++++++++++++- stable/fpm-alpine/Dockerfile | 2 - stable/fpm-alpine/bin/friendica | 172 ------------------------------- stable/fpm-alpine/cron.sh | 2 +- stable/fpm-alpine/entrypoint.sh | 107 ++++++++++++++++++- stable/fpm/Dockerfile | 2 - stable/fpm/bin/friendica | 172 ------------------------------- stable/fpm/cron.sh | 2 +- stable/fpm/entrypoint.sh | 107 ++++++++++++++++++- 25 files changed, 629 insertions(+), 1091 deletions(-) delete mode 100644 develop/apache/bin/friendica delete mode 100644 develop/fpm-alpine/bin/friendica delete mode 100644 develop/fpm/bin/friendica delete mode 100644 stable/apache/bin/friendica delete mode 100644 stable/fpm-alpine/bin/friendica delete mode 100644 stable/fpm/bin/friendica diff --git a/README.md b/README.md index 09e61cc..48669d3 100644 --- a/README.md +++ b/README.md @@ -123,31 +123,19 @@ You can also predefine the following `.htconfig.php` values: There are differences between the [stable](https://github.com/friendica/docker/tree/master/stable/) and the [develop](https://github.com/friendica/docker/tree/master/develop/) branches. They have both in common that normally we do not automatically overwrite your working directory with the new version. -Instead you need to explicit run `friendica update` for the node for updating files&database. +Instead you need to explicit run `update` for the node for updating files&database. ## Updating stable You have to pull the latest image from the hub (`docker pull friendica`). ## Updating develop You don't need to pull the image for each commit in [friendica](https://github.com/friendica/friendica/). -Instead you can just update your node with `friendica update`. -It will clone the latest Friendica version and copy it to your working directory. - -# The `friendica` CLI - -To make the usage of the Dockerimages smooth, we created a little CLI. -It wraps the common commands for Friendica and adds new commands. - -You can call it with +Instead you can just update your node with executing `update` on the node. +Example: ```console -$ docker exec -ti friendica_running_node friendica \ +$ docker exec -ti friendica_running_node update ``` - -Commands: -- `console` Executes an command in the Friendica console (`bin/console.php` wrapper) -- `composer` Executes the composer.phar executable for Friendica (`bin/composer.phar` wrapper) -- `install` Installs Friendica on a empty environment (gets called automatically during first start) -- `update` Updates Friendica on a **existing** environment +It will clone the latest Friendica version and copy it to your working directory. # Questions / Issues If you got any questions or problems using the image, please visit our [Github Repository](https://github.com/friendica/docker) and write an issue. \ No newline at end of file diff --git a/develop/apache/Dockerfile b/develop/apache/Dockerfile index 9de57f1..ac9de19 100644 --- a/develop/apache/Dockerfile +++ b/develop/apache/Dockerfile @@ -102,11 +102,9 @@ RUN {\ ENV FRIENDICA_VERSION develop ENV ADDONS_VERSION develop -COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ COPY *.sh / RUN chmod +x /*.sh -RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] CMD ["apache2-foreground"] \ No newline at end of file diff --git a/develop/apache/bin/friendica b/develop/apache/bin/friendica deleted file mode 100644 index 66233c1..0000000 --- a/develop/apache/bin/friendica +++ /dev/null @@ -1,172 +0,0 @@ -#!/bin/sh -set -eu - -FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} -FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} -AUTOINSTALL=${AUTOINSTALL:-false} - -SOURCEDIR=/usr/src -WORKDIR=/var/www/html - -# run an command with the www-data user -run_as() { - if [ "$(id -u)" = 0 ]; then - su - www-data -s /bin/sh -c "$1" - else - sh -c "$1" - fi -} - -# checks if the the first parameter is greater than the second parameter -version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] -} - -# clones the whole develop branch (Friendica and Addons) -clone_develop() { - dir="${1:-$SOURCEDIR}" - friendica="${2:-$FRIENDICA_VERSION}" - addons="${3:-$FRIENDICA_ADDONS}" - - echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" - - # Removing the whole directory first - rm -fr ${dir}/friendica - - git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica - chmod 777 ${dir}/friendica/view/smarty3 - mkdir ${dir}/friendica/addon - git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon -} - -# help of this shell script -friendica_help() { - echo "Usage: friendica []" - echo "" - echo "Commands:" - echo " console Executes an command in the Friendica console" - echo " composer Executes the composer.phar executable for Friendica" - echo " install Installs Friendica" - echo " update Updates Friendica" - return -} - -# executes the Friendica console -console() { - cd ${WORKDIR} - # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - php "${WORKDIR}/bin/console.php" $@ -} - -# executes the composer.phar binary of Friendica -composer() { - if [ -f ${WORKDIR}/bin/composer.phar ]; then - run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}" - fi -} - -copy_sources() { - installed_version="0.0.0.0" - if [ -f ${WORKDIR}/VERSION ]; then - installed_version="$(cat ${WORKDIR}/VERSION)" - fi - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - clone_develop - fi - - image_version="0.0.0.0" - if [ -f ${SOURCEDIR}/friendica/VERSION ]; then - image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" - else - # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because of no version found" - return; - fi - - if version_greater "$installed_version" "$image_version"; then - echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - return; - fi - - if version_greater "$image_version" "$installed_version"; then - if [ "$(id -u)" = 0 ]; then - rsync_options="-rlDog --chown www-data:root" - else - rsync_options="-rlD" - fi - - echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'" - rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ - fi -} - -# install Friendica -install() { - if [ -f ${WORKDIR}/VERSION ]; then - # If there is a given installation of Friendica and we should not update it => exit - # We have to explicit update Friendica to avoid breaking something - return - fi - - copy_sources - - echo "Installing Friendica" - if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "install" - fi - - if [ ! -f ${WORKDIR}/.htconfig.php ] && - [ -f ${SOURCEDIR}/config/htconfig.php ] && - "$AUTOINSTALL" == "true"; then - run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" - # TODO Pull Request for dba Change - run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" - console "autoinstall -f .htconfig.php" - # TODO Workaround because of a strange permission issue - rm -fr ${WORKDIR}/view/smarty3/compiled - fi -} - -update() { - if [ ! -f ${WORKDIR}/VERSION ]; then - # We want to update a given installation - # if there is no installation, exit - return - fi - - copy_sources - - echo "Upgrading Friendica" - if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "install" - fi - console "dbstructure update" -} - -sendmail() { - if [ ! -f /etc/init.d/sendmail ]; then - # If sendmail isn't installed, exit this method - return - fi - - line=$(head -n 1 /etc/hosts) - line2=$(echo $line | awk '{print $2}') - echo "$line $line2.localdomain" >> /etc/hosts - - echo "Starting sendmail for Mail-Support" - /etc/init.d/sendmail start -} - -if [ $# -eq 0 ]; then - friendica_help -fi - -case "$1" in - install) shift; install "$@";; - update) shift; update "$@" ;; - console) shift; console "$@" ;; - composer) shift; composer "$@" ;; - sendmail) shift; sendmail "$@" ;; - *) friendica_help ;; -esac diff --git a/develop/apache/cron.sh b/develop/apache/cron.sh index 4dfa411..b368336 100644 --- a/develop/apache/cron.sh +++ b/develop/apache/cron.sh @@ -1,4 +1,4 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file diff --git a/develop/apache/entrypoint.sh b/develop/apache/entrypoint.sh index 1f03315..b95492b 100644 --- a/develop/apache/entrypoint.sh +++ b/develop/apache/entrypoint.sh @@ -1,8 +1,107 @@ #!/bin/sh set -eu -# Check if Friendica needs to get installed -friendica install -friendica sendmail +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} -exec "$@" +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# executes the Friendica console +console() { + cd $WORKDIR + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1 +} + +# If there is no VERSION file or the command is "update", (re-)install Friendica +if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then + + installed_version="0.0.0.0" + if [ -f $WORKDIR/VERSION ]; then + installed_version="$(cat $WORKDIR/VERSION)" + fi + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + # Removing the whole directory first + rm -fr $SOURCEDIR/friendica + + git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1 + chmod 777 $SOURCEDIR/friendica/view/smarty3 + mkdir $SOURCEDIR/friendica/addon + git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1 + fi + + image_version="0.0.0.0" + if [ -f $SOURCEDIR/friendica/VERSION ]; then + image_version="$(cat $SOURCEDIR/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + echo "Friendica command '$1' failed, because no version found" + exit 1; + fi + + if version_greater "$installed_version" "$image_version"; then + echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + + rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + if [ ! -f ${WORKDIR}/bin/composer.phar ]; then + echo "no composer found" + exit 1 + fi + + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1 + fi + + if [ ! -f $WORKDIR/.htconfig.php ] && + [ -f $SOURCEDIR/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr $WORKDIR/view/smarty3/compiled + elif [ "$1" = "update" ]; then + console "dbstructure update" + fi + fi +fi + +# Start sendmail if you find it +if [ -f /etc/init.d/sendmail ]; then + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + nohup /etc/init.d/sendmail start > /dev/null 2>&1 & +fi + +exec "$@" \ No newline at end of file diff --git a/develop/fpm-alpine/Dockerfile b/develop/fpm-alpine/Dockerfile index 3083d43..271c507 100644 --- a/develop/fpm-alpine/Dockerfile +++ b/develop/fpm-alpine/Dockerfile @@ -80,11 +80,9 @@ RUN {\ ENV FRIENDICA_VERSION develop ENV ADDONS_VERSION develop -COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ COPY *.sh / RUN chmod +x /*.sh -RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] \ No newline at end of file diff --git a/develop/fpm-alpine/bin/friendica b/develop/fpm-alpine/bin/friendica deleted file mode 100644 index 66233c1..0000000 --- a/develop/fpm-alpine/bin/friendica +++ /dev/null @@ -1,172 +0,0 @@ -#!/bin/sh -set -eu - -FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} -FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} -AUTOINSTALL=${AUTOINSTALL:-false} - -SOURCEDIR=/usr/src -WORKDIR=/var/www/html - -# run an command with the www-data user -run_as() { - if [ "$(id -u)" = 0 ]; then - su - www-data -s /bin/sh -c "$1" - else - sh -c "$1" - fi -} - -# checks if the the first parameter is greater than the second parameter -version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] -} - -# clones the whole develop branch (Friendica and Addons) -clone_develop() { - dir="${1:-$SOURCEDIR}" - friendica="${2:-$FRIENDICA_VERSION}" - addons="${3:-$FRIENDICA_ADDONS}" - - echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" - - # Removing the whole directory first - rm -fr ${dir}/friendica - - git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica - chmod 777 ${dir}/friendica/view/smarty3 - mkdir ${dir}/friendica/addon - git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon -} - -# help of this shell script -friendica_help() { - echo "Usage: friendica []" - echo "" - echo "Commands:" - echo " console Executes an command in the Friendica console" - echo " composer Executes the composer.phar executable for Friendica" - echo " install Installs Friendica" - echo " update Updates Friendica" - return -} - -# executes the Friendica console -console() { - cd ${WORKDIR} - # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - php "${WORKDIR}/bin/console.php" $@ -} - -# executes the composer.phar binary of Friendica -composer() { - if [ -f ${WORKDIR}/bin/composer.phar ]; then - run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}" - fi -} - -copy_sources() { - installed_version="0.0.0.0" - if [ -f ${WORKDIR}/VERSION ]; then - installed_version="$(cat ${WORKDIR}/VERSION)" - fi - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - clone_develop - fi - - image_version="0.0.0.0" - if [ -f ${SOURCEDIR}/friendica/VERSION ]; then - image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" - else - # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because of no version found" - return; - fi - - if version_greater "$installed_version" "$image_version"; then - echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - return; - fi - - if version_greater "$image_version" "$installed_version"; then - if [ "$(id -u)" = 0 ]; then - rsync_options="-rlDog --chown www-data:root" - else - rsync_options="-rlD" - fi - - echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'" - rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ - fi -} - -# install Friendica -install() { - if [ -f ${WORKDIR}/VERSION ]; then - # If there is a given installation of Friendica and we should not update it => exit - # We have to explicit update Friendica to avoid breaking something - return - fi - - copy_sources - - echo "Installing Friendica" - if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "install" - fi - - if [ ! -f ${WORKDIR}/.htconfig.php ] && - [ -f ${SOURCEDIR}/config/htconfig.php ] && - "$AUTOINSTALL" == "true"; then - run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" - # TODO Pull Request for dba Change - run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" - console "autoinstall -f .htconfig.php" - # TODO Workaround because of a strange permission issue - rm -fr ${WORKDIR}/view/smarty3/compiled - fi -} - -update() { - if [ ! -f ${WORKDIR}/VERSION ]; then - # We want to update a given installation - # if there is no installation, exit - return - fi - - copy_sources - - echo "Upgrading Friendica" - if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "install" - fi - console "dbstructure update" -} - -sendmail() { - if [ ! -f /etc/init.d/sendmail ]; then - # If sendmail isn't installed, exit this method - return - fi - - line=$(head -n 1 /etc/hosts) - line2=$(echo $line | awk '{print $2}') - echo "$line $line2.localdomain" >> /etc/hosts - - echo "Starting sendmail for Mail-Support" - /etc/init.d/sendmail start -} - -if [ $# -eq 0 ]; then - friendica_help -fi - -case "$1" in - install) shift; install "$@";; - update) shift; update "$@" ;; - console) shift; console "$@" ;; - composer) shift; composer "$@" ;; - sendmail) shift; sendmail "$@" ;; - *) friendica_help ;; -esac diff --git a/develop/fpm-alpine/cron.sh b/develop/fpm-alpine/cron.sh index 4dfa411..b368336 100644 --- a/develop/fpm-alpine/cron.sh +++ b/develop/fpm-alpine/cron.sh @@ -1,4 +1,4 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file diff --git a/develop/fpm-alpine/entrypoint.sh b/develop/fpm-alpine/entrypoint.sh index 1f03315..b95492b 100644 --- a/develop/fpm-alpine/entrypoint.sh +++ b/develop/fpm-alpine/entrypoint.sh @@ -1,8 +1,107 @@ #!/bin/sh set -eu -# Check if Friendica needs to get installed -friendica install -friendica sendmail +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} -exec "$@" +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# executes the Friendica console +console() { + cd $WORKDIR + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1 +} + +# If there is no VERSION file or the command is "update", (re-)install Friendica +if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then + + installed_version="0.0.0.0" + if [ -f $WORKDIR/VERSION ]; then + installed_version="$(cat $WORKDIR/VERSION)" + fi + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + # Removing the whole directory first + rm -fr $SOURCEDIR/friendica + + git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1 + chmod 777 $SOURCEDIR/friendica/view/smarty3 + mkdir $SOURCEDIR/friendica/addon + git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1 + fi + + image_version="0.0.0.0" + if [ -f $SOURCEDIR/friendica/VERSION ]; then + image_version="$(cat $SOURCEDIR/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + echo "Friendica command '$1' failed, because no version found" + exit 1; + fi + + if version_greater "$installed_version" "$image_version"; then + echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + + rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + if [ ! -f ${WORKDIR}/bin/composer.phar ]; then + echo "no composer found" + exit 1 + fi + + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1 + fi + + if [ ! -f $WORKDIR/.htconfig.php ] && + [ -f $SOURCEDIR/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr $WORKDIR/view/smarty3/compiled + elif [ "$1" = "update" ]; then + console "dbstructure update" + fi + fi +fi + +# Start sendmail if you find it +if [ -f /etc/init.d/sendmail ]; then + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + nohup /etc/init.d/sendmail start > /dev/null 2>&1 & +fi + +exec "$@" \ No newline at end of file diff --git a/develop/fpm/Dockerfile b/develop/fpm/Dockerfile index eee77ed..078a525 100644 --- a/develop/fpm/Dockerfile +++ b/develop/fpm/Dockerfile @@ -93,11 +93,9 @@ RUN {\ ENV FRIENDICA_VERSION develop ENV ADDONS_VERSION develop -COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ COPY *.sh / RUN chmod +x /*.sh -RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] \ No newline at end of file diff --git a/develop/fpm/bin/friendica b/develop/fpm/bin/friendica deleted file mode 100644 index 66233c1..0000000 --- a/develop/fpm/bin/friendica +++ /dev/null @@ -1,172 +0,0 @@ -#!/bin/sh -set -eu - -FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} -FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} -AUTOINSTALL=${AUTOINSTALL:-false} - -SOURCEDIR=/usr/src -WORKDIR=/var/www/html - -# run an command with the www-data user -run_as() { - if [ "$(id -u)" = 0 ]; then - su - www-data -s /bin/sh -c "$1" - else - sh -c "$1" - fi -} - -# checks if the the first parameter is greater than the second parameter -version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] -} - -# clones the whole develop branch (Friendica and Addons) -clone_develop() { - dir="${1:-$SOURCEDIR}" - friendica="${2:-$FRIENDICA_VERSION}" - addons="${3:-$FRIENDICA_ADDONS}" - - echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" - - # Removing the whole directory first - rm -fr ${dir}/friendica - - git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica - chmod 777 ${dir}/friendica/view/smarty3 - mkdir ${dir}/friendica/addon - git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon -} - -# help of this shell script -friendica_help() { - echo "Usage: friendica []" - echo "" - echo "Commands:" - echo " console Executes an command in the Friendica console" - echo " composer Executes the composer.phar executable for Friendica" - echo " install Installs Friendica" - echo " update Updates Friendica" - return -} - -# executes the Friendica console -console() { - cd ${WORKDIR} - # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - php "${WORKDIR}/bin/console.php" $@ -} - -# executes the composer.phar binary of Friendica -composer() { - if [ -f ${WORKDIR}/bin/composer.phar ]; then - run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}" - fi -} - -copy_sources() { - installed_version="0.0.0.0" - if [ -f ${WORKDIR}/VERSION ]; then - installed_version="$(cat ${WORKDIR}/VERSION)" - fi - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - clone_develop - fi - - image_version="0.0.0.0" - if [ -f ${SOURCEDIR}/friendica/VERSION ]; then - image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" - else - # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because of no version found" - return; - fi - - if version_greater "$installed_version" "$image_version"; then - echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - return; - fi - - if version_greater "$image_version" "$installed_version"; then - if [ "$(id -u)" = 0 ]; then - rsync_options="-rlDog --chown www-data:root" - else - rsync_options="-rlD" - fi - - echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'" - rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ - fi -} - -# install Friendica -install() { - if [ -f ${WORKDIR}/VERSION ]; then - # If there is a given installation of Friendica and we should not update it => exit - # We have to explicit update Friendica to avoid breaking something - return - fi - - copy_sources - - echo "Installing Friendica" - if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "install" - fi - - if [ ! -f ${WORKDIR}/.htconfig.php ] && - [ -f ${SOURCEDIR}/config/htconfig.php ] && - "$AUTOINSTALL" == "true"; then - run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" - # TODO Pull Request for dba Change - run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" - console "autoinstall -f .htconfig.php" - # TODO Workaround because of a strange permission issue - rm -fr ${WORKDIR}/view/smarty3/compiled - fi -} - -update() { - if [ ! -f ${WORKDIR}/VERSION ]; then - # We want to update a given installation - # if there is no installation, exit - return - fi - - copy_sources - - echo "Upgrading Friendica" - if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "install" - fi - console "dbstructure update" -} - -sendmail() { - if [ ! -f /etc/init.d/sendmail ]; then - # If sendmail isn't installed, exit this method - return - fi - - line=$(head -n 1 /etc/hosts) - line2=$(echo $line | awk '{print $2}') - echo "$line $line2.localdomain" >> /etc/hosts - - echo "Starting sendmail for Mail-Support" - /etc/init.d/sendmail start -} - -if [ $# -eq 0 ]; then - friendica_help -fi - -case "$1" in - install) shift; install "$@";; - update) shift; update "$@" ;; - console) shift; console "$@" ;; - composer) shift; composer "$@" ;; - sendmail) shift; sendmail "$@" ;; - *) friendica_help ;; -esac diff --git a/develop/fpm/cron.sh b/develop/fpm/cron.sh index 4dfa411..b368336 100644 --- a/develop/fpm/cron.sh +++ b/develop/fpm/cron.sh @@ -1,4 +1,4 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file diff --git a/develop/fpm/entrypoint.sh b/develop/fpm/entrypoint.sh index 1f03315..b95492b 100644 --- a/develop/fpm/entrypoint.sh +++ b/develop/fpm/entrypoint.sh @@ -1,8 +1,107 @@ #!/bin/sh set -eu -# Check if Friendica needs to get installed -friendica install -friendica sendmail +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} -exec "$@" +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# executes the Friendica console +console() { + cd $WORKDIR + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1 +} + +# If there is no VERSION file or the command is "update", (re-)install Friendica +if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then + + installed_version="0.0.0.0" + if [ -f $WORKDIR/VERSION ]; then + installed_version="$(cat $WORKDIR/VERSION)" + fi + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + # Removing the whole directory first + rm -fr $SOURCEDIR/friendica + + git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1 + chmod 777 $SOURCEDIR/friendica/view/smarty3 + mkdir $SOURCEDIR/friendica/addon + git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1 + fi + + image_version="0.0.0.0" + if [ -f $SOURCEDIR/friendica/VERSION ]; then + image_version="$(cat $SOURCEDIR/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + echo "Friendica command '$1' failed, because no version found" + exit 1; + fi + + if version_greater "$installed_version" "$image_version"; then + echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + + rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + if [ ! -f ${WORKDIR}/bin/composer.phar ]; then + echo "no composer found" + exit 1 + fi + + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1 + fi + + if [ ! -f $WORKDIR/.htconfig.php ] && + [ -f $SOURCEDIR/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr $WORKDIR/view/smarty3/compiled + elif [ "$1" = "update" ]; then + console "dbstructure update" + fi + fi +fi + +# Start sendmail if you find it +if [ -f /etc/init.d/sendmail ]; then + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + nohup /etc/init.d/sendmail start > /dev/null 2>&1 & +fi + +exec "$@" \ No newline at end of file diff --git a/stable/apache/Dockerfile b/stable/apache/Dockerfile index 87e88b1..5a47801 100644 --- a/stable/apache/Dockerfile +++ b/stable/apache/Dockerfile @@ -115,11 +115,9 @@ RUN set -ex; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ rm friendica_addons.tar.gz; -COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ COPY *.sh / RUN chmod +x /*.sh -RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] CMD ["apache2-foreground"] diff --git a/stable/apache/bin/friendica b/stable/apache/bin/friendica deleted file mode 100644 index 66233c1..0000000 --- a/stable/apache/bin/friendica +++ /dev/null @@ -1,172 +0,0 @@ -#!/bin/sh -set -eu - -FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} -FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} -AUTOINSTALL=${AUTOINSTALL:-false} - -SOURCEDIR=/usr/src -WORKDIR=/var/www/html - -# run an command with the www-data user -run_as() { - if [ "$(id -u)" = 0 ]; then - su - www-data -s /bin/sh -c "$1" - else - sh -c "$1" - fi -} - -# checks if the the first parameter is greater than the second parameter -version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] -} - -# clones the whole develop branch (Friendica and Addons) -clone_develop() { - dir="${1:-$SOURCEDIR}" - friendica="${2:-$FRIENDICA_VERSION}" - addons="${3:-$FRIENDICA_ADDONS}" - - echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" - - # Removing the whole directory first - rm -fr ${dir}/friendica - - git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica - chmod 777 ${dir}/friendica/view/smarty3 - mkdir ${dir}/friendica/addon - git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon -} - -# help of this shell script -friendica_help() { - echo "Usage: friendica []" - echo "" - echo "Commands:" - echo " console Executes an command in the Friendica console" - echo " composer Executes the composer.phar executable for Friendica" - echo " install Installs Friendica" - echo " update Updates Friendica" - return -} - -# executes the Friendica console -console() { - cd ${WORKDIR} - # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - php "${WORKDIR}/bin/console.php" $@ -} - -# executes the composer.phar binary of Friendica -composer() { - if [ -f ${WORKDIR}/bin/composer.phar ]; then - run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}" - fi -} - -copy_sources() { - installed_version="0.0.0.0" - if [ -f ${WORKDIR}/VERSION ]; then - installed_version="$(cat ${WORKDIR}/VERSION)" - fi - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - clone_develop - fi - - image_version="0.0.0.0" - if [ -f ${SOURCEDIR}/friendica/VERSION ]; then - image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" - else - # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because of no version found" - return; - fi - - if version_greater "$installed_version" "$image_version"; then - echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - return; - fi - - if version_greater "$image_version" "$installed_version"; then - if [ "$(id -u)" = 0 ]; then - rsync_options="-rlDog --chown www-data:root" - else - rsync_options="-rlD" - fi - - echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'" - rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ - fi -} - -# install Friendica -install() { - if [ -f ${WORKDIR}/VERSION ]; then - # If there is a given installation of Friendica and we should not update it => exit - # We have to explicit update Friendica to avoid breaking something - return - fi - - copy_sources - - echo "Installing Friendica" - if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "install" - fi - - if [ ! -f ${WORKDIR}/.htconfig.php ] && - [ -f ${SOURCEDIR}/config/htconfig.php ] && - "$AUTOINSTALL" == "true"; then - run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" - # TODO Pull Request for dba Change - run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" - console "autoinstall -f .htconfig.php" - # TODO Workaround because of a strange permission issue - rm -fr ${WORKDIR}/view/smarty3/compiled - fi -} - -update() { - if [ ! -f ${WORKDIR}/VERSION ]; then - # We want to update a given installation - # if there is no installation, exit - return - fi - - copy_sources - - echo "Upgrading Friendica" - if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "install" - fi - console "dbstructure update" -} - -sendmail() { - if [ ! -f /etc/init.d/sendmail ]; then - # If sendmail isn't installed, exit this method - return - fi - - line=$(head -n 1 /etc/hosts) - line2=$(echo $line | awk '{print $2}') - echo "$line $line2.localdomain" >> /etc/hosts - - echo "Starting sendmail for Mail-Support" - /etc/init.d/sendmail start -} - -if [ $# -eq 0 ]; then - friendica_help -fi - -case "$1" in - install) shift; install "$@";; - update) shift; update "$@" ;; - console) shift; console "$@" ;; - composer) shift; composer "$@" ;; - sendmail) shift; sendmail "$@" ;; - *) friendica_help ;; -esac diff --git a/stable/apache/cron.sh b/stable/apache/cron.sh index 4dfa411..b368336 100644 --- a/stable/apache/cron.sh +++ b/stable/apache/cron.sh @@ -1,4 +1,4 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file diff --git a/stable/apache/entrypoint.sh b/stable/apache/entrypoint.sh index 1f03315..b95492b 100644 --- a/stable/apache/entrypoint.sh +++ b/stable/apache/entrypoint.sh @@ -1,8 +1,107 @@ #!/bin/sh set -eu -# Check if Friendica needs to get installed -friendica install -friendica sendmail +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} -exec "$@" +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# executes the Friendica console +console() { + cd $WORKDIR + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1 +} + +# If there is no VERSION file or the command is "update", (re-)install Friendica +if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then + + installed_version="0.0.0.0" + if [ -f $WORKDIR/VERSION ]; then + installed_version="$(cat $WORKDIR/VERSION)" + fi + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + # Removing the whole directory first + rm -fr $SOURCEDIR/friendica + + git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1 + chmod 777 $SOURCEDIR/friendica/view/smarty3 + mkdir $SOURCEDIR/friendica/addon + git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1 + fi + + image_version="0.0.0.0" + if [ -f $SOURCEDIR/friendica/VERSION ]; then + image_version="$(cat $SOURCEDIR/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + echo "Friendica command '$1' failed, because no version found" + exit 1; + fi + + if version_greater "$installed_version" "$image_version"; then + echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + + rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + if [ ! -f ${WORKDIR}/bin/composer.phar ]; then + echo "no composer found" + exit 1 + fi + + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1 + fi + + if [ ! -f $WORKDIR/.htconfig.php ] && + [ -f $SOURCEDIR/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr $WORKDIR/view/smarty3/compiled + elif [ "$1" = "update" ]; then + console "dbstructure update" + fi + fi +fi + +# Start sendmail if you find it +if [ -f /etc/init.d/sendmail ]; then + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + nohup /etc/init.d/sendmail start > /dev/null 2>&1 & +fi + +exec "$@" \ No newline at end of file diff --git a/stable/fpm-alpine/Dockerfile b/stable/fpm-alpine/Dockerfile index 793bc75..4cca26b 100644 --- a/stable/fpm-alpine/Dockerfile +++ b/stable/fpm-alpine/Dockerfile @@ -93,11 +93,9 @@ RUN set -ex; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ rm friendica_addons.tar.gz; -COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ COPY *.sh / RUN chmod +x /*.sh -RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] \ No newline at end of file diff --git a/stable/fpm-alpine/bin/friendica b/stable/fpm-alpine/bin/friendica deleted file mode 100644 index 66233c1..0000000 --- a/stable/fpm-alpine/bin/friendica +++ /dev/null @@ -1,172 +0,0 @@ -#!/bin/sh -set -eu - -FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} -FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} -AUTOINSTALL=${AUTOINSTALL:-false} - -SOURCEDIR=/usr/src -WORKDIR=/var/www/html - -# run an command with the www-data user -run_as() { - if [ "$(id -u)" = 0 ]; then - su - www-data -s /bin/sh -c "$1" - else - sh -c "$1" - fi -} - -# checks if the the first parameter is greater than the second parameter -version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] -} - -# clones the whole develop branch (Friendica and Addons) -clone_develop() { - dir="${1:-$SOURCEDIR}" - friendica="${2:-$FRIENDICA_VERSION}" - addons="${3:-$FRIENDICA_ADDONS}" - - echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" - - # Removing the whole directory first - rm -fr ${dir}/friendica - - git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica - chmod 777 ${dir}/friendica/view/smarty3 - mkdir ${dir}/friendica/addon - git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon -} - -# help of this shell script -friendica_help() { - echo "Usage: friendica []" - echo "" - echo "Commands:" - echo " console Executes an command in the Friendica console" - echo " composer Executes the composer.phar executable for Friendica" - echo " install Installs Friendica" - echo " update Updates Friendica" - return -} - -# executes the Friendica console -console() { - cd ${WORKDIR} - # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - php "${WORKDIR}/bin/console.php" $@ -} - -# executes the composer.phar binary of Friendica -composer() { - if [ -f ${WORKDIR}/bin/composer.phar ]; then - run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}" - fi -} - -copy_sources() { - installed_version="0.0.0.0" - if [ -f ${WORKDIR}/VERSION ]; then - installed_version="$(cat ${WORKDIR}/VERSION)" - fi - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - clone_develop - fi - - image_version="0.0.0.0" - if [ -f ${SOURCEDIR}/friendica/VERSION ]; then - image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" - else - # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because of no version found" - return; - fi - - if version_greater "$installed_version" "$image_version"; then - echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - return; - fi - - if version_greater "$image_version" "$installed_version"; then - if [ "$(id -u)" = 0 ]; then - rsync_options="-rlDog --chown www-data:root" - else - rsync_options="-rlD" - fi - - echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'" - rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ - fi -} - -# install Friendica -install() { - if [ -f ${WORKDIR}/VERSION ]; then - # If there is a given installation of Friendica and we should not update it => exit - # We have to explicit update Friendica to avoid breaking something - return - fi - - copy_sources - - echo "Installing Friendica" - if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "install" - fi - - if [ ! -f ${WORKDIR}/.htconfig.php ] && - [ -f ${SOURCEDIR}/config/htconfig.php ] && - "$AUTOINSTALL" == "true"; then - run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" - # TODO Pull Request for dba Change - run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" - console "autoinstall -f .htconfig.php" - # TODO Workaround because of a strange permission issue - rm -fr ${WORKDIR}/view/smarty3/compiled - fi -} - -update() { - if [ ! -f ${WORKDIR}/VERSION ]; then - # We want to update a given installation - # if there is no installation, exit - return - fi - - copy_sources - - echo "Upgrading Friendica" - if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "install" - fi - console "dbstructure update" -} - -sendmail() { - if [ ! -f /etc/init.d/sendmail ]; then - # If sendmail isn't installed, exit this method - return - fi - - line=$(head -n 1 /etc/hosts) - line2=$(echo $line | awk '{print $2}') - echo "$line $line2.localdomain" >> /etc/hosts - - echo "Starting sendmail for Mail-Support" - /etc/init.d/sendmail start -} - -if [ $# -eq 0 ]; then - friendica_help -fi - -case "$1" in - install) shift; install "$@";; - update) shift; update "$@" ;; - console) shift; console "$@" ;; - composer) shift; composer "$@" ;; - sendmail) shift; sendmail "$@" ;; - *) friendica_help ;; -esac diff --git a/stable/fpm-alpine/cron.sh b/stable/fpm-alpine/cron.sh index 4dfa411..b368336 100644 --- a/stable/fpm-alpine/cron.sh +++ b/stable/fpm-alpine/cron.sh @@ -1,4 +1,4 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file diff --git a/stable/fpm-alpine/entrypoint.sh b/stable/fpm-alpine/entrypoint.sh index 1f03315..b95492b 100644 --- a/stable/fpm-alpine/entrypoint.sh +++ b/stable/fpm-alpine/entrypoint.sh @@ -1,8 +1,107 @@ #!/bin/sh set -eu -# Check if Friendica needs to get installed -friendica install -friendica sendmail +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} -exec "$@" +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# executes the Friendica console +console() { + cd $WORKDIR + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1 +} + +# If there is no VERSION file or the command is "update", (re-)install Friendica +if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then + + installed_version="0.0.0.0" + if [ -f $WORKDIR/VERSION ]; then + installed_version="$(cat $WORKDIR/VERSION)" + fi + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + # Removing the whole directory first + rm -fr $SOURCEDIR/friendica + + git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1 + chmod 777 $SOURCEDIR/friendica/view/smarty3 + mkdir $SOURCEDIR/friendica/addon + git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1 + fi + + image_version="0.0.0.0" + if [ -f $SOURCEDIR/friendica/VERSION ]; then + image_version="$(cat $SOURCEDIR/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + echo "Friendica command '$1' failed, because no version found" + exit 1; + fi + + if version_greater "$installed_version" "$image_version"; then + echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + + rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + if [ ! -f ${WORKDIR}/bin/composer.phar ]; then + echo "no composer found" + exit 1 + fi + + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1 + fi + + if [ ! -f $WORKDIR/.htconfig.php ] && + [ -f $SOURCEDIR/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr $WORKDIR/view/smarty3/compiled + elif [ "$1" = "update" ]; then + console "dbstructure update" + fi + fi +fi + +# Start sendmail if you find it +if [ -f /etc/init.d/sendmail ]; then + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + nohup /etc/init.d/sendmail start > /dev/null 2>&1 & +fi + +exec "$@" \ No newline at end of file diff --git a/stable/fpm/Dockerfile b/stable/fpm/Dockerfile index b99361a..f01f770 100644 --- a/stable/fpm/Dockerfile +++ b/stable/fpm/Dockerfile @@ -106,11 +106,9 @@ RUN set -ex; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ rm friendica_addons.tar.gz; -COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ COPY *.sh / RUN chmod +x /*.sh -RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] diff --git a/stable/fpm/bin/friendica b/stable/fpm/bin/friendica deleted file mode 100644 index 66233c1..0000000 --- a/stable/fpm/bin/friendica +++ /dev/null @@ -1,172 +0,0 @@ -#!/bin/sh -set -eu - -FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} -FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} -AUTOINSTALL=${AUTOINSTALL:-false} - -SOURCEDIR=/usr/src -WORKDIR=/var/www/html - -# run an command with the www-data user -run_as() { - if [ "$(id -u)" = 0 ]; then - su - www-data -s /bin/sh -c "$1" - else - sh -c "$1" - fi -} - -# checks if the the first parameter is greater than the second parameter -version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] -} - -# clones the whole develop branch (Friendica and Addons) -clone_develop() { - dir="${1:-$SOURCEDIR}" - friendica="${2:-$FRIENDICA_VERSION}" - addons="${3:-$FRIENDICA_ADDONS}" - - echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'" - - # Removing the whole directory first - rm -fr ${dir}/friendica - - git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica - chmod 777 ${dir}/friendica/view/smarty3 - mkdir ${dir}/friendica/addon - git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon -} - -# help of this shell script -friendica_help() { - echo "Usage: friendica []" - echo "" - echo "Commands:" - echo " console Executes an command in the Friendica console" - echo " composer Executes the composer.phar executable for Friendica" - echo " install Installs Friendica" - echo " update Updates Friendica" - return -} - -# executes the Friendica console -console() { - cd ${WORKDIR} - # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - php "${WORKDIR}/bin/console.php" $@ -} - -# executes the composer.phar binary of Friendica -composer() { - if [ -f ${WORKDIR}/bin/composer.phar ]; then - run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}" - fi -} - -copy_sources() { - installed_version="0.0.0.0" - if [ -f ${WORKDIR}/VERSION ]; then - installed_version="$(cat ${WORKDIR}/VERSION)" - fi - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - clone_develop - fi - - image_version="0.0.0.0" - if [ -f ${SOURCEDIR}/friendica/VERSION ]; then - image_version="$(cat ${SOURCEDIR}/friendica/VERSION)" - else - # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because of no version found" - return; - fi - - if version_greater "$installed_version" "$image_version"; then - echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - return; - fi - - if version_greater "$image_version" "$installed_version"; then - if [ "$(id -u)" = 0 ]; then - rsync_options="-rlDog --chown www-data:root" - else - rsync_options="-rlD" - fi - - echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'" - rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ - fi -} - -# install Friendica -install() { - if [ -f ${WORKDIR}/VERSION ]; then - # If there is a given installation of Friendica and we should not update it => exit - # We have to explicit update Friendica to avoid breaking something - return - fi - - copy_sources - - echo "Installing Friendica" - if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "install" - fi - - if [ ! -f ${WORKDIR}/.htconfig.php ] && - [ -f ${SOURCEDIR}/config/htconfig.php ] && - "$AUTOINSTALL" == "true"; then - run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" - # TODO Pull Request for dba Change - run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" - console "autoinstall -f .htconfig.php" - # TODO Workaround because of a strange permission issue - rm -fr ${WORKDIR}/view/smarty3/compiled - fi -} - -update() { - if [ ! -f ${WORKDIR}/VERSION ]; then - # We want to update a given installation - # if there is no installation, exit - return - fi - - copy_sources - - echo "Upgrading Friendica" - if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "install" - fi - console "dbstructure update" -} - -sendmail() { - if [ ! -f /etc/init.d/sendmail ]; then - # If sendmail isn't installed, exit this method - return - fi - - line=$(head -n 1 /etc/hosts) - line2=$(echo $line | awk '{print $2}') - echo "$line $line2.localdomain" >> /etc/hosts - - echo "Starting sendmail for Mail-Support" - /etc/init.d/sendmail start -} - -if [ $# -eq 0 ]; then - friendica_help -fi - -case "$1" in - install) shift; install "$@";; - update) shift; update "$@" ;; - console) shift; console "$@" ;; - composer) shift; composer "$@" ;; - sendmail) shift; sendmail "$@" ;; - *) friendica_help ;; -esac diff --git a/stable/fpm/cron.sh b/stable/fpm/cron.sh index 4dfa411..b368336 100644 --- a/stable/fpm/cron.sh +++ b/stable/fpm/cron.sh @@ -1,4 +1,4 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file diff --git a/stable/fpm/entrypoint.sh b/stable/fpm/entrypoint.sh index 1f03315..b95492b 100644 --- a/stable/fpm/entrypoint.sh +++ b/stable/fpm/entrypoint.sh @@ -1,8 +1,107 @@ #!/bin/sh set -eu -# Check if Friendica needs to get installed -friendica install -friendica sendmail +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} -exec "$@" +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# executes the Friendica console +console() { + cd $WORKDIR + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1 +} + +# If there is no VERSION file or the command is "update", (re-)install Friendica +if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then + + installed_version="0.0.0.0" + if [ -f $WORKDIR/VERSION ]; then + installed_version="$(cat $WORKDIR/VERSION)" + fi + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + # Removing the whole directory first + rm -fr $SOURCEDIR/friendica + + git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1 + chmod 777 $SOURCEDIR/friendica/view/smarty3 + mkdir $SOURCEDIR/friendica/addon + git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1 + fi + + image_version="0.0.0.0" + if [ -f $SOURCEDIR/friendica/VERSION ]; then + image_version="$(cat $SOURCEDIR/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + echo "Friendica command '$1' failed, because no version found" + exit 1; + fi + + if version_greater "$installed_version" "$image_version"; then + echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + + rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + if [ ! -f ${WORKDIR}/bin/composer.phar ]; then + echo "no composer found" + exit 1 + fi + + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1 + fi + + if [ ! -f $WORKDIR/.htconfig.php ] && + [ -f $SOURCEDIR/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr $WORKDIR/view/smarty3/compiled + elif [ "$1" = "update" ]; then + console "dbstructure update" + fi + fi +fi + +# Start sendmail if you find it +if [ -f /etc/init.d/sendmail ]; then + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + nohup /etc/init.d/sendmail start > /dev/null 2>&1 & +fi + +exec "$@" \ No newline at end of file From f3b3fe5e3924b31acab5e81050ba1d3041093bc5 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 20 May 2018 22:07:54 +0200 Subject: [PATCH 13/16] Fixing travis tests - Fixing `git clone` at develop-branch to pipe the output to /dev/null --- develop/apache/entrypoint.sh | 4 ++-- develop/fpm-alpine/entrypoint.sh | 4 ++-- develop/fpm/entrypoint.sh | 4 ++-- stable/apache/entrypoint.sh | 4 ++-- stable/fpm-alpine/entrypoint.sh | 4 ++-- stable/fpm/entrypoint.sh | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/develop/apache/entrypoint.sh b/develop/apache/entrypoint.sh index b95492b..fc1504d 100644 --- a/develop/apache/entrypoint.sh +++ b/develop/apache/entrypoint.sh @@ -41,10 +41,10 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # Removing the whole directory first rm -fr $SOURCEDIR/friendica - git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" > /dev/null 2&>1 chmod 777 $SOURCEDIR/friendica/view/smarty3 mkdir $SOURCEDIR/friendica/addon - git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" > /dev/null 2&>1 fi image_version="0.0.0.0" diff --git a/develop/fpm-alpine/entrypoint.sh b/develop/fpm-alpine/entrypoint.sh index b95492b..fc1504d 100644 --- a/develop/fpm-alpine/entrypoint.sh +++ b/develop/fpm-alpine/entrypoint.sh @@ -41,10 +41,10 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # Removing the whole directory first rm -fr $SOURCEDIR/friendica - git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" > /dev/null 2&>1 chmod 777 $SOURCEDIR/friendica/view/smarty3 mkdir $SOURCEDIR/friendica/addon - git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" > /dev/null 2&>1 fi image_version="0.0.0.0" diff --git a/develop/fpm/entrypoint.sh b/develop/fpm/entrypoint.sh index b95492b..fc1504d 100644 --- a/develop/fpm/entrypoint.sh +++ b/develop/fpm/entrypoint.sh @@ -41,10 +41,10 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # Removing the whole directory first rm -fr $SOURCEDIR/friendica - git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" > /dev/null 2&>1 chmod 777 $SOURCEDIR/friendica/view/smarty3 mkdir $SOURCEDIR/friendica/addon - git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" > /dev/null 2&>1 fi image_version="0.0.0.0" diff --git a/stable/apache/entrypoint.sh b/stable/apache/entrypoint.sh index b95492b..fc1504d 100644 --- a/stable/apache/entrypoint.sh +++ b/stable/apache/entrypoint.sh @@ -41,10 +41,10 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # Removing the whole directory first rm -fr $SOURCEDIR/friendica - git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" > /dev/null 2&>1 chmod 777 $SOURCEDIR/friendica/view/smarty3 mkdir $SOURCEDIR/friendica/addon - git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" > /dev/null 2&>1 fi image_version="0.0.0.0" diff --git a/stable/fpm-alpine/entrypoint.sh b/stable/fpm-alpine/entrypoint.sh index b95492b..fc1504d 100644 --- a/stable/fpm-alpine/entrypoint.sh +++ b/stable/fpm-alpine/entrypoint.sh @@ -41,10 +41,10 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # Removing the whole directory first rm -fr $SOURCEDIR/friendica - git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" > /dev/null 2&>1 chmod 777 $SOURCEDIR/friendica/view/smarty3 mkdir $SOURCEDIR/friendica/addon - git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" > /dev/null 2&>1 fi image_version="0.0.0.0" diff --git a/stable/fpm/entrypoint.sh b/stable/fpm/entrypoint.sh index b95492b..fc1504d 100644 --- a/stable/fpm/entrypoint.sh +++ b/stable/fpm/entrypoint.sh @@ -41,10 +41,10 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # Removing the whole directory first rm -fr $SOURCEDIR/friendica - git clone --quiet -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" > /dev/null 2&>1 chmod 777 $SOURCEDIR/friendica/view/smarty3 mkdir $SOURCEDIR/friendica/addon - git clone --quiet -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" > /dev/null 2&>1 fi image_version="0.0.0.0" From 22a3d48c9ff7a0e249a808001cae0e19a7c9b193 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 20 May 2018 22:13:05 +0200 Subject: [PATCH 14/16] Fixing update - "exit 0" when explicit updating Friendica --- develop/apache/entrypoint.sh | 3 +++ develop/fpm-alpine/entrypoint.sh | 3 +++ develop/fpm/entrypoint.sh | 3 +++ stable/apache/entrypoint.sh | 3 +++ stable/fpm-alpine/entrypoint.sh | 3 +++ stable/fpm/entrypoint.sh | 3 +++ 6 files changed, 18 insertions(+) diff --git a/develop/apache/entrypoint.sh b/develop/apache/entrypoint.sh index fc1504d..2d8582d 100644 --- a/develop/apache/entrypoint.sh +++ b/develop/apache/entrypoint.sh @@ -89,7 +89,10 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # TODO Workaround because of a strange permission issue rm -fr $WORKDIR/view/smarty3/compiled elif [ "$1" = "update" ]; then + echo "Updating Friendica" console "dbstructure update" + + exit 0 fi fi fi diff --git a/develop/fpm-alpine/entrypoint.sh b/develop/fpm-alpine/entrypoint.sh index fc1504d..2d8582d 100644 --- a/develop/fpm-alpine/entrypoint.sh +++ b/develop/fpm-alpine/entrypoint.sh @@ -89,7 +89,10 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # TODO Workaround because of a strange permission issue rm -fr $WORKDIR/view/smarty3/compiled elif [ "$1" = "update" ]; then + echo "Updating Friendica" console "dbstructure update" + + exit 0 fi fi fi diff --git a/develop/fpm/entrypoint.sh b/develop/fpm/entrypoint.sh index fc1504d..2d8582d 100644 --- a/develop/fpm/entrypoint.sh +++ b/develop/fpm/entrypoint.sh @@ -89,7 +89,10 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # TODO Workaround because of a strange permission issue rm -fr $WORKDIR/view/smarty3/compiled elif [ "$1" = "update" ]; then + echo "Updating Friendica" console "dbstructure update" + + exit 0 fi fi fi diff --git a/stable/apache/entrypoint.sh b/stable/apache/entrypoint.sh index fc1504d..2d8582d 100644 --- a/stable/apache/entrypoint.sh +++ b/stable/apache/entrypoint.sh @@ -89,7 +89,10 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # TODO Workaround because of a strange permission issue rm -fr $WORKDIR/view/smarty3/compiled elif [ "$1" = "update" ]; then + echo "Updating Friendica" console "dbstructure update" + + exit 0 fi fi fi diff --git a/stable/fpm-alpine/entrypoint.sh b/stable/fpm-alpine/entrypoint.sh index fc1504d..2d8582d 100644 --- a/stable/fpm-alpine/entrypoint.sh +++ b/stable/fpm-alpine/entrypoint.sh @@ -89,7 +89,10 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # TODO Workaround because of a strange permission issue rm -fr $WORKDIR/view/smarty3/compiled elif [ "$1" = "update" ]; then + echo "Updating Friendica" console "dbstructure update" + + exit 0 fi fi fi diff --git a/stable/fpm/entrypoint.sh b/stable/fpm/entrypoint.sh index fc1504d..2d8582d 100644 --- a/stable/fpm/entrypoint.sh +++ b/stable/fpm/entrypoint.sh @@ -89,7 +89,10 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # TODO Workaround because of a strange permission issue rm -fr $WORKDIR/view/smarty3/compiled elif [ "$1" = "update" ]; then + echo "Updating Friendica" console "dbstructure update" + + exit 0 fi fi fi From ce49a5994bf217efd5eda16f686d5b571625441a Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 20 May 2018 22:33:29 +0200 Subject: [PATCH 15/16] Fixing travis tests - Fixing output verbosity --- develop/apache/entrypoint.sh | 15 +++++++-------- develop/fpm-alpine/entrypoint.sh | 15 +++++++-------- develop/fpm/entrypoint.sh | 15 +++++++-------- stable/apache/entrypoint.sh | 15 +++++++-------- stable/fpm-alpine/entrypoint.sh | 15 +++++++-------- stable/fpm/entrypoint.sh | 15 +++++++-------- 6 files changed, 42 insertions(+), 48 deletions(-) diff --git a/develop/apache/entrypoint.sh b/develop/apache/entrypoint.sh index 2d8582d..d1c9eb2 100644 --- a/develop/apache/entrypoint.sh +++ b/develop/apache/entrypoint.sh @@ -26,7 +26,7 @@ version_greater() { console() { cd $WORKDIR # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1 + sh -c "php $WORKDIR/bin/console.php $@" } # If there is no VERSION file or the command is "update", (re-)install Friendica @@ -41,10 +41,12 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # Removing the whole directory first rm -fr $SOURCEDIR/friendica - sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" > /dev/null 2&>1 - chmod 777 $SOURCEDIR/friendica/view/smarty3 + sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" + if [ -f $SOURCEDIR/friendica/view/smarty3 ]; then + chmod 777 $SOURCEDIR/friendica/view/smarty3 + fi mkdir $SOURCEDIR/friendica/addon - sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" fi image_version="0.0.0.0" @@ -76,7 +78,7 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then exit 1 fi - run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1 + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" fi if [ ! -f $WORKDIR/.htconfig.php ] && @@ -89,10 +91,7 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # TODO Workaround because of a strange permission issue rm -fr $WORKDIR/view/smarty3/compiled elif [ "$1" = "update" ]; then - echo "Updating Friendica" console "dbstructure update" - - exit 0 fi fi fi diff --git a/develop/fpm-alpine/entrypoint.sh b/develop/fpm-alpine/entrypoint.sh index 2d8582d..d1c9eb2 100644 --- a/develop/fpm-alpine/entrypoint.sh +++ b/develop/fpm-alpine/entrypoint.sh @@ -26,7 +26,7 @@ version_greater() { console() { cd $WORKDIR # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1 + sh -c "php $WORKDIR/bin/console.php $@" } # If there is no VERSION file or the command is "update", (re-)install Friendica @@ -41,10 +41,12 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # Removing the whole directory first rm -fr $SOURCEDIR/friendica - sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" > /dev/null 2&>1 - chmod 777 $SOURCEDIR/friendica/view/smarty3 + sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" + if [ -f $SOURCEDIR/friendica/view/smarty3 ]; then + chmod 777 $SOURCEDIR/friendica/view/smarty3 + fi mkdir $SOURCEDIR/friendica/addon - sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" fi image_version="0.0.0.0" @@ -76,7 +78,7 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then exit 1 fi - run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1 + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" fi if [ ! -f $WORKDIR/.htconfig.php ] && @@ -89,10 +91,7 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # TODO Workaround because of a strange permission issue rm -fr $WORKDIR/view/smarty3/compiled elif [ "$1" = "update" ]; then - echo "Updating Friendica" console "dbstructure update" - - exit 0 fi fi fi diff --git a/develop/fpm/entrypoint.sh b/develop/fpm/entrypoint.sh index 2d8582d..d1c9eb2 100644 --- a/develop/fpm/entrypoint.sh +++ b/develop/fpm/entrypoint.sh @@ -26,7 +26,7 @@ version_greater() { console() { cd $WORKDIR # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1 + sh -c "php $WORKDIR/bin/console.php $@" } # If there is no VERSION file or the command is "update", (re-)install Friendica @@ -41,10 +41,12 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # Removing the whole directory first rm -fr $SOURCEDIR/friendica - sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" > /dev/null 2&>1 - chmod 777 $SOURCEDIR/friendica/view/smarty3 + sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" + if [ -f $SOURCEDIR/friendica/view/smarty3 ]; then + chmod 777 $SOURCEDIR/friendica/view/smarty3 + fi mkdir $SOURCEDIR/friendica/addon - sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" fi image_version="0.0.0.0" @@ -76,7 +78,7 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then exit 1 fi - run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1 + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" fi if [ ! -f $WORKDIR/.htconfig.php ] && @@ -89,10 +91,7 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # TODO Workaround because of a strange permission issue rm -fr $WORKDIR/view/smarty3/compiled elif [ "$1" = "update" ]; then - echo "Updating Friendica" console "dbstructure update" - - exit 0 fi fi fi diff --git a/stable/apache/entrypoint.sh b/stable/apache/entrypoint.sh index 2d8582d..d1c9eb2 100644 --- a/stable/apache/entrypoint.sh +++ b/stable/apache/entrypoint.sh @@ -26,7 +26,7 @@ version_greater() { console() { cd $WORKDIR # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1 + sh -c "php $WORKDIR/bin/console.php $@" } # If there is no VERSION file or the command is "update", (re-)install Friendica @@ -41,10 +41,12 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # Removing the whole directory first rm -fr $SOURCEDIR/friendica - sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" > /dev/null 2&>1 - chmod 777 $SOURCEDIR/friendica/view/smarty3 + sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" + if [ -f $SOURCEDIR/friendica/view/smarty3 ]; then + chmod 777 $SOURCEDIR/friendica/view/smarty3 + fi mkdir $SOURCEDIR/friendica/addon - sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" fi image_version="0.0.0.0" @@ -76,7 +78,7 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then exit 1 fi - run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1 + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" fi if [ ! -f $WORKDIR/.htconfig.php ] && @@ -89,10 +91,7 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # TODO Workaround because of a strange permission issue rm -fr $WORKDIR/view/smarty3/compiled elif [ "$1" = "update" ]; then - echo "Updating Friendica" console "dbstructure update" - - exit 0 fi fi fi diff --git a/stable/fpm-alpine/entrypoint.sh b/stable/fpm-alpine/entrypoint.sh index 2d8582d..d1c9eb2 100644 --- a/stable/fpm-alpine/entrypoint.sh +++ b/stable/fpm-alpine/entrypoint.sh @@ -26,7 +26,7 @@ version_greater() { console() { cd $WORKDIR # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1 + sh -c "php $WORKDIR/bin/console.php $@" } # If there is no VERSION file or the command is "update", (re-)install Friendica @@ -41,10 +41,12 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # Removing the whole directory first rm -fr $SOURCEDIR/friendica - sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" > /dev/null 2&>1 - chmod 777 $SOURCEDIR/friendica/view/smarty3 + sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" + if [ -f $SOURCEDIR/friendica/view/smarty3 ]; then + chmod 777 $SOURCEDIR/friendica/view/smarty3 + fi mkdir $SOURCEDIR/friendica/addon - sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" fi image_version="0.0.0.0" @@ -76,7 +78,7 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then exit 1 fi - run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1 + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" fi if [ ! -f $WORKDIR/.htconfig.php ] && @@ -89,10 +91,7 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # TODO Workaround because of a strange permission issue rm -fr $WORKDIR/view/smarty3/compiled elif [ "$1" = "update" ]; then - echo "Updating Friendica" console "dbstructure update" - - exit 0 fi fi fi diff --git a/stable/fpm/entrypoint.sh b/stable/fpm/entrypoint.sh index 2d8582d..d1c9eb2 100644 --- a/stable/fpm/entrypoint.sh +++ b/stable/fpm/entrypoint.sh @@ -26,7 +26,7 @@ version_greater() { console() { cd $WORKDIR # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - sh -c "php $WORKDIR/bin/console.php $@" > /dev/null 2&>1 + sh -c "php $WORKDIR/bin/console.php $@" } # If there is no VERSION file or the command is "update", (re-)install Friendica @@ -41,10 +41,12 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # Removing the whole directory first rm -fr $SOURCEDIR/friendica - sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" > /dev/null 2&>1 - chmod 777 $SOURCEDIR/friendica/view/smarty3 + sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" + if [ -f $SOURCEDIR/friendica/view/smarty3 ]; then + chmod 777 $SOURCEDIR/friendica/view/smarty3 + fi mkdir $SOURCEDIR/friendica/addon - sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" > /dev/null 2&>1 + sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" fi image_version="0.0.0.0" @@ -76,7 +78,7 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then exit 1 fi - run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" > /dev/null 2&>1 + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" fi if [ ! -f $WORKDIR/.htconfig.php ] && @@ -89,10 +91,7 @@ if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then # TODO Workaround because of a strange permission issue rm -fr $WORKDIR/view/smarty3/compiled elif [ "$1" = "update" ]; then - echo "Updating Friendica" console "dbstructure update" - - exit 0 fi fi fi From 1362cc34ca68511387223ff0b9ec8c4a1a1fa564 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Mon, 21 May 2018 21:32:26 +0200 Subject: [PATCH 16/16] Fixed cron.sh & update - restored script `friendica` for update & wrapper purpose - fixed `cron.sh` --- README.md | 21 ++- develop/apache/Dockerfile | 8 +- develop/apache/bin/friendica | 212 +++++++++++++++++++++++++++++++ develop/apache/cron.sh | 12 +- develop/apache/entrypoint.sh | 106 +--------------- develop/fpm-alpine/Dockerfile | 8 +- develop/fpm-alpine/bin/friendica | 212 +++++++++++++++++++++++++++++++ develop/fpm-alpine/cron.sh | 12 +- develop/fpm-alpine/entrypoint.sh | 106 +--------------- develop/fpm/Dockerfile | 8 +- develop/fpm/bin/friendica | 212 +++++++++++++++++++++++++++++++ develop/fpm/cron.sh | 12 +- develop/fpm/entrypoint.sh | 106 +--------------- stable/apache/Dockerfile | 8 +- stable/apache/bin/friendica | 212 +++++++++++++++++++++++++++++++ stable/apache/cron.sh | 12 +- stable/apache/entrypoint.sh | 106 +--------------- stable/fpm-alpine/Dockerfile | 8 +- stable/fpm-alpine/bin/friendica | 212 +++++++++++++++++++++++++++++++ stable/fpm-alpine/cron.sh | 12 +- stable/fpm-alpine/entrypoint.sh | 106 +--------------- stable/fpm/Dockerfile | 8 +- stable/fpm/bin/friendica | 212 +++++++++++++++++++++++++++++++ stable/fpm/cron.sh | 12 +- stable/fpm/entrypoint.sh | 106 +--------------- 25 files changed, 1387 insertions(+), 662 deletions(-) create mode 100644 develop/apache/bin/friendica create mode 100644 develop/fpm-alpine/bin/friendica create mode 100644 develop/fpm/bin/friendica create mode 100644 stable/apache/bin/friendica create mode 100644 stable/fpm-alpine/bin/friendica create mode 100644 stable/fpm/bin/friendica diff --git a/README.md b/README.md index 48669d3..9102c1a 100644 --- a/README.md +++ b/README.md @@ -130,12 +130,29 @@ You have to pull the latest image from the hub (`docker pull friendica`). ## Updating develop You don't need to pull the image for each commit in [friendica](https://github.com/friendica/friendica/). -Instead you can just update your node with executing `update` on the node. +Instead you can just update your node with executing `friendica update` on the node. Example: ```console -$ docker exec -ti friendica_running_node update +$ docker exec -ti friendica_running_node friendica update ``` It will clone the latest Friendica version and copy it to your working directory. +# The `friendica` CLI + +To make the usage of the Dockerimages smooth, we created a little CLI. +It wraps the common commands for Friendica and adds new commands. + +You can call it with +```console +$ docker exec -ti friendica_running_node friendica \ +``` + +Commands: +- `console` Executes an command in the Friendica console (`bin/console.php` wrapper) +- `composer` Executes the composer.phar executable for Friendica (`bin/composer.phar` wrapper) +- `install` Installs Friendica on a empty environment (gets called automatically during first start) +- `update` Updates Friendica on a **existing** environment + + # Questions / Issues If you got any questions or problems using the image, please visit our [Github Repository](https://github.com/friendica/docker) and write an issue. \ No newline at end of file diff --git a/develop/apache/Dockerfile b/develop/apache/Dockerfile index ac9de19..e76f2db 100644 --- a/develop/apache/Dockerfile +++ b/develop/apache/Dockerfile @@ -11,15 +11,11 @@ RUN set -ex; \ apt-get install -y --no-install-recommends \ rsync \ bzip2 \ - busybox-static \ git \ # For mail() support sendmail \ ; \ - rm -rf /var/lib/apt/lists/*; \ - \ - mkdir -p /var/spool/cron/crontabs; \ - echo '*/10 * * * * cd /var/www/html && php -f bin/worker.php' > /var/spool/cron/crontabs/www-data + rm -rf /var/lib/apt/lists/*; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ @@ -102,9 +98,11 @@ RUN {\ ENV FRIENDICA_VERSION develop ENV ADDONS_VERSION develop +COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ COPY *.sh / RUN chmod +x /*.sh +RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] CMD ["apache2-foreground"] \ No newline at end of file diff --git a/develop/apache/bin/friendica b/develop/apache/bin/friendica new file mode 100644 index 0000000..175ed05 --- /dev/null +++ b/develop/apache/bin/friendica @@ -0,0 +1,212 @@ +#!/bin/sh +set -eu + +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} + +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# change delimiter for arrays from whitespaces to newlines (so we can pass strings with whitespaces) +#IFS=\r\n + +VERBOSE=1 +for arg; do + case "$arg" in + -q|--quit) + if [ "$VERBOSE" -eq "2" ]; then + echo 'You cannot use verbose and quiet at the same time' + exit 1 + fi + VERBOSE=0 + break + ;; + -v|--verbose) + if [ "$VERBOSE" -eq "0" ]; then + echo 'You cannot use verbose and quiet at the same time' + exit 1 + fi + VERBOSE=2 + break + ;; + esac +done + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# log event +log() { + currVerb=1 + if [ $# -eq 2 ]; then + currVerb=$2 + fi + if [ "$VERBOSE" -ge "$currVerb" ]; then + echo "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + dir="${1:-$SOURCEDIR}" + friendica="${2:-$FRIENDICA_VERSION}" + addons="${3:-$FRIENDICA_ADDONS}" + + log 'Cloning Friendica '\'$friendica\'' with Addons '\'$addons\'' into '\'$dir\' + + # Removing the whole directory first + rm -fr $dir/friendica + + sh -c "git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica" + mkdir $dir/friendica/addon + sh -c "git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon" +} + +# help of this shell script +friendica_help() { + echo "Usage: friendica []" + echo "" + echo "Commands:" + echo " console Executes an command in the Friendica console" + echo " composer Executes the composer.phar executable for Friendica" + echo " install Installs Friendica" + echo " update Updates Friendica" + exit 0 +} + +# executes the Friendica console +console() { + cd $WORKDIR + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + sh -c "php $WORKDIR/bin/console.php $@" +} + +# executes the composer.phar binary of Friendica +composer() { + if [ -f $WORKDIR/bin/composer.phar ]; then + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar $@ -d $WORKDIR" + fi +} + +copy_sources() { + installed_version="0.0.0.0" + if [ -f ${WORKDIR}/VERSION ]; then + installed_version="$(cat ${WORKDIR}/VERSION)" + fi + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + fi + + image_version="0.0.0.0" + if [ -f $SOURCEDIR/friendica/VERSION ]; then + image_version="$(cat $SOURCEDIR/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + log 'Friendica command '\'$1\'' failed, because of no version found', 0 + exit 1; + fi + + if version_greater "$installed_version" "$image_version"; then + log 'Can'\''t copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ('$image_version')', 0 + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown=www-data:root" + else + rsync_options="-rlD" + fi + + log 'Copying Friendica sources ('$image_version') from '\'$SOURCEDIR'/friendica'\'' to '\'$WORKDIR\' + rsync $rsync_options --delete --exclude='.git' $SOURCEDIR/friendica/ $WORKDIR/ + + if [ -f $WORKDIR/view/smarty3 ]; then + chmod 777 $WORKDIR/view/smarty3 + fi + fi +} + +# install Friendica +install() { + if [ -f ${WORKDIR}/VERSION ]; then + # If there is a given installation of Friendica and we should not update it => exit + # We have to explicit update Friendica to avoid breaking something + return + fi + + copy_sources + + log 'Installing Friendica' + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + + if [ ! -f ${WORKDIR}/.htconfig.php ] && + [ -f ${SOURCEDIR}/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr ${WORKDIR}/view/smarty3/compiled + fi +} + +update() { + if [ ! -f ${WORKDIR}/VERSION ]; then + # We want to update a given installation + # if there is no installation, exit + return + fi + + copy_sources + + log 'Upgrading Friendica' + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + console "dbstructure update" +} + +sendmail() { + if [ ! -f /etc/init.d/sendmail ]; then + # If sendmail isn't installed, exit this method + return + fi + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + log 'Starting sendmail for Mail-Support' + nohup /etc/init.d/sendmail start > /dev/null 2>&1 & +} + +if [ $# -eq 0 ]; then + friendica_help + exit 0 +fi + +case "$1" in + install) shift; install "$@";; + update) shift; update "$@" ;; + console) shift; console "$@" ;; + composer) shift; composer "$@" ;; + sendmail) shift; sendmail "$@" ;; + *) friendica_help ;; +esac diff --git a/develop/apache/cron.sh b/develop/apache/cron.sh index b368336..e8f064b 100644 --- a/develop/apache/cron.sh +++ b/develop/apache/cron.sh @@ -1,4 +1,14 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file +trap "break;exit" SIGHUP SIGINT SIGTERM + +while [ ! -f /var/www/html/.htconfig.php ]; do + sleep 1 +done + +while true; do + cd /var/www/html + php -f /var/www/html/bin/worker.php + sleep 10m +done \ No newline at end of file diff --git a/develop/apache/entrypoint.sh b/develop/apache/entrypoint.sh index d1c9eb2..4a0608c 100644 --- a/develop/apache/entrypoint.sh +++ b/develop/apache/entrypoint.sh @@ -1,109 +1,7 @@ #!/bin/sh set -eu -FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} -FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} -AUTOINSTALL=${AUTOINSTALL:-false} - -SOURCEDIR=/usr/src -WORKDIR=/var/www/html - -# run an command with the www-data user -run_as() { - if [ "$(id -u)" = 0 ]; then - su - www-data -s /bin/sh -c "$1" - else - sh -c "$1" - fi -} - -# checks if the the first parameter is greater than the second parameter -version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] -} - -# executes the Friendica console -console() { - cd $WORKDIR - # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - sh -c "php $WORKDIR/bin/console.php $@" -} - -# If there is no VERSION file or the command is "update", (re-)install Friendica -if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then - - installed_version="0.0.0.0" - if [ -f $WORKDIR/VERSION ]; then - installed_version="$(cat $WORKDIR/VERSION)" - fi - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - # Removing the whole directory first - rm -fr $SOURCEDIR/friendica - - sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" - if [ -f $SOURCEDIR/friendica/view/smarty3 ]; then - chmod 777 $SOURCEDIR/friendica/view/smarty3 - fi - mkdir $SOURCEDIR/friendica/addon - sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" - fi - - image_version="0.0.0.0" - if [ -f $SOURCEDIR/friendica/VERSION ]; then - image_version="$(cat $SOURCEDIR/friendica/VERSION)" - else - # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because no version found" - exit 1; - fi - - if version_greater "$installed_version" "$image_version"; then - echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - exit 1; - fi - - if version_greater "$image_version" "$installed_version"; then - if [ "$(id -u)" = 0 ]; then - rsync_options="-rlDog --chown www-data:root" - else - rsync_options="-rlD" - fi - - rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - if [ ! -f ${WORKDIR}/bin/composer.phar ]; then - echo "no composer found" - exit 1 - fi - - run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" - fi - - if [ ! -f $WORKDIR/.htconfig.php ] && - [ -f $SOURCEDIR/config/htconfig.php ] && - "$AUTOINSTALL" == "true"; then - run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php" - # TODO Pull Request for dba Change - run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php" - console "autoinstall -f .htconfig.php" - # TODO Workaround because of a strange permission issue - rm -fr $WORKDIR/view/smarty3/compiled - elif [ "$1" = "update" ]; then - console "dbstructure update" - fi - fi -fi - -# Start sendmail if you find it -if [ -f /etc/init.d/sendmail ]; then - - line=$(head -n 1 /etc/hosts) - line2=$(echo $line | awk '{print $2}') - echo "$line $line2.localdomain" >> /etc/hosts - - nohup /etc/init.d/sendmail start > /dev/null 2>&1 & -fi +friendica install -q +friendica sendmail -q exec "$@" \ No newline at end of file diff --git a/develop/fpm-alpine/Dockerfile b/develop/fpm-alpine/Dockerfile index 271c507..663a77a 100644 --- a/develop/fpm-alpine/Dockerfile +++ b/develop/fpm-alpine/Dockerfile @@ -9,11 +9,7 @@ RUN set -ex; \ \ apk add --no-cache \ rsync \ - git \ - ; \ - \ - rm /var/spool/cron/crontabs/root; \ - echo '*/10 * * * * cd /var/www/html && php -f bin/worker.php' > /var/spool/cron/crontabs/www-data + git; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ @@ -80,9 +76,11 @@ RUN {\ ENV FRIENDICA_VERSION develop ENV ADDONS_VERSION develop +COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ COPY *.sh / RUN chmod +x /*.sh +RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] \ No newline at end of file diff --git a/develop/fpm-alpine/bin/friendica b/develop/fpm-alpine/bin/friendica new file mode 100644 index 0000000..175ed05 --- /dev/null +++ b/develop/fpm-alpine/bin/friendica @@ -0,0 +1,212 @@ +#!/bin/sh +set -eu + +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} + +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# change delimiter for arrays from whitespaces to newlines (so we can pass strings with whitespaces) +#IFS=\r\n + +VERBOSE=1 +for arg; do + case "$arg" in + -q|--quit) + if [ "$VERBOSE" -eq "2" ]; then + echo 'You cannot use verbose and quiet at the same time' + exit 1 + fi + VERBOSE=0 + break + ;; + -v|--verbose) + if [ "$VERBOSE" -eq "0" ]; then + echo 'You cannot use verbose and quiet at the same time' + exit 1 + fi + VERBOSE=2 + break + ;; + esac +done + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# log event +log() { + currVerb=1 + if [ $# -eq 2 ]; then + currVerb=$2 + fi + if [ "$VERBOSE" -ge "$currVerb" ]; then + echo "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + dir="${1:-$SOURCEDIR}" + friendica="${2:-$FRIENDICA_VERSION}" + addons="${3:-$FRIENDICA_ADDONS}" + + log 'Cloning Friendica '\'$friendica\'' with Addons '\'$addons\'' into '\'$dir\' + + # Removing the whole directory first + rm -fr $dir/friendica + + sh -c "git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica" + mkdir $dir/friendica/addon + sh -c "git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon" +} + +# help of this shell script +friendica_help() { + echo "Usage: friendica []" + echo "" + echo "Commands:" + echo " console Executes an command in the Friendica console" + echo " composer Executes the composer.phar executable for Friendica" + echo " install Installs Friendica" + echo " update Updates Friendica" + exit 0 +} + +# executes the Friendica console +console() { + cd $WORKDIR + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + sh -c "php $WORKDIR/bin/console.php $@" +} + +# executes the composer.phar binary of Friendica +composer() { + if [ -f $WORKDIR/bin/composer.phar ]; then + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar $@ -d $WORKDIR" + fi +} + +copy_sources() { + installed_version="0.0.0.0" + if [ -f ${WORKDIR}/VERSION ]; then + installed_version="$(cat ${WORKDIR}/VERSION)" + fi + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + fi + + image_version="0.0.0.0" + if [ -f $SOURCEDIR/friendica/VERSION ]; then + image_version="$(cat $SOURCEDIR/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + log 'Friendica command '\'$1\'' failed, because of no version found', 0 + exit 1; + fi + + if version_greater "$installed_version" "$image_version"; then + log 'Can'\''t copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ('$image_version')', 0 + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown=www-data:root" + else + rsync_options="-rlD" + fi + + log 'Copying Friendica sources ('$image_version') from '\'$SOURCEDIR'/friendica'\'' to '\'$WORKDIR\' + rsync $rsync_options --delete --exclude='.git' $SOURCEDIR/friendica/ $WORKDIR/ + + if [ -f $WORKDIR/view/smarty3 ]; then + chmod 777 $WORKDIR/view/smarty3 + fi + fi +} + +# install Friendica +install() { + if [ -f ${WORKDIR}/VERSION ]; then + # If there is a given installation of Friendica and we should not update it => exit + # We have to explicit update Friendica to avoid breaking something + return + fi + + copy_sources + + log 'Installing Friendica' + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + + if [ ! -f ${WORKDIR}/.htconfig.php ] && + [ -f ${SOURCEDIR}/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr ${WORKDIR}/view/smarty3/compiled + fi +} + +update() { + if [ ! -f ${WORKDIR}/VERSION ]; then + # We want to update a given installation + # if there is no installation, exit + return + fi + + copy_sources + + log 'Upgrading Friendica' + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + console "dbstructure update" +} + +sendmail() { + if [ ! -f /etc/init.d/sendmail ]; then + # If sendmail isn't installed, exit this method + return + fi + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + log 'Starting sendmail for Mail-Support' + nohup /etc/init.d/sendmail start > /dev/null 2>&1 & +} + +if [ $# -eq 0 ]; then + friendica_help + exit 0 +fi + +case "$1" in + install) shift; install "$@";; + update) shift; update "$@" ;; + console) shift; console "$@" ;; + composer) shift; composer "$@" ;; + sendmail) shift; sendmail "$@" ;; + *) friendica_help ;; +esac diff --git a/develop/fpm-alpine/cron.sh b/develop/fpm-alpine/cron.sh index b368336..e8f064b 100644 --- a/develop/fpm-alpine/cron.sh +++ b/develop/fpm-alpine/cron.sh @@ -1,4 +1,14 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file +trap "break;exit" SIGHUP SIGINT SIGTERM + +while [ ! -f /var/www/html/.htconfig.php ]; do + sleep 1 +done + +while true; do + cd /var/www/html + php -f /var/www/html/bin/worker.php + sleep 10m +done \ No newline at end of file diff --git a/develop/fpm-alpine/entrypoint.sh b/develop/fpm-alpine/entrypoint.sh index d1c9eb2..4a0608c 100644 --- a/develop/fpm-alpine/entrypoint.sh +++ b/develop/fpm-alpine/entrypoint.sh @@ -1,109 +1,7 @@ #!/bin/sh set -eu -FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} -FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} -AUTOINSTALL=${AUTOINSTALL:-false} - -SOURCEDIR=/usr/src -WORKDIR=/var/www/html - -# run an command with the www-data user -run_as() { - if [ "$(id -u)" = 0 ]; then - su - www-data -s /bin/sh -c "$1" - else - sh -c "$1" - fi -} - -# checks if the the first parameter is greater than the second parameter -version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] -} - -# executes the Friendica console -console() { - cd $WORKDIR - # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - sh -c "php $WORKDIR/bin/console.php $@" -} - -# If there is no VERSION file or the command is "update", (re-)install Friendica -if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then - - installed_version="0.0.0.0" - if [ -f $WORKDIR/VERSION ]; then - installed_version="$(cat $WORKDIR/VERSION)" - fi - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - # Removing the whole directory first - rm -fr $SOURCEDIR/friendica - - sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" - if [ -f $SOURCEDIR/friendica/view/smarty3 ]; then - chmod 777 $SOURCEDIR/friendica/view/smarty3 - fi - mkdir $SOURCEDIR/friendica/addon - sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" - fi - - image_version="0.0.0.0" - if [ -f $SOURCEDIR/friendica/VERSION ]; then - image_version="$(cat $SOURCEDIR/friendica/VERSION)" - else - # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because no version found" - exit 1; - fi - - if version_greater "$installed_version" "$image_version"; then - echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - exit 1; - fi - - if version_greater "$image_version" "$installed_version"; then - if [ "$(id -u)" = 0 ]; then - rsync_options="-rlDog --chown www-data:root" - else - rsync_options="-rlD" - fi - - rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - if [ ! -f ${WORKDIR}/bin/composer.phar ]; then - echo "no composer found" - exit 1 - fi - - run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" - fi - - if [ ! -f $WORKDIR/.htconfig.php ] && - [ -f $SOURCEDIR/config/htconfig.php ] && - "$AUTOINSTALL" == "true"; then - run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php" - # TODO Pull Request for dba Change - run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php" - console "autoinstall -f .htconfig.php" - # TODO Workaround because of a strange permission issue - rm -fr $WORKDIR/view/smarty3/compiled - elif [ "$1" = "update" ]; then - console "dbstructure update" - fi - fi -fi - -# Start sendmail if you find it -if [ -f /etc/init.d/sendmail ]; then - - line=$(head -n 1 /etc/hosts) - line2=$(echo $line | awk '{print $2}') - echo "$line $line2.localdomain" >> /etc/hosts - - nohup /etc/init.d/sendmail start > /dev/null 2>&1 & -fi +friendica install -q +friendica sendmail -q exec "$@" \ No newline at end of file diff --git a/develop/fpm/Dockerfile b/develop/fpm/Dockerfile index 078a525..a87031e 100644 --- a/develop/fpm/Dockerfile +++ b/develop/fpm/Dockerfile @@ -11,15 +11,11 @@ RUN set -ex; \ apt-get install -y --no-install-recommends \ rsync \ bzip2 \ - busybox-static \ git \ # For mail() support sendmail \ ; \ - rm -rf /var/lib/apt/lists/*; \ - \ - mkdir -p /var/spool/cron/crontabs; \ - echo '*/10 * * * * cd /var/www/html && php -f bin/worker.php' > /var/spool/cron/crontabs/www-data + rm -rf /var/lib/apt/lists/*; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ @@ -93,9 +89,11 @@ RUN {\ ENV FRIENDICA_VERSION develop ENV ADDONS_VERSION develop +COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ COPY *.sh / RUN chmod +x /*.sh +RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] \ No newline at end of file diff --git a/develop/fpm/bin/friendica b/develop/fpm/bin/friendica new file mode 100644 index 0000000..175ed05 --- /dev/null +++ b/develop/fpm/bin/friendica @@ -0,0 +1,212 @@ +#!/bin/sh +set -eu + +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} + +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# change delimiter for arrays from whitespaces to newlines (so we can pass strings with whitespaces) +#IFS=\r\n + +VERBOSE=1 +for arg; do + case "$arg" in + -q|--quit) + if [ "$VERBOSE" -eq "2" ]; then + echo 'You cannot use verbose and quiet at the same time' + exit 1 + fi + VERBOSE=0 + break + ;; + -v|--verbose) + if [ "$VERBOSE" -eq "0" ]; then + echo 'You cannot use verbose and quiet at the same time' + exit 1 + fi + VERBOSE=2 + break + ;; + esac +done + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# log event +log() { + currVerb=1 + if [ $# -eq 2 ]; then + currVerb=$2 + fi + if [ "$VERBOSE" -ge "$currVerb" ]; then + echo "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + dir="${1:-$SOURCEDIR}" + friendica="${2:-$FRIENDICA_VERSION}" + addons="${3:-$FRIENDICA_ADDONS}" + + log 'Cloning Friendica '\'$friendica\'' with Addons '\'$addons\'' into '\'$dir\' + + # Removing the whole directory first + rm -fr $dir/friendica + + sh -c "git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica" + mkdir $dir/friendica/addon + sh -c "git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon" +} + +# help of this shell script +friendica_help() { + echo "Usage: friendica []" + echo "" + echo "Commands:" + echo " console Executes an command in the Friendica console" + echo " composer Executes the composer.phar executable for Friendica" + echo " install Installs Friendica" + echo " update Updates Friendica" + exit 0 +} + +# executes the Friendica console +console() { + cd $WORKDIR + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + sh -c "php $WORKDIR/bin/console.php $@" +} + +# executes the composer.phar binary of Friendica +composer() { + if [ -f $WORKDIR/bin/composer.phar ]; then + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar $@ -d $WORKDIR" + fi +} + +copy_sources() { + installed_version="0.0.0.0" + if [ -f ${WORKDIR}/VERSION ]; then + installed_version="$(cat ${WORKDIR}/VERSION)" + fi + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + fi + + image_version="0.0.0.0" + if [ -f $SOURCEDIR/friendica/VERSION ]; then + image_version="$(cat $SOURCEDIR/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + log 'Friendica command '\'$1\'' failed, because of no version found', 0 + exit 1; + fi + + if version_greater "$installed_version" "$image_version"; then + log 'Can'\''t copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ('$image_version')', 0 + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown=www-data:root" + else + rsync_options="-rlD" + fi + + log 'Copying Friendica sources ('$image_version') from '\'$SOURCEDIR'/friendica'\'' to '\'$WORKDIR\' + rsync $rsync_options --delete --exclude='.git' $SOURCEDIR/friendica/ $WORKDIR/ + + if [ -f $WORKDIR/view/smarty3 ]; then + chmod 777 $WORKDIR/view/smarty3 + fi + fi +} + +# install Friendica +install() { + if [ -f ${WORKDIR}/VERSION ]; then + # If there is a given installation of Friendica and we should not update it => exit + # We have to explicit update Friendica to avoid breaking something + return + fi + + copy_sources + + log 'Installing Friendica' + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + + if [ ! -f ${WORKDIR}/.htconfig.php ] && + [ -f ${SOURCEDIR}/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr ${WORKDIR}/view/smarty3/compiled + fi +} + +update() { + if [ ! -f ${WORKDIR}/VERSION ]; then + # We want to update a given installation + # if there is no installation, exit + return + fi + + copy_sources + + log 'Upgrading Friendica' + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + console "dbstructure update" +} + +sendmail() { + if [ ! -f /etc/init.d/sendmail ]; then + # If sendmail isn't installed, exit this method + return + fi + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + log 'Starting sendmail for Mail-Support' + nohup /etc/init.d/sendmail start > /dev/null 2>&1 & +} + +if [ $# -eq 0 ]; then + friendica_help + exit 0 +fi + +case "$1" in + install) shift; install "$@";; + update) shift; update "$@" ;; + console) shift; console "$@" ;; + composer) shift; composer "$@" ;; + sendmail) shift; sendmail "$@" ;; + *) friendica_help ;; +esac diff --git a/develop/fpm/cron.sh b/develop/fpm/cron.sh index b368336..e8f064b 100644 --- a/develop/fpm/cron.sh +++ b/develop/fpm/cron.sh @@ -1,4 +1,14 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file +trap "break;exit" SIGHUP SIGINT SIGTERM + +while [ ! -f /var/www/html/.htconfig.php ]; do + sleep 1 +done + +while true; do + cd /var/www/html + php -f /var/www/html/bin/worker.php + sleep 10m +done \ No newline at end of file diff --git a/develop/fpm/entrypoint.sh b/develop/fpm/entrypoint.sh index d1c9eb2..4a0608c 100644 --- a/develop/fpm/entrypoint.sh +++ b/develop/fpm/entrypoint.sh @@ -1,109 +1,7 @@ #!/bin/sh set -eu -FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} -FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} -AUTOINSTALL=${AUTOINSTALL:-false} - -SOURCEDIR=/usr/src -WORKDIR=/var/www/html - -# run an command with the www-data user -run_as() { - if [ "$(id -u)" = 0 ]; then - su - www-data -s /bin/sh -c "$1" - else - sh -c "$1" - fi -} - -# checks if the the first parameter is greater than the second parameter -version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] -} - -# executes the Friendica console -console() { - cd $WORKDIR - # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - sh -c "php $WORKDIR/bin/console.php $@" -} - -# If there is no VERSION file or the command is "update", (re-)install Friendica -if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then - - installed_version="0.0.0.0" - if [ -f $WORKDIR/VERSION ]; then - installed_version="$(cat $WORKDIR/VERSION)" - fi - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - # Removing the whole directory first - rm -fr $SOURCEDIR/friendica - - sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" - if [ -f $SOURCEDIR/friendica/view/smarty3 ]; then - chmod 777 $SOURCEDIR/friendica/view/smarty3 - fi - mkdir $SOURCEDIR/friendica/addon - sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" - fi - - image_version="0.0.0.0" - if [ -f $SOURCEDIR/friendica/VERSION ]; then - image_version="$(cat $SOURCEDIR/friendica/VERSION)" - else - # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because no version found" - exit 1; - fi - - if version_greater "$installed_version" "$image_version"; then - echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - exit 1; - fi - - if version_greater "$image_version" "$installed_version"; then - if [ "$(id -u)" = 0 ]; then - rsync_options="-rlDog --chown www-data:root" - else - rsync_options="-rlD" - fi - - rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - if [ ! -f ${WORKDIR}/bin/composer.phar ]; then - echo "no composer found" - exit 1 - fi - - run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" - fi - - if [ ! -f $WORKDIR/.htconfig.php ] && - [ -f $SOURCEDIR/config/htconfig.php ] && - "$AUTOINSTALL" == "true"; then - run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php" - # TODO Pull Request for dba Change - run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php" - console "autoinstall -f .htconfig.php" - # TODO Workaround because of a strange permission issue - rm -fr $WORKDIR/view/smarty3/compiled - elif [ "$1" = "update" ]; then - console "dbstructure update" - fi - fi -fi - -# Start sendmail if you find it -if [ -f /etc/init.d/sendmail ]; then - - line=$(head -n 1 /etc/hosts) - line2=$(echo $line | awk '{print $2}') - echo "$line $line2.localdomain" >> /etc/hosts - - nohup /etc/init.d/sendmail start > /dev/null 2>&1 & -fi +friendica install -q +friendica sendmail -q exec "$@" \ No newline at end of file diff --git a/stable/apache/Dockerfile b/stable/apache/Dockerfile index 5a47801..fef62fb 100644 --- a/stable/apache/Dockerfile +++ b/stable/apache/Dockerfile @@ -11,15 +11,11 @@ RUN set -ex; \ apt-get install -y --no-install-recommends \ rsync \ bzip2 \ - busybox-static \ git \ # For mail() support sendmail \ ; \ - rm -rf /var/lib/apt/lists/*; \ - \ - mkdir -p /var/spool/cron/crontabs; \ - echo '*/10 * * * * cd /var/www/html && php -f bin/worker.php' > /var/spool/cron/crontabs/www-data + rm -rf /var/lib/apt/lists/*; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ @@ -115,9 +111,11 @@ RUN set -ex; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ rm friendica_addons.tar.gz; +COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ COPY *.sh / RUN chmod +x /*.sh +RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] CMD ["apache2-foreground"] diff --git a/stable/apache/bin/friendica b/stable/apache/bin/friendica new file mode 100644 index 0000000..175ed05 --- /dev/null +++ b/stable/apache/bin/friendica @@ -0,0 +1,212 @@ +#!/bin/sh +set -eu + +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} + +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# change delimiter for arrays from whitespaces to newlines (so we can pass strings with whitespaces) +#IFS=\r\n + +VERBOSE=1 +for arg; do + case "$arg" in + -q|--quit) + if [ "$VERBOSE" -eq "2" ]; then + echo 'You cannot use verbose and quiet at the same time' + exit 1 + fi + VERBOSE=0 + break + ;; + -v|--verbose) + if [ "$VERBOSE" -eq "0" ]; then + echo 'You cannot use verbose and quiet at the same time' + exit 1 + fi + VERBOSE=2 + break + ;; + esac +done + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# log event +log() { + currVerb=1 + if [ $# -eq 2 ]; then + currVerb=$2 + fi + if [ "$VERBOSE" -ge "$currVerb" ]; then + echo "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + dir="${1:-$SOURCEDIR}" + friendica="${2:-$FRIENDICA_VERSION}" + addons="${3:-$FRIENDICA_ADDONS}" + + log 'Cloning Friendica '\'$friendica\'' with Addons '\'$addons\'' into '\'$dir\' + + # Removing the whole directory first + rm -fr $dir/friendica + + sh -c "git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica" + mkdir $dir/friendica/addon + sh -c "git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon" +} + +# help of this shell script +friendica_help() { + echo "Usage: friendica []" + echo "" + echo "Commands:" + echo " console Executes an command in the Friendica console" + echo " composer Executes the composer.phar executable for Friendica" + echo " install Installs Friendica" + echo " update Updates Friendica" + exit 0 +} + +# executes the Friendica console +console() { + cd $WORKDIR + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + sh -c "php $WORKDIR/bin/console.php $@" +} + +# executes the composer.phar binary of Friendica +composer() { + if [ -f $WORKDIR/bin/composer.phar ]; then + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar $@ -d $WORKDIR" + fi +} + +copy_sources() { + installed_version="0.0.0.0" + if [ -f ${WORKDIR}/VERSION ]; then + installed_version="$(cat ${WORKDIR}/VERSION)" + fi + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + fi + + image_version="0.0.0.0" + if [ -f $SOURCEDIR/friendica/VERSION ]; then + image_version="$(cat $SOURCEDIR/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + log 'Friendica command '\'$1\'' failed, because of no version found', 0 + exit 1; + fi + + if version_greater "$installed_version" "$image_version"; then + log 'Can'\''t copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ('$image_version')', 0 + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown=www-data:root" + else + rsync_options="-rlD" + fi + + log 'Copying Friendica sources ('$image_version') from '\'$SOURCEDIR'/friendica'\'' to '\'$WORKDIR\' + rsync $rsync_options --delete --exclude='.git' $SOURCEDIR/friendica/ $WORKDIR/ + + if [ -f $WORKDIR/view/smarty3 ]; then + chmod 777 $WORKDIR/view/smarty3 + fi + fi +} + +# install Friendica +install() { + if [ -f ${WORKDIR}/VERSION ]; then + # If there is a given installation of Friendica and we should not update it => exit + # We have to explicit update Friendica to avoid breaking something + return + fi + + copy_sources + + log 'Installing Friendica' + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + + if [ ! -f ${WORKDIR}/.htconfig.php ] && + [ -f ${SOURCEDIR}/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr ${WORKDIR}/view/smarty3/compiled + fi +} + +update() { + if [ ! -f ${WORKDIR}/VERSION ]; then + # We want to update a given installation + # if there is no installation, exit + return + fi + + copy_sources + + log 'Upgrading Friendica' + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + console "dbstructure update" +} + +sendmail() { + if [ ! -f /etc/init.d/sendmail ]; then + # If sendmail isn't installed, exit this method + return + fi + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + log 'Starting sendmail for Mail-Support' + nohup /etc/init.d/sendmail start > /dev/null 2>&1 & +} + +if [ $# -eq 0 ]; then + friendica_help + exit 0 +fi + +case "$1" in + install) shift; install "$@";; + update) shift; update "$@" ;; + console) shift; console "$@" ;; + composer) shift; composer "$@" ;; + sendmail) shift; sendmail "$@" ;; + *) friendica_help ;; +esac diff --git a/stable/apache/cron.sh b/stable/apache/cron.sh index b368336..e8f064b 100644 --- a/stable/apache/cron.sh +++ b/stable/apache/cron.sh @@ -1,4 +1,14 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file +trap "break;exit" SIGHUP SIGINT SIGTERM + +while [ ! -f /var/www/html/.htconfig.php ]; do + sleep 1 +done + +while true; do + cd /var/www/html + php -f /var/www/html/bin/worker.php + sleep 10m +done \ No newline at end of file diff --git a/stable/apache/entrypoint.sh b/stable/apache/entrypoint.sh index d1c9eb2..4a0608c 100644 --- a/stable/apache/entrypoint.sh +++ b/stable/apache/entrypoint.sh @@ -1,109 +1,7 @@ #!/bin/sh set -eu -FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} -FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} -AUTOINSTALL=${AUTOINSTALL:-false} - -SOURCEDIR=/usr/src -WORKDIR=/var/www/html - -# run an command with the www-data user -run_as() { - if [ "$(id -u)" = 0 ]; then - su - www-data -s /bin/sh -c "$1" - else - sh -c "$1" - fi -} - -# checks if the the first parameter is greater than the second parameter -version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] -} - -# executes the Friendica console -console() { - cd $WORKDIR - # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - sh -c "php $WORKDIR/bin/console.php $@" -} - -# If there is no VERSION file or the command is "update", (re-)install Friendica -if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then - - installed_version="0.0.0.0" - if [ -f $WORKDIR/VERSION ]; then - installed_version="$(cat $WORKDIR/VERSION)" - fi - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - # Removing the whole directory first - rm -fr $SOURCEDIR/friendica - - sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" - if [ -f $SOURCEDIR/friendica/view/smarty3 ]; then - chmod 777 $SOURCEDIR/friendica/view/smarty3 - fi - mkdir $SOURCEDIR/friendica/addon - sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" - fi - - image_version="0.0.0.0" - if [ -f $SOURCEDIR/friendica/VERSION ]; then - image_version="$(cat $SOURCEDIR/friendica/VERSION)" - else - # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because no version found" - exit 1; - fi - - if version_greater "$installed_version" "$image_version"; then - echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - exit 1; - fi - - if version_greater "$image_version" "$installed_version"; then - if [ "$(id -u)" = 0 ]; then - rsync_options="-rlDog --chown www-data:root" - else - rsync_options="-rlD" - fi - - rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - if [ ! -f ${WORKDIR}/bin/composer.phar ]; then - echo "no composer found" - exit 1 - fi - - run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" - fi - - if [ ! -f $WORKDIR/.htconfig.php ] && - [ -f $SOURCEDIR/config/htconfig.php ] && - "$AUTOINSTALL" == "true"; then - run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php" - # TODO Pull Request for dba Change - run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php" - console "autoinstall -f .htconfig.php" - # TODO Workaround because of a strange permission issue - rm -fr $WORKDIR/view/smarty3/compiled - elif [ "$1" = "update" ]; then - console "dbstructure update" - fi - fi -fi - -# Start sendmail if you find it -if [ -f /etc/init.d/sendmail ]; then - - line=$(head -n 1 /etc/hosts) - line2=$(echo $line | awk '{print $2}') - echo "$line $line2.localdomain" >> /etc/hosts - - nohup /etc/init.d/sendmail start > /dev/null 2>&1 & -fi +friendica install -q +friendica sendmail -q exec "$@" \ No newline at end of file diff --git a/stable/fpm-alpine/Dockerfile b/stable/fpm-alpine/Dockerfile index 4cca26b..b1dea2c 100644 --- a/stable/fpm-alpine/Dockerfile +++ b/stable/fpm-alpine/Dockerfile @@ -9,11 +9,7 @@ RUN set -ex; \ \ apk add --no-cache \ rsync \ - git \ - ; \ - \ - rm /var/spool/cron/crontabs/root; \ - echo '*/10 * * * * cd /var/www/html && php -f bin/worker.php' > /var/spool/cron/crontabs/www-data + git; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ @@ -93,9 +89,11 @@ RUN set -ex; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ rm friendica_addons.tar.gz; +COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ COPY *.sh / RUN chmod +x /*.sh +RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] \ No newline at end of file diff --git a/stable/fpm-alpine/bin/friendica b/stable/fpm-alpine/bin/friendica new file mode 100644 index 0000000..175ed05 --- /dev/null +++ b/stable/fpm-alpine/bin/friendica @@ -0,0 +1,212 @@ +#!/bin/sh +set -eu + +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} + +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# change delimiter for arrays from whitespaces to newlines (so we can pass strings with whitespaces) +#IFS=\r\n + +VERBOSE=1 +for arg; do + case "$arg" in + -q|--quit) + if [ "$VERBOSE" -eq "2" ]; then + echo 'You cannot use verbose and quiet at the same time' + exit 1 + fi + VERBOSE=0 + break + ;; + -v|--verbose) + if [ "$VERBOSE" -eq "0" ]; then + echo 'You cannot use verbose and quiet at the same time' + exit 1 + fi + VERBOSE=2 + break + ;; + esac +done + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# log event +log() { + currVerb=1 + if [ $# -eq 2 ]; then + currVerb=$2 + fi + if [ "$VERBOSE" -ge "$currVerb" ]; then + echo "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + dir="${1:-$SOURCEDIR}" + friendica="${2:-$FRIENDICA_VERSION}" + addons="${3:-$FRIENDICA_ADDONS}" + + log 'Cloning Friendica '\'$friendica\'' with Addons '\'$addons\'' into '\'$dir\' + + # Removing the whole directory first + rm -fr $dir/friendica + + sh -c "git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica" + mkdir $dir/friendica/addon + sh -c "git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon" +} + +# help of this shell script +friendica_help() { + echo "Usage: friendica []" + echo "" + echo "Commands:" + echo " console Executes an command in the Friendica console" + echo " composer Executes the composer.phar executable for Friendica" + echo " install Installs Friendica" + echo " update Updates Friendica" + exit 0 +} + +# executes the Friendica console +console() { + cd $WORKDIR + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + sh -c "php $WORKDIR/bin/console.php $@" +} + +# executes the composer.phar binary of Friendica +composer() { + if [ -f $WORKDIR/bin/composer.phar ]; then + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar $@ -d $WORKDIR" + fi +} + +copy_sources() { + installed_version="0.0.0.0" + if [ -f ${WORKDIR}/VERSION ]; then + installed_version="$(cat ${WORKDIR}/VERSION)" + fi + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + fi + + image_version="0.0.0.0" + if [ -f $SOURCEDIR/friendica/VERSION ]; then + image_version="$(cat $SOURCEDIR/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + log 'Friendica command '\'$1\'' failed, because of no version found', 0 + exit 1; + fi + + if version_greater "$installed_version" "$image_version"; then + log 'Can'\''t copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ('$image_version')', 0 + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown=www-data:root" + else + rsync_options="-rlD" + fi + + log 'Copying Friendica sources ('$image_version') from '\'$SOURCEDIR'/friendica'\'' to '\'$WORKDIR\' + rsync $rsync_options --delete --exclude='.git' $SOURCEDIR/friendica/ $WORKDIR/ + + if [ -f $WORKDIR/view/smarty3 ]; then + chmod 777 $WORKDIR/view/smarty3 + fi + fi +} + +# install Friendica +install() { + if [ -f ${WORKDIR}/VERSION ]; then + # If there is a given installation of Friendica and we should not update it => exit + # We have to explicit update Friendica to avoid breaking something + return + fi + + copy_sources + + log 'Installing Friendica' + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + + if [ ! -f ${WORKDIR}/.htconfig.php ] && + [ -f ${SOURCEDIR}/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr ${WORKDIR}/view/smarty3/compiled + fi +} + +update() { + if [ ! -f ${WORKDIR}/VERSION ]; then + # We want to update a given installation + # if there is no installation, exit + return + fi + + copy_sources + + log 'Upgrading Friendica' + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + console "dbstructure update" +} + +sendmail() { + if [ ! -f /etc/init.d/sendmail ]; then + # If sendmail isn't installed, exit this method + return + fi + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + log 'Starting sendmail for Mail-Support' + nohup /etc/init.d/sendmail start > /dev/null 2>&1 & +} + +if [ $# -eq 0 ]; then + friendica_help + exit 0 +fi + +case "$1" in + install) shift; install "$@";; + update) shift; update "$@" ;; + console) shift; console "$@" ;; + composer) shift; composer "$@" ;; + sendmail) shift; sendmail "$@" ;; + *) friendica_help ;; +esac diff --git a/stable/fpm-alpine/cron.sh b/stable/fpm-alpine/cron.sh index b368336..e8f064b 100644 --- a/stable/fpm-alpine/cron.sh +++ b/stable/fpm-alpine/cron.sh @@ -1,4 +1,14 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file +trap "break;exit" SIGHUP SIGINT SIGTERM + +while [ ! -f /var/www/html/.htconfig.php ]; do + sleep 1 +done + +while true; do + cd /var/www/html + php -f /var/www/html/bin/worker.php + sleep 10m +done \ No newline at end of file diff --git a/stable/fpm-alpine/entrypoint.sh b/stable/fpm-alpine/entrypoint.sh index d1c9eb2..4a0608c 100644 --- a/stable/fpm-alpine/entrypoint.sh +++ b/stable/fpm-alpine/entrypoint.sh @@ -1,109 +1,7 @@ #!/bin/sh set -eu -FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} -FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} -AUTOINSTALL=${AUTOINSTALL:-false} - -SOURCEDIR=/usr/src -WORKDIR=/var/www/html - -# run an command with the www-data user -run_as() { - if [ "$(id -u)" = 0 ]; then - su - www-data -s /bin/sh -c "$1" - else - sh -c "$1" - fi -} - -# checks if the the first parameter is greater than the second parameter -version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] -} - -# executes the Friendica console -console() { - cd $WORKDIR - # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - sh -c "php $WORKDIR/bin/console.php $@" -} - -# If there is no VERSION file or the command is "update", (re-)install Friendica -if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then - - installed_version="0.0.0.0" - if [ -f $WORKDIR/VERSION ]; then - installed_version="$(cat $WORKDIR/VERSION)" - fi - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - # Removing the whole directory first - rm -fr $SOURCEDIR/friendica - - sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" - if [ -f $SOURCEDIR/friendica/view/smarty3 ]; then - chmod 777 $SOURCEDIR/friendica/view/smarty3 - fi - mkdir $SOURCEDIR/friendica/addon - sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" - fi - - image_version="0.0.0.0" - if [ -f $SOURCEDIR/friendica/VERSION ]; then - image_version="$(cat $SOURCEDIR/friendica/VERSION)" - else - # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because no version found" - exit 1; - fi - - if version_greater "$installed_version" "$image_version"; then - echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - exit 1; - fi - - if version_greater "$image_version" "$installed_version"; then - if [ "$(id -u)" = 0 ]; then - rsync_options="-rlDog --chown www-data:root" - else - rsync_options="-rlD" - fi - - rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - if [ ! -f ${WORKDIR}/bin/composer.phar ]; then - echo "no composer found" - exit 1 - fi - - run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" - fi - - if [ ! -f $WORKDIR/.htconfig.php ] && - [ -f $SOURCEDIR/config/htconfig.php ] && - "$AUTOINSTALL" == "true"; then - run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php" - # TODO Pull Request for dba Change - run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php" - console "autoinstall -f .htconfig.php" - # TODO Workaround because of a strange permission issue - rm -fr $WORKDIR/view/smarty3/compiled - elif [ "$1" = "update" ]; then - console "dbstructure update" - fi - fi -fi - -# Start sendmail if you find it -if [ -f /etc/init.d/sendmail ]; then - - line=$(head -n 1 /etc/hosts) - line2=$(echo $line | awk '{print $2}') - echo "$line $line2.localdomain" >> /etc/hosts - - nohup /etc/init.d/sendmail start > /dev/null 2>&1 & -fi +friendica install -q +friendica sendmail -q exec "$@" \ No newline at end of file diff --git a/stable/fpm/Dockerfile b/stable/fpm/Dockerfile index f01f770..1926273 100644 --- a/stable/fpm/Dockerfile +++ b/stable/fpm/Dockerfile @@ -11,15 +11,11 @@ RUN set -ex; \ apt-get install -y --no-install-recommends \ rsync \ bzip2 \ - busybox-static \ git \ # For mail() support sendmail \ ; \ - rm -rf /var/lib/apt/lists/*; \ - \ - mkdir -p /var/spool/cron/crontabs; \ - echo '*/10 * * * * cd /var/www/html && php -f bin/worker.php' > /var/spool/cron/crontabs/www-data + rm -rf /var/lib/apt/lists/*; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ @@ -106,9 +102,11 @@ RUN set -ex; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ rm friendica_addons.tar.gz; +COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ COPY *.sh / RUN chmod +x /*.sh +RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] diff --git a/stable/fpm/bin/friendica b/stable/fpm/bin/friendica new file mode 100644 index 0000000..175ed05 --- /dev/null +++ b/stable/fpm/bin/friendica @@ -0,0 +1,212 @@ +#!/bin/sh +set -eu + +FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} +FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} +AUTOINSTALL=${AUTOINSTALL:-false} + +SOURCEDIR=/usr/src +WORKDIR=/var/www/html + +# change delimiter for arrays from whitespaces to newlines (so we can pass strings with whitespaces) +#IFS=\r\n + +VERBOSE=1 +for arg; do + case "$arg" in + -q|--quit) + if [ "$VERBOSE" -eq "2" ]; then + echo 'You cannot use verbose and quiet at the same time' + exit 1 + fi + VERBOSE=0 + break + ;; + -v|--verbose) + if [ "$VERBOSE" -eq "0" ]; then + echo 'You cannot use verbose and quiet at the same time' + exit 1 + fi + VERBOSE=2 + break + ;; + esac +done + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" = 0 ]; then + su - www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +# log event +log() { + currVerb=1 + if [ $# -eq 2 ]; then + currVerb=$2 + fi + if [ "$VERBOSE" -ge "$currVerb" ]; then + echo "$1" + fi +} + +# checks if the the first parameter is greater than the second parameter +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + dir="${1:-$SOURCEDIR}" + friendica="${2:-$FRIENDICA_VERSION}" + addons="${3:-$FRIENDICA_ADDONS}" + + log 'Cloning Friendica '\'$friendica\'' with Addons '\'$addons\'' into '\'$dir\' + + # Removing the whole directory first + rm -fr $dir/friendica + + sh -c "git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica" + mkdir $dir/friendica/addon + sh -c "git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon" +} + +# help of this shell script +friendica_help() { + echo "Usage: friendica []" + echo "" + echo "Commands:" + echo " console Executes an command in the Friendica console" + echo " composer Executes the composer.phar executable for Friendica" + echo " install Installs Friendica" + echo " update Updates Friendica" + exit 0 +} + +# executes the Friendica console +console() { + cd $WORKDIR + # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) + sh -c "php $WORKDIR/bin/console.php $@" +} + +# executes the composer.phar binary of Friendica +composer() { + if [ -f $WORKDIR/bin/composer.phar ]; then + run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar $@ -d $WORKDIR" + fi +} + +copy_sources() { + installed_version="0.0.0.0" + if [ -f ${WORKDIR}/VERSION ]; then + installed_version="$(cat ${WORKDIR}/VERSION)" + fi + + if [ "$FRIENDICA_VERSION" = "develop" ]; then + clone_develop + fi + + image_version="0.0.0.0" + if [ -f $SOURCEDIR/friendica/VERSION ]; then + image_version="$(cat $SOURCEDIR/friendica/VERSION)" + else + # no given installation and not using the developer branch => nothing to do + log 'Friendica command '\'$1\'' failed, because of no version found', 0 + exit 1; + fi + + if version_greater "$installed_version" "$image_version"; then + log 'Can'\''t copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ('$image_version')', 0 + exit 1; + fi + + if version_greater "$image_version" "$installed_version"; then + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown=www-data:root" + else + rsync_options="-rlD" + fi + + log 'Copying Friendica sources ('$image_version') from '\'$SOURCEDIR'/friendica'\'' to '\'$WORKDIR\' + rsync $rsync_options --delete --exclude='.git' $SOURCEDIR/friendica/ $WORKDIR/ + + if [ -f $WORKDIR/view/smarty3 ]; then + chmod 777 $WORKDIR/view/smarty3 + fi + fi +} + +# install Friendica +install() { + if [ -f ${WORKDIR}/VERSION ]; then + # If there is a given installation of Friendica and we should not update it => exit + # We have to explicit update Friendica to avoid breaking something + return + fi + + copy_sources + + log 'Installing Friendica' + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + + if [ ! -f ${WORKDIR}/.htconfig.php ] && + [ -f ${SOURCEDIR}/config/htconfig.php ] && + "$AUTOINSTALL" == "true"; then + run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php" + # TODO Pull Request for dba Change + run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php" + console "autoinstall -f .htconfig.php" + # TODO Workaround because of a strange permission issue + rm -fr ${WORKDIR}/view/smarty3/compiled + fi +} + +update() { + if [ ! -f ${WORKDIR}/VERSION ]; then + # We want to update a given installation + # if there is no installation, exit + return + fi + + copy_sources + + log 'Upgrading Friendica' + if [ "$FRIENDICA_VERSION" = "develop" ]; then + composer "install" + fi + console "dbstructure update" +} + +sendmail() { + if [ ! -f /etc/init.d/sendmail ]; then + # If sendmail isn't installed, exit this method + return + fi + + line=$(head -n 1 /etc/hosts) + line2=$(echo $line | awk '{print $2}') + echo "$line $line2.localdomain" >> /etc/hosts + + log 'Starting sendmail for Mail-Support' + nohup /etc/init.d/sendmail start > /dev/null 2>&1 & +} + +if [ $# -eq 0 ]; then + friendica_help + exit 0 +fi + +case "$1" in + install) shift; install "$@";; + update) shift; update "$@" ;; + console) shift; console "$@" ;; + composer) shift; composer "$@" ;; + sendmail) shift; sendmail "$@" ;; + *) friendica_help ;; +esac diff --git a/stable/fpm/cron.sh b/stable/fpm/cron.sh index b368336..e8f064b 100644 --- a/stable/fpm/cron.sh +++ b/stable/fpm/cron.sh @@ -1,4 +1,14 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout \ No newline at end of file +trap "break;exit" SIGHUP SIGINT SIGTERM + +while [ ! -f /var/www/html/.htconfig.php ]; do + sleep 1 +done + +while true; do + cd /var/www/html + php -f /var/www/html/bin/worker.php + sleep 10m +done \ No newline at end of file diff --git a/stable/fpm/entrypoint.sh b/stable/fpm/entrypoint.sh index d1c9eb2..4a0608c 100644 --- a/stable/fpm/entrypoint.sh +++ b/stable/fpm/entrypoint.sh @@ -1,109 +1,7 @@ #!/bin/sh set -eu -FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} -FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} -AUTOINSTALL=${AUTOINSTALL:-false} - -SOURCEDIR=/usr/src -WORKDIR=/var/www/html - -# run an command with the www-data user -run_as() { - if [ "$(id -u)" = 0 ]; then - su - www-data -s /bin/sh -c "$1" - else - sh -c "$1" - fi -} - -# checks if the the first parameter is greater than the second parameter -version_greater() { - [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ] -} - -# executes the Friendica console -console() { - cd $WORKDIR - # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - sh -c "php $WORKDIR/bin/console.php $@" -} - -# If there is no VERSION file or the command is "update", (re-)install Friendica -if [ ! -f $WORKDIR/VERSION -o "$1" = "update" ]; then - - installed_version="0.0.0.0" - if [ -f $WORKDIR/VERSION ]; then - installed_version="$(cat $WORKDIR/VERSION)" - fi - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - # Removing the whole directory first - rm -fr $SOURCEDIR/friendica - - sh -c "git clone -q -b $FRIENDICA_VERSION https://github.com/friendica/friendica $SOURCEDIR/friendica" - if [ -f $SOURCEDIR/friendica/view/smarty3 ]; then - chmod 777 $SOURCEDIR/friendica/view/smarty3 - fi - mkdir $SOURCEDIR/friendica/addon - sh -c "git clone -q -b $FRIENDICA_ADDONS https://github.com/friendica/friendica-addons $SOURCEDIR/friendica/addon" - fi - - image_version="0.0.0.0" - if [ -f $SOURCEDIR/friendica/VERSION ]; then - image_version="$(cat $SOURCEDIR/friendica/VERSION)" - else - # no given installation and not using the developer branch => nothing to do - echo "Friendica command '$1' failed, because no version found" - exit 1; - fi - - if version_greater "$installed_version" "$image_version"; then - echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)" - exit 1; - fi - - if version_greater "$image_version" "$installed_version"; then - if [ "$(id -u)" = 0 ]; then - rsync_options="-rlDog --chown www-data:root" - else - rsync_options="-rlD" - fi - - rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/ - - if [ "$FRIENDICA_VERSION" = "develop" ]; then - if [ ! -f ${WORKDIR}/bin/composer.phar ]; then - echo "no composer found" - exit 1 - fi - - run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar install -d $WORKDIR" - fi - - if [ ! -f $WORKDIR/.htconfig.php ] && - [ -f $SOURCEDIR/config/htconfig.php ] && - "$AUTOINSTALL" == "true"; then - run_as "cp $SOURCEDIR/config/htconfig.php $WORKDIR/html/.htconfig.php" - # TODO Pull Request for dba Change - run_as "sed -i 's/\s+\sDNS_CNAME//g' $WORKDIR/include/dba.php" - console "autoinstall -f .htconfig.php" - # TODO Workaround because of a strange permission issue - rm -fr $WORKDIR/view/smarty3/compiled - elif [ "$1" = "update" ]; then - console "dbstructure update" - fi - fi -fi - -# Start sendmail if you find it -if [ -f /etc/init.d/sendmail ]; then - - line=$(head -n 1 /etc/hosts) - line2=$(echo $line | awk '{print $2}') - echo "$line $line2.localdomain" >> /etc/hosts - - nohup /etc/init.d/sendmail start > /dev/null 2>&1 & -fi +friendica install -q +friendica sendmail -q exec "$@" \ No newline at end of file