diff --git a/.bin/friendica b/.bin/friendica deleted file mode 100644 index e9abd27..0000000 --- a/.bin/friendica +++ /dev/null @@ -1,278 +0,0 @@ -#!/bin/sh -set -eu - -SMTP=${SMTP:-localhost} -SMTP_FROM=${SMTP_FROM:-no-reply} - -SOURCEDIR=${SOURCEDIR:-/usr/src} -WORKDIR=${WORKDIR:-/var/www/html} - -SMTP_TLS=${SMTP_TLS:-} -SMTP_STARTTLS=${SMTP_STARTTLS:-} -SMTP_AUTH_USER=${SMTP_AUTH_USER:-} -SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-} -SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-} - -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)" -eq 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}" - - friendica_git=$friendica - addons_git=$addons - if echo "$friendica" | grep -Eq '^.*\-dev'; then - friendica_git="develop" - fi - - if echo "$addons" | grep -Eq '^.*\-dev'; then - addons_git="develop" - fi - - log 'Cloning Friendica '\'$friendica_git\'' with Addons '\'$addons_git\'' into '\'$dir\' - - # Removing the whole directory first - rm -fr $dir/friendica - - sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica ${dir}/friendica" - mkdir $dir/friendica/addon - sh -c "git clone -q -b ${addons_git} 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 -} - -check_database() { - TERM=dumb php -- <<'EOPHP' - -EOPHP -} - -# executes the Friendica console -console() { - if [ -f $WORKDIR/bin/console.php ]; then - cd $WORKDIR - php $WORKDIR/bin/console.php "$@" - fi -} - -# 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" - elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then - cd $SOURCEDIR/friendica - $SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica - fi -} - -copy_sources() { - installed_version="0.0.0.0" - if [ -f ${WORKDIR}/VERSION ]; then - installed_version="$(cat ${WORKDIR}/VERSION)" - fi - - if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; 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" || - echo "$image_version" | grep -Eq '^.*\-dev|-rc'; then - if [ "$(id -u)" -eq 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' --exclude='photo' --exclude='proxy' --exclude='.htconfig.php' --exclude='home.*' $SOURCEDIR/friendica/ $WORKDIR/ - - if [ -f $WORKDIR/view/smarty3 ]; then - chmod -R 777 $WORKDIR/view/smarty3 - fi - - # the stable packages already have the whole vendor stuff in their images - if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then - composer install - 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 - - log 'Installing Friendica' - - copy_sources - - if [ ! -f ${WORKDIR}/.htconfig.php ] && - [ -f ${SOURCEDIR}/config/htconfig.php ] && - [ "$AUTOINSTALL" = "true" ]; then - if check_database; then - run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php" - console autoinstall -f .htconfig.php - # TODO Workaround because of a strange permission issue - rm -fr ${WORKDIR}/view/smarty3/compiled - fi - fi -} - -update() { - if [ ! -f ${WORKDIR}/VERSION ]; then - # We want to update a given installation - # if there is no installation, exit - return - fi - - log 'Upgrading Friendica' - - copy_sources - - console dbstructure update -} - -configmail() { - if [ "$SMTP" = "localhost" ]; then - # SMTP is a required setting - # do nothing if it is "localhost" (= not changed) - return - fi - - sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd - sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd - - # add possible mail-senders - echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases - echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases - - # replace ssmtp.conf settings - cat << EOF > /etc/ssmtp/ssmtp.conf -# /etc/ssmtp/ssmtp.conf - -root=$SMTP_FROM@$HOSTNAME -hostname=$HOSTNAME -mailhub=$SMTP -FromLineOverride=YES -EOF - [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf -} - -if [ "$#" -eq 0 ]; then - friendica_help - exit 0 -fi - -case "$1" in - install) shift; install $@;; - update) shift; update $@ ;; - console) shift; console $@ ;; - composer) shift; composer $@ ;; - configmail) shift; configmail $@ ;; - *) friendica_help ;; -esac diff --git a/.config/htconfig.php b/.config/htconfig.php deleted file mode 100644 index 4b67aa8..0000000 --- a/.config/htconfig.php +++ /dev/null @@ -1,137 +0,0 @@ -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; - -if (!empty(getenv('VALIDATION'))) { - $a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION')); - $a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION')); -} - -if (!empty(getenv('CACHE_DRIVER'))) { - $a->config['system']['cache_driver'] = strtolower(getenv('CACHE_DRIVER')); - - if (!empty(getenv('REDIS_HOST'))) { - $a->config['system']['redis_host'] = getenv('REDIS_HOST'); - } - - if (!empty(getenv('REDIS_PORT'))) { - $a->config['system']['redis_port'] = getenv('REDIS_PORT'); - } - - if (!empty(getenv('MEMCACHE_HOST'))) { - $a->config['system']['memcache_host'] = getenv('MEMCACHE_HOST'); - } - - if (!empty(getenv('MEMCACHE_PORT'))) { - $a->config['system']['memcache_port'] = getenv('MEMCACHE_PORT'); - } - - if (!empty(getenv('MEMCACHED_HOSTS'))) { - $a->config['system']['memcached_hosts'] = getenv('MEMCACHED_HOSTS'); - } -} \ No newline at end of file diff --git a/.examples/README.md b/.examples/README.md index 7af8455..c3f88f5 100644 --- a/.examples/README.md +++ b/.examples/README.md @@ -1,68 +1,87 @@ -# Examples section - -In this subfolder are some examples how to use the docker images. -There are two section: - -* [`dockerfiles`](https://github.com/friendica/docker/tree/master/.examples/dockerfiles) -* [`docker-compose`](https://github.com/friendica/docker/tree/master/.examples/docker-compose) - -The `dockerfiles` are derived images that add or alter certain functionalities of the default docker images. -In the `docker-compose` subfolder are examples for deployment of the application. - -## Dockerfiles - -The Dockerfiles use the default images as base image and build on top of it. - -Examples | Descriptions --------- | ------- -[cron](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/cron) | uses supervisor to run the cron job inside the container (so no extra container is needed). - -## docker-compose - -In `docker-compose` additional services are bundled to create a complex Friendica installation. -The examples are designed to run out-of-the-box. - -Before running the examples, you have to modify the `db.env` and `docker-compose.yml` file and fill in your custom information. - -The docker-compose examples make heavily use of derived Dockerfiles to add configuration files into the containers. -This way they should also work on remote docker systems as _Docker for Windows_. -when running docker-compose on the same host as the docker daemon, another possibility would be to simply mount the files in the volumes section in the `docker-compose.yml` file. - -### insecure - -This examples should only be used for **testing** on the local network because it uses a unencrypted http connection. -When you want to have your server reachable from the internet adding HTTPS-encryption is mandatory! -For this use one of the [with-traefik-proxy](#with-traefik-proxy) examples. - -To use this example complete the following steps: - -1. choose a password for the database user in `db.env` behind `MYSQL_PASSWORD=` -2. run `docker-compose build --pull` to pull the mose recent base images and build the custom dockerfiles -3. start Friendica with `docker-compose up -d` - -If you want to update your installation to a newer version, repeat 3 and 4. -**Note**: If you are on a develop branch (*-dev or *-rc) you have to update Friendica with the command `docker-compose exec app friendica update` - -### with-traefik-proxy - -The traefik proxy adds a proxy layer between Friendica and the internet. -The proxy is designed to server multiple sites on the same host machine. - -The advantage in adding this layer is the ability to use [Let's Encrypt](https://letsencrypt.org/) out certification handling of the box. - -Therefore you have to use adjust the `labels:` inside the `docker-compose.yml` to let traefik know what domains it should route and what certifications it should request. - -To use this example complete the following steps: - -1. open `docker-compose.yml` - 1. insert your friendica domain behind `hostname:` - 2. insert your friendica domain at `traefik.friendica.rule=Host:friendica.local` -2. choose a password for the database user in `db.env` behind `MYSQL_PASSWORD=` -3. open `proxy/traefik.toml` - 1. replace `domain = "example.org"` with your friendica domain - 2. replace `email = "root@example.org"` with a valid email -4. run `docker-compose build --pull` to pull the most recent base images and build the custom dockerfiles -5. start Friendica with `docker-compose up -d` - -If you want to update your installation to a newer version, repeat 4 and 5. +# Examples section + +In this subfolder are some examples how to use the docker images. +There are two section: + +* [`dockerfiles`](https://github.com/friendica/docker/tree/master/.examples/dockerfiles) +* [`docker-compose`](https://github.com/friendica/docker/tree/master/.examples/docker-compose) + +The `dockerfiles` are derived images that add or alter certain functionalities of the default docker images. +In the `docker-compose` subfolder are examples for deployment of the application. + +## Dockerfiles + +The Dockerfiles use the default images as base image and build on top of it. + +Examples | Descriptions +-------- | ------- +[cron](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/cron) | uses supervisor to run the cron job inside the container (so no extra container is needed). +[smtp](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/smtp) | adds SMTP support to the Friendica container (necessary if you want to have mail support in Friendica). + +### SMTP settings + +The binary `ssmtp` is used for the `mail()` support of Friendica. + +You have to set the `--hostname/-h` parameter correctly to use the right domainname for the `mail()` command. + +You have to set a valid SMTP-MTA for the `SMTP` environment variable to enable mail support in Friendica. +A valid SMTP-MTA would be, for example, `mx.example.org`. + +The following environment variables are possible for the SMTP examples. + +- `SITENAME` The name of the Friendica node. (**required** - Default: `Testsite`) +- `SMTP` Address of the SMTP Mail-Gateway. (**required** - Default: `localhost`) +- `SMTP_FROM` Sender user-part of the address. (Default: `no-reply` - e.g. no-reply@friendica.local) +- `SMTP_AUTH_USER` Username for the SMTP Mail-Gateway. (Default: empty) +- `SMTP_AUTH_PASS` Password for the SMTP Mail-Gateway. (Default: empty) +- `SMTP_AUTH_METHOD` Authentication method for the SMTP Mail-Gateway. (Default: empty/plain text) + +## docker-compose + +In `docker-compose` additional services are bundled to create a complex Friendica installation. +The examples are designed to run out-of-the-box. + +Before running the examples, you have to modify the `db.env` and `docker-compose.yml` file and fill in your custom information. + +The docker-compose examples make heavily use of derived Dockerfiles to add configuration files into the containers. +This way they should also work on remote docker systems as _Docker for Windows_. +when running docker-compose on the same host as the docker daemon, another possibility would be to simply mount the files in the volumes section in the `docker-compose.yml` file. + +### insecure + +This examples should only be used for **testing** on the local network because it uses a unencrypted http connection. +When you want to have your server reachable from the internet adding HTTPS-encryption is mandatory! +For this use one of the [with-traefik-proxy](#with-traefik-proxy) examples. + +To use this example complete the following steps: + +1. choose a password for the database user in `db.env` behind `MYSQL_PASSWORD=` +2. run `docker-compose build --pull` to pull the mose recent base images and build the custom dockerfiles +3. start Friendica with `docker-compose up -d` + +If you want to update your installation to a newer version, repeat 3 and 4. +**Note**: If you are on a develop branch (*-dev or *-rc) you have to update Friendica with the command `docker-compose exec app friendica update` + +### with-traefik-proxy + +The traefik proxy adds a proxy layer between Friendica and the internet. +The proxy is designed to server multiple sites on the same host machine. + +The advantage in adding this layer is the ability to use [Let's Encrypt](https://letsencrypt.org/) out certification handling of the box. + +Therefore you have to use adjust the `labels:` inside the `docker-compose.yml` to let traefik know what domains it should route and what certifications it should request. + +To use this example complete the following steps: + +1. open `docker-compose.yml` + 1. insert your friendica domain behind `hostname:` + 2. insert your friendica domain at `traefik.friendica.rule=Host:friendica.local` +2. choose a password for the database user in `db.env` behind `MYSQL_PASSWORD=` +3. open `proxy/traefik.toml` + 1. replace `domain = "example.org"` with your friendica domain + 2. replace `email = "root@example.org"` with a valid email +4. run `docker-compose build --pull` to pull the most recent base images and build the custom dockerfiles +5. start Friendica with `docker-compose up -d` + +If you want to update your installation to a newer version, repeat 4 and 5. **Note**: If you are on a develop branch (*-dev or *-rc) you have to update Friendica with the command `docker-compose exec app friendica update` \ No newline at end of file diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/Dockerfile b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/Dockerfile new file mode 100644 index 0000000..25f436d --- /dev/null +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/Dockerfile @@ -0,0 +1,41 @@ +FROM friendica/server:apache + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ +# For mail() support + ssmtp \ + ; \ + rm -rf /var/lib/apt/lists/*; + +ENV SMTP localhost +ENV SMTP_FROM no-reply + +ENV SITENAME "Testsite" + +# Setup SSMTP +RUN set -ex; \ + sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd ;\ + sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd ;\ +# add possible mail-senders + {\ + echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" ;\ + echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" ;\ + } > /etc/ssmtp/revaliases;\ +# replace ssmtp.conf settings + {\ + echo "root=$SMTP_FROM@$HOSTNAME" ;\ + echo "hostname=$HOSTNAME" ;\ + echo "mailhub=$SMTP" ;\ + echo "FromLineOverride=YES" ;\ + [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" ;\ + [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" ;\ + [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" ;\ + [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" ;\ + [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" ;\ + } > /etc/ssmtp/ssmtp.conf; + +RUN mkdir -p /usr/src/config +COPY addon.ini.php /usr/src/config/ diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/addon.ini.php b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/addon.ini.php new file mode 100644 index 0000000..c2bd16d --- /dev/null +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/addon.ini.php @@ -0,0 +1,12 @@ + /etc/ssmtp/revaliases;\ +# replace ssmtp.conf settings + {\ + echo "root=$SMTP_FROM@$HOSTNAME" ;\ + echo "hostname=$HOSTNAME" ;\ + echo "mailhub=$SMTP" ;\ + echo "FromLineOverride=YES" ;\ + [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" ;\ + [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" ;\ + [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" ;\ + [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" ;\ + [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" ;\ + } > /etc/ssmtp/ssmtp.conf; + +RUN mkdir -p /usr/src/config +COPY addon.ini.php /usr/src/config/ diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/fpm-alpine/app/addon.ini.php b/.examples/docker-compose/insecure/mariadb-cron-redis/fpm-alpine/app/addon.ini.php new file mode 100644 index 0000000..c2bd16d --- /dev/null +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/fpm-alpine/app/addon.ini.php @@ -0,0 +1,12 @@ + /etc/ssmtp/revaliases;\ +# replace ssmtp.conf settings + {\ + echo "root=$SMTP_FROM@$HOSTNAME" ;\ + echo "hostname=$HOSTNAME" ;\ + echo "mailhub=$SMTP" ;\ + echo "FromLineOverride=YES" ;\ + [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" ;\ + [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" ;\ + [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" ;\ + [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" ;\ + [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" ;\ + } > /etc/ssmtp/ssmtp.conf; + +RUN mkdir -p /usr/src/config +COPY addon.ini.php /usr/src/config/ diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/app/addon.ini.php b/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/app/addon.ini.php new file mode 100644 index 0000000..c2bd16d --- /dev/null +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/app/addon.ini.php @@ -0,0 +1,12 @@ + /etc/ssmtp/revaliases;\ +# replace ssmtp.conf settings + {\ + echo "root=$SMTP_FROM@$HOSTNAME" ;\ + echo "hostname=$HOSTNAME" ;\ + echo "mailhub=$SMTP" ;\ + echo "FromLineOverride=YES" ;\ + [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" ;\ + [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" ;\ + [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" ;\ + [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" ;\ + [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" ;\ + } > /etc/ssmtp/ssmtp.conf; diff --git a/.examples/dockerfiles/smtp/fpm-alpine/Dockerfile b/.examples/dockerfiles/smtp/fpm-alpine/Dockerfile new file mode 100644 index 0000000..edc772d --- /dev/null +++ b/.examples/dockerfiles/smtp/fpm-alpine/Dockerfile @@ -0,0 +1,32 @@ +FROM friendica/server:fpm-alpine + +RUN set -ex; \ + apk add --no-cache \ + # For mail() support + ssmtp; + +ENV SMTP localhost +ENV SMTP_FROM no-reply + +ENV SITENAME "Testsite" + +# Setup SSMTP +RUN sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd ;\ + sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd ;\ +# add possible mail-senders + {\ + echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" ;\ + echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" ;\ + } > /etc/ssmtp/revaliases;\ +# replace ssmtp.conf settings + {\ + echo "root=$SMTP_FROM@$HOSTNAME" ;\ + echo "hostname=$HOSTNAME" ;\ + echo "mailhub=$SMTP" ;\ + echo "FromLineOverride=YES" ;\ + [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" ;\ + [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" ;\ + [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" ;\ + [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" ;\ + [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" ;\ + } > /etc/ssmtp/ssmtp.conf; diff --git a/.examples/dockerfiles/smtp/fpm/Dockerfile b/.examples/dockerfiles/smtp/fpm/Dockerfile new file mode 100644 index 0000000..268f38f --- /dev/null +++ b/.examples/dockerfiles/smtp/fpm/Dockerfile @@ -0,0 +1,37 @@ +FROM friendica/server:fpm + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ +# For mail() support + ssmtp \ + ; \ + rm -rf /var/lib/apt/lists/*; + +ENV SMTP localhost +ENV SMTP_FROM no-reply + +ENV SITENAME "Testsite" + +# Setup SSMTP +RUN sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd ;\ + sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd ;\ +# add possible mail-senders + {\ + echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" ;\ + echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" ;\ + } > /etc/ssmtp/revaliases;\ +# replace ssmtp.conf settings + {\ + echo "root=$SMTP_FROM@$HOSTNAME" ;\ + echo "hostname=$HOSTNAME" ;\ + echo "mailhub=$SMTP" ;\ + echo "FromLineOverride=YES" ;\ + [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" ;\ + [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" ;\ + [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" ;\ + [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" ;\ + [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" ;\ + } > /etc/ssmtp/ssmtp.conf; diff --git a/.travis.yml b/.travis.yml index 2879499..e72073d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,23 +54,23 @@ jobs: - ./generate-stackbrew-library.sh - stage: test images (amd64) - env: VERSION=2018.08-dev VARIANT=fpm-alpine ARCH=amd64 - - env: VERSION=2018.08-dev VARIANT=fpm ARCH=amd64 - - env: VERSION=2018.08-dev VARIANT=apache ARCH=amd64 - - env: VERSION=2018.05 VARIANT=fpm-alpine ARCH=amd64 - - env: VERSION=2018.05 VARIANT=fpm ARCH=amd64 - - env: VERSION=2018.05 VARIANT=apache ARCH=amd64 + env: VERSION=2018.09 VARIANT=fpm-alpine ARCH=amd64 + - env: VERSION=2018.09 VARIANT=fpm ARCH=amd64 + - env: VERSION=2018.09 VARIANT=apache ARCH=amd64 + - env: VERSION=2018.12-dev VARIANT=fpm-alpine ARCH=amd64 + - env: VERSION=2018.12-dev VARIANT=fpm ARCH=amd64 + - env: VERSION=2018.12-dev VARIANT=apache ARCH=amd64 - stage: test images (full) - env: VERSION=2018.08-dev VARIANT=fpm-alpine ARCH=amd64 - - env: VERSION=2018.08-dev VARIANT=fpm-alpine ARCH=i386 - - env: VERSION=2018.08-dev VARIANT=fpm ARCH=amd64 - - env: VERSION=2018.08-dev VARIANT=fpm ARCH=i386 - - env: VERSION=2018.08-dev VARIANT=apache ARCH=amd64 - - env: VERSION=2018.08-dev VARIANT=apache ARCH=i386 - - env: VERSION=2018.05 VARIANT=fpm-alpine ARCH=amd64 - - env: VERSION=2018.05 VARIANT=fpm-alpine ARCH=i386 - - env: VERSION=2018.05 VARIANT=fpm ARCH=amd64 - - env: VERSION=2018.05 VARIANT=fpm ARCH=i386 - - env: VERSION=2018.05 VARIANT=apache ARCH=amd64 - - env: VERSION=2018.05 VARIANT=apache ARCH=i386 + env: VERSION=2018.09 VARIANT=fpm-alpine ARCH=amd64 + - env: VERSION=2018.09 VARIANT=fpm-alpine ARCH=i386 + - env: VERSION=2018.09 VARIANT=fpm ARCH=amd64 + - env: VERSION=2018.09 VARIANT=fpm ARCH=i386 + - env: VERSION=2018.09 VARIANT=apache ARCH=amd64 + - env: VERSION=2018.09 VARIANT=apache ARCH=i386 + - env: VERSION=2018.12-dev VARIANT=fpm-alpine ARCH=amd64 + - env: VERSION=2018.12-dev VARIANT=fpm-alpine ARCH=i386 + - env: VERSION=2018.12-dev VARIANT=fpm ARCH=amd64 + - env: VERSION=2018.12-dev VARIANT=fpm ARCH=i386 + - env: VERSION=2018.12-dev VARIANT=apache ARCH=amd64 + - env: VERSION=2018.12-dev VARIANT=apache ARCH=i386 diff --git a/2018.05/apache/bin/friendica b/2018.05/apache/bin/friendica deleted file mode 100644 index e9abd27..0000000 --- a/2018.05/apache/bin/friendica +++ /dev/null @@ -1,278 +0,0 @@ -#!/bin/sh -set -eu - -SMTP=${SMTP:-localhost} -SMTP_FROM=${SMTP_FROM:-no-reply} - -SOURCEDIR=${SOURCEDIR:-/usr/src} -WORKDIR=${WORKDIR:-/var/www/html} - -SMTP_TLS=${SMTP_TLS:-} -SMTP_STARTTLS=${SMTP_STARTTLS:-} -SMTP_AUTH_USER=${SMTP_AUTH_USER:-} -SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-} -SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-} - -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)" -eq 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}" - - friendica_git=$friendica - addons_git=$addons - if echo "$friendica" | grep -Eq '^.*\-dev'; then - friendica_git="develop" - fi - - if echo "$addons" | grep -Eq '^.*\-dev'; then - addons_git="develop" - fi - - log 'Cloning Friendica '\'$friendica_git\'' with Addons '\'$addons_git\'' into '\'$dir\' - - # Removing the whole directory first - rm -fr $dir/friendica - - sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica ${dir}/friendica" - mkdir $dir/friendica/addon - sh -c "git clone -q -b ${addons_git} 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 -} - -check_database() { - TERM=dumb php -- <<'EOPHP' - -EOPHP -} - -# executes the Friendica console -console() { - if [ -f $WORKDIR/bin/console.php ]; then - cd $WORKDIR - php $WORKDIR/bin/console.php "$@" - fi -} - -# 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" - elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then - cd $SOURCEDIR/friendica - $SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica - fi -} - -copy_sources() { - installed_version="0.0.0.0" - if [ -f ${WORKDIR}/VERSION ]; then - installed_version="$(cat ${WORKDIR}/VERSION)" - fi - - if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; 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" || - echo "$image_version" | grep -Eq '^.*\-dev|-rc'; then - if [ "$(id -u)" -eq 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' --exclude='photo' --exclude='proxy' --exclude='.htconfig.php' --exclude='home.*' $SOURCEDIR/friendica/ $WORKDIR/ - - if [ -f $WORKDIR/view/smarty3 ]; then - chmod -R 777 $WORKDIR/view/smarty3 - fi - - # the stable packages already have the whole vendor stuff in their images - if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then - composer install - 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 - - log 'Installing Friendica' - - copy_sources - - if [ ! -f ${WORKDIR}/.htconfig.php ] && - [ -f ${SOURCEDIR}/config/htconfig.php ] && - [ "$AUTOINSTALL" = "true" ]; then - if check_database; then - run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php" - console autoinstall -f .htconfig.php - # TODO Workaround because of a strange permission issue - rm -fr ${WORKDIR}/view/smarty3/compiled - fi - fi -} - -update() { - if [ ! -f ${WORKDIR}/VERSION ]; then - # We want to update a given installation - # if there is no installation, exit - return - fi - - log 'Upgrading Friendica' - - copy_sources - - console dbstructure update -} - -configmail() { - if [ "$SMTP" = "localhost" ]; then - # SMTP is a required setting - # do nothing if it is "localhost" (= not changed) - return - fi - - sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd - sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd - - # add possible mail-senders - echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases - echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases - - # replace ssmtp.conf settings - cat << EOF > /etc/ssmtp/ssmtp.conf -# /etc/ssmtp/ssmtp.conf - -root=$SMTP_FROM@$HOSTNAME -hostname=$HOSTNAME -mailhub=$SMTP -FromLineOverride=YES -EOF - [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf -} - -if [ "$#" -eq 0 ]; then - friendica_help - exit 0 -fi - -case "$1" in - install) shift; install $@;; - update) shift; update $@ ;; - console) shift; console $@ ;; - composer) shift; composer $@ ;; - configmail) shift; configmail $@ ;; - *) friendica_help ;; -esac diff --git a/2018.05/apache/config/htconfig.php b/2018.05/apache/config/htconfig.php deleted file mode 100644 index 4b67aa8..0000000 --- a/2018.05/apache/config/htconfig.php +++ /dev/null @@ -1,137 +0,0 @@ -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; - -if (!empty(getenv('VALIDATION'))) { - $a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION')); - $a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION')); -} - -if (!empty(getenv('CACHE_DRIVER'))) { - $a->config['system']['cache_driver'] = strtolower(getenv('CACHE_DRIVER')); - - if (!empty(getenv('REDIS_HOST'))) { - $a->config['system']['redis_host'] = getenv('REDIS_HOST'); - } - - if (!empty(getenv('REDIS_PORT'))) { - $a->config['system']['redis_port'] = getenv('REDIS_PORT'); - } - - if (!empty(getenv('MEMCACHE_HOST'))) { - $a->config['system']['memcache_host'] = getenv('MEMCACHE_HOST'); - } - - if (!empty(getenv('MEMCACHE_PORT'))) { - $a->config['system']['memcache_port'] = getenv('MEMCACHE_PORT'); - } - - if (!empty(getenv('MEMCACHED_HOSTS'))) { - $a->config['system']['memcached_hosts'] = getenv('MEMCACHED_HOSTS'); - } -} \ No newline at end of file diff --git a/2018.05/apache/cron.sh b/2018.05/apache/cron.sh deleted file mode 100644 index 8c29dee..0000000 --- a/2018.05/apache/cron.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -trap "break;exit" HUP INT TERM - -while [ ! -f /var/www/html/.htconfig.php ]; do - sleep 1 -done - -while true; do - php -f /var/www/html/bin/worker.php - sleep 10m -done \ No newline at end of file diff --git a/2018.05/apache/entrypoint.sh b/2018.05/apache/entrypoint.sh deleted file mode 100644 index 8b75f8d..0000000 --- a/2018.05/apache/entrypoint.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -eu - -friendica install -q -friendica configmail -q - -exec "$@" \ No newline at end of file diff --git a/2018.05/fpm-alpine/bin/friendica b/2018.05/fpm-alpine/bin/friendica deleted file mode 100644 index e9abd27..0000000 --- a/2018.05/fpm-alpine/bin/friendica +++ /dev/null @@ -1,278 +0,0 @@ -#!/bin/sh -set -eu - -SMTP=${SMTP:-localhost} -SMTP_FROM=${SMTP_FROM:-no-reply} - -SOURCEDIR=${SOURCEDIR:-/usr/src} -WORKDIR=${WORKDIR:-/var/www/html} - -SMTP_TLS=${SMTP_TLS:-} -SMTP_STARTTLS=${SMTP_STARTTLS:-} -SMTP_AUTH_USER=${SMTP_AUTH_USER:-} -SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-} -SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-} - -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)" -eq 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}" - - friendica_git=$friendica - addons_git=$addons - if echo "$friendica" | grep -Eq '^.*\-dev'; then - friendica_git="develop" - fi - - if echo "$addons" | grep -Eq '^.*\-dev'; then - addons_git="develop" - fi - - log 'Cloning Friendica '\'$friendica_git\'' with Addons '\'$addons_git\'' into '\'$dir\' - - # Removing the whole directory first - rm -fr $dir/friendica - - sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica ${dir}/friendica" - mkdir $dir/friendica/addon - sh -c "git clone -q -b ${addons_git} 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 -} - -check_database() { - TERM=dumb php -- <<'EOPHP' - -EOPHP -} - -# executes the Friendica console -console() { - if [ -f $WORKDIR/bin/console.php ]; then - cd $WORKDIR - php $WORKDIR/bin/console.php "$@" - fi -} - -# 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" - elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then - cd $SOURCEDIR/friendica - $SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica - fi -} - -copy_sources() { - installed_version="0.0.0.0" - if [ -f ${WORKDIR}/VERSION ]; then - installed_version="$(cat ${WORKDIR}/VERSION)" - fi - - if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; 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" || - echo "$image_version" | grep -Eq '^.*\-dev|-rc'; then - if [ "$(id -u)" -eq 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' --exclude='photo' --exclude='proxy' --exclude='.htconfig.php' --exclude='home.*' $SOURCEDIR/friendica/ $WORKDIR/ - - if [ -f $WORKDIR/view/smarty3 ]; then - chmod -R 777 $WORKDIR/view/smarty3 - fi - - # the stable packages already have the whole vendor stuff in their images - if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then - composer install - 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 - - log 'Installing Friendica' - - copy_sources - - if [ ! -f ${WORKDIR}/.htconfig.php ] && - [ -f ${SOURCEDIR}/config/htconfig.php ] && - [ "$AUTOINSTALL" = "true" ]; then - if check_database; then - run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php" - console autoinstall -f .htconfig.php - # TODO Workaround because of a strange permission issue - rm -fr ${WORKDIR}/view/smarty3/compiled - fi - fi -} - -update() { - if [ ! -f ${WORKDIR}/VERSION ]; then - # We want to update a given installation - # if there is no installation, exit - return - fi - - log 'Upgrading Friendica' - - copy_sources - - console dbstructure update -} - -configmail() { - if [ "$SMTP" = "localhost" ]; then - # SMTP is a required setting - # do nothing if it is "localhost" (= not changed) - return - fi - - sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd - sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd - - # add possible mail-senders - echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases - echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases - - # replace ssmtp.conf settings - cat << EOF > /etc/ssmtp/ssmtp.conf -# /etc/ssmtp/ssmtp.conf - -root=$SMTP_FROM@$HOSTNAME -hostname=$HOSTNAME -mailhub=$SMTP -FromLineOverride=YES -EOF - [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf -} - -if [ "$#" -eq 0 ]; then - friendica_help - exit 0 -fi - -case "$1" in - install) shift; install $@;; - update) shift; update $@ ;; - console) shift; console $@ ;; - composer) shift; composer $@ ;; - configmail) shift; configmail $@ ;; - *) friendica_help ;; -esac diff --git a/2018.05/fpm-alpine/config/htconfig.php b/2018.05/fpm-alpine/config/htconfig.php deleted file mode 100644 index 4b67aa8..0000000 --- a/2018.05/fpm-alpine/config/htconfig.php +++ /dev/null @@ -1,137 +0,0 @@ -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; - -if (!empty(getenv('VALIDATION'))) { - $a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION')); - $a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION')); -} - -if (!empty(getenv('CACHE_DRIVER'))) { - $a->config['system']['cache_driver'] = strtolower(getenv('CACHE_DRIVER')); - - if (!empty(getenv('REDIS_HOST'))) { - $a->config['system']['redis_host'] = getenv('REDIS_HOST'); - } - - if (!empty(getenv('REDIS_PORT'))) { - $a->config['system']['redis_port'] = getenv('REDIS_PORT'); - } - - if (!empty(getenv('MEMCACHE_HOST'))) { - $a->config['system']['memcache_host'] = getenv('MEMCACHE_HOST'); - } - - if (!empty(getenv('MEMCACHE_PORT'))) { - $a->config['system']['memcache_port'] = getenv('MEMCACHE_PORT'); - } - - if (!empty(getenv('MEMCACHED_HOSTS'))) { - $a->config['system']['memcached_hosts'] = getenv('MEMCACHED_HOSTS'); - } -} \ No newline at end of file diff --git a/2018.05/fpm-alpine/cron.sh b/2018.05/fpm-alpine/cron.sh deleted file mode 100644 index 8c29dee..0000000 --- a/2018.05/fpm-alpine/cron.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -trap "break;exit" HUP INT TERM - -while [ ! -f /var/www/html/.htconfig.php ]; do - sleep 1 -done - -while true; do - php -f /var/www/html/bin/worker.php - sleep 10m -done \ No newline at end of file diff --git a/2018.05/fpm-alpine/entrypoint.sh b/2018.05/fpm-alpine/entrypoint.sh deleted file mode 100644 index 8b75f8d..0000000 --- a/2018.05/fpm-alpine/entrypoint.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -eu - -friendica install -q -friendica configmail -q - -exec "$@" \ No newline at end of file diff --git a/2018.05/fpm/bin/friendica b/2018.05/fpm/bin/friendica deleted file mode 100644 index e9abd27..0000000 --- a/2018.05/fpm/bin/friendica +++ /dev/null @@ -1,278 +0,0 @@ -#!/bin/sh -set -eu - -SMTP=${SMTP:-localhost} -SMTP_FROM=${SMTP_FROM:-no-reply} - -SOURCEDIR=${SOURCEDIR:-/usr/src} -WORKDIR=${WORKDIR:-/var/www/html} - -SMTP_TLS=${SMTP_TLS:-} -SMTP_STARTTLS=${SMTP_STARTTLS:-} -SMTP_AUTH_USER=${SMTP_AUTH_USER:-} -SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-} -SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-} - -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)" -eq 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}" - - friendica_git=$friendica - addons_git=$addons - if echo "$friendica" | grep -Eq '^.*\-dev'; then - friendica_git="develop" - fi - - if echo "$addons" | grep -Eq '^.*\-dev'; then - addons_git="develop" - fi - - log 'Cloning Friendica '\'$friendica_git\'' with Addons '\'$addons_git\'' into '\'$dir\' - - # Removing the whole directory first - rm -fr $dir/friendica - - sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica ${dir}/friendica" - mkdir $dir/friendica/addon - sh -c "git clone -q -b ${addons_git} 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 -} - -check_database() { - TERM=dumb php -- <<'EOPHP' - -EOPHP -} - -# executes the Friendica console -console() { - if [ -f $WORKDIR/bin/console.php ]; then - cd $WORKDIR - php $WORKDIR/bin/console.php "$@" - fi -} - -# 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" - elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then - cd $SOURCEDIR/friendica - $SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica - fi -} - -copy_sources() { - installed_version="0.0.0.0" - if [ -f ${WORKDIR}/VERSION ]; then - installed_version="$(cat ${WORKDIR}/VERSION)" - fi - - if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; 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" || - echo "$image_version" | grep -Eq '^.*\-dev|-rc'; then - if [ "$(id -u)" -eq 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' --exclude='photo' --exclude='proxy' --exclude='.htconfig.php' --exclude='home.*' $SOURCEDIR/friendica/ $WORKDIR/ - - if [ -f $WORKDIR/view/smarty3 ]; then - chmod -R 777 $WORKDIR/view/smarty3 - fi - - # the stable packages already have the whole vendor stuff in their images - if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then - composer install - 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 - - log 'Installing Friendica' - - copy_sources - - if [ ! -f ${WORKDIR}/.htconfig.php ] && - [ -f ${SOURCEDIR}/config/htconfig.php ] && - [ "$AUTOINSTALL" = "true" ]; then - if check_database; then - run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php" - console autoinstall -f .htconfig.php - # TODO Workaround because of a strange permission issue - rm -fr ${WORKDIR}/view/smarty3/compiled - fi - fi -} - -update() { - if [ ! -f ${WORKDIR}/VERSION ]; then - # We want to update a given installation - # if there is no installation, exit - return - fi - - log 'Upgrading Friendica' - - copy_sources - - console dbstructure update -} - -configmail() { - if [ "$SMTP" = "localhost" ]; then - # SMTP is a required setting - # do nothing if it is "localhost" (= not changed) - return - fi - - sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd - sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd - - # add possible mail-senders - echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases - echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases - - # replace ssmtp.conf settings - cat << EOF > /etc/ssmtp/ssmtp.conf -# /etc/ssmtp/ssmtp.conf - -root=$SMTP_FROM@$HOSTNAME -hostname=$HOSTNAME -mailhub=$SMTP -FromLineOverride=YES -EOF - [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf -} - -if [ "$#" -eq 0 ]; then - friendica_help - exit 0 -fi - -case "$1" in - install) shift; install $@;; - update) shift; update $@ ;; - console) shift; console $@ ;; - composer) shift; composer $@ ;; - configmail) shift; configmail $@ ;; - *) friendica_help ;; -esac diff --git a/2018.05/fpm/config/htconfig.php b/2018.05/fpm/config/htconfig.php deleted file mode 100644 index 4b67aa8..0000000 --- a/2018.05/fpm/config/htconfig.php +++ /dev/null @@ -1,137 +0,0 @@ -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; - -if (!empty(getenv('VALIDATION'))) { - $a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION')); - $a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION')); -} - -if (!empty(getenv('CACHE_DRIVER'))) { - $a->config['system']['cache_driver'] = strtolower(getenv('CACHE_DRIVER')); - - if (!empty(getenv('REDIS_HOST'))) { - $a->config['system']['redis_host'] = getenv('REDIS_HOST'); - } - - if (!empty(getenv('REDIS_PORT'))) { - $a->config['system']['redis_port'] = getenv('REDIS_PORT'); - } - - if (!empty(getenv('MEMCACHE_HOST'))) { - $a->config['system']['memcache_host'] = getenv('MEMCACHE_HOST'); - } - - if (!empty(getenv('MEMCACHE_PORT'))) { - $a->config['system']['memcache_port'] = getenv('MEMCACHE_PORT'); - } - - if (!empty(getenv('MEMCACHED_HOSTS'))) { - $a->config['system']['memcached_hosts'] = getenv('MEMCACHED_HOSTS'); - } -} \ No newline at end of file diff --git a/2018.05/fpm/cron.sh b/2018.05/fpm/cron.sh deleted file mode 100644 index 8c29dee..0000000 --- a/2018.05/fpm/cron.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -trap "break;exit" HUP INT TERM - -while [ ! -f /var/www/html/.htconfig.php ]; do - sleep 1 -done - -while true; do - php -f /var/www/html/bin/worker.php - sleep 10m -done \ No newline at end of file diff --git a/2018.05/fpm/entrypoint.sh b/2018.05/fpm/entrypoint.sh deleted file mode 100644 index 8b75f8d..0000000 --- a/2018.05/fpm/entrypoint.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -eu - -friendica install -q -friendica configmail -q - -exec "$@" \ No newline at end of file diff --git a/2018.08-dev/apache/bin/friendica b/2018.08-dev/apache/bin/friendica deleted file mode 100644 index e9abd27..0000000 --- a/2018.08-dev/apache/bin/friendica +++ /dev/null @@ -1,278 +0,0 @@ -#!/bin/sh -set -eu - -SMTP=${SMTP:-localhost} -SMTP_FROM=${SMTP_FROM:-no-reply} - -SOURCEDIR=${SOURCEDIR:-/usr/src} -WORKDIR=${WORKDIR:-/var/www/html} - -SMTP_TLS=${SMTP_TLS:-} -SMTP_STARTTLS=${SMTP_STARTTLS:-} -SMTP_AUTH_USER=${SMTP_AUTH_USER:-} -SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-} -SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-} - -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)" -eq 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}" - - friendica_git=$friendica - addons_git=$addons - if echo "$friendica" | grep -Eq '^.*\-dev'; then - friendica_git="develop" - fi - - if echo "$addons" | grep -Eq '^.*\-dev'; then - addons_git="develop" - fi - - log 'Cloning Friendica '\'$friendica_git\'' with Addons '\'$addons_git\'' into '\'$dir\' - - # Removing the whole directory first - rm -fr $dir/friendica - - sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica ${dir}/friendica" - mkdir $dir/friendica/addon - sh -c "git clone -q -b ${addons_git} 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 -} - -check_database() { - TERM=dumb php -- <<'EOPHP' - -EOPHP -} - -# executes the Friendica console -console() { - if [ -f $WORKDIR/bin/console.php ]; then - cd $WORKDIR - php $WORKDIR/bin/console.php "$@" - fi -} - -# 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" - elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then - cd $SOURCEDIR/friendica - $SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica - fi -} - -copy_sources() { - installed_version="0.0.0.0" - if [ -f ${WORKDIR}/VERSION ]; then - installed_version="$(cat ${WORKDIR}/VERSION)" - fi - - if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; 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" || - echo "$image_version" | grep -Eq '^.*\-dev|-rc'; then - if [ "$(id -u)" -eq 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' --exclude='photo' --exclude='proxy' --exclude='.htconfig.php' --exclude='home.*' $SOURCEDIR/friendica/ $WORKDIR/ - - if [ -f $WORKDIR/view/smarty3 ]; then - chmod -R 777 $WORKDIR/view/smarty3 - fi - - # the stable packages already have the whole vendor stuff in their images - if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then - composer install - 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 - - log 'Installing Friendica' - - copy_sources - - if [ ! -f ${WORKDIR}/.htconfig.php ] && - [ -f ${SOURCEDIR}/config/htconfig.php ] && - [ "$AUTOINSTALL" = "true" ]; then - if check_database; then - run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php" - console autoinstall -f .htconfig.php - # TODO Workaround because of a strange permission issue - rm -fr ${WORKDIR}/view/smarty3/compiled - fi - fi -} - -update() { - if [ ! -f ${WORKDIR}/VERSION ]; then - # We want to update a given installation - # if there is no installation, exit - return - fi - - log 'Upgrading Friendica' - - copy_sources - - console dbstructure update -} - -configmail() { - if [ "$SMTP" = "localhost" ]; then - # SMTP is a required setting - # do nothing if it is "localhost" (= not changed) - return - fi - - sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd - sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd - - # add possible mail-senders - echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases - echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases - - # replace ssmtp.conf settings - cat << EOF > /etc/ssmtp/ssmtp.conf -# /etc/ssmtp/ssmtp.conf - -root=$SMTP_FROM@$HOSTNAME -hostname=$HOSTNAME -mailhub=$SMTP -FromLineOverride=YES -EOF - [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf -} - -if [ "$#" -eq 0 ]; then - friendica_help - exit 0 -fi - -case "$1" in - install) shift; install $@;; - update) shift; update $@ ;; - console) shift; console $@ ;; - composer) shift; composer $@ ;; - configmail) shift; configmail $@ ;; - *) friendica_help ;; -esac diff --git a/2018.08-dev/apache/config/htconfig.php b/2018.08-dev/apache/config/htconfig.php deleted file mode 100644 index 4b67aa8..0000000 --- a/2018.08-dev/apache/config/htconfig.php +++ /dev/null @@ -1,137 +0,0 @@ -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; - -if (!empty(getenv('VALIDATION'))) { - $a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION')); - $a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION')); -} - -if (!empty(getenv('CACHE_DRIVER'))) { - $a->config['system']['cache_driver'] = strtolower(getenv('CACHE_DRIVER')); - - if (!empty(getenv('REDIS_HOST'))) { - $a->config['system']['redis_host'] = getenv('REDIS_HOST'); - } - - if (!empty(getenv('REDIS_PORT'))) { - $a->config['system']['redis_port'] = getenv('REDIS_PORT'); - } - - if (!empty(getenv('MEMCACHE_HOST'))) { - $a->config['system']['memcache_host'] = getenv('MEMCACHE_HOST'); - } - - if (!empty(getenv('MEMCACHE_PORT'))) { - $a->config['system']['memcache_port'] = getenv('MEMCACHE_PORT'); - } - - if (!empty(getenv('MEMCACHED_HOSTS'))) { - $a->config['system']['memcached_hosts'] = getenv('MEMCACHED_HOSTS'); - } -} \ No newline at end of file diff --git a/2018.08-dev/apache/cron.sh b/2018.08-dev/apache/cron.sh deleted file mode 100644 index 8c29dee..0000000 --- a/2018.08-dev/apache/cron.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -trap "break;exit" HUP INT TERM - -while [ ! -f /var/www/html/.htconfig.php ]; do - sleep 1 -done - -while true; do - php -f /var/www/html/bin/worker.php - sleep 10m -done \ No newline at end of file diff --git a/2018.08-dev/apache/entrypoint.sh b/2018.08-dev/apache/entrypoint.sh deleted file mode 100644 index 8b75f8d..0000000 --- a/2018.08-dev/apache/entrypoint.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -eu - -friendica install -q -friendica configmail -q - -exec "$@" \ No newline at end of file diff --git a/2018.08-dev/fpm-alpine/bin/friendica b/2018.08-dev/fpm-alpine/bin/friendica deleted file mode 100644 index e9abd27..0000000 --- a/2018.08-dev/fpm-alpine/bin/friendica +++ /dev/null @@ -1,278 +0,0 @@ -#!/bin/sh -set -eu - -SMTP=${SMTP:-localhost} -SMTP_FROM=${SMTP_FROM:-no-reply} - -SOURCEDIR=${SOURCEDIR:-/usr/src} -WORKDIR=${WORKDIR:-/var/www/html} - -SMTP_TLS=${SMTP_TLS:-} -SMTP_STARTTLS=${SMTP_STARTTLS:-} -SMTP_AUTH_USER=${SMTP_AUTH_USER:-} -SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-} -SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-} - -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)" -eq 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}" - - friendica_git=$friendica - addons_git=$addons - if echo "$friendica" | grep -Eq '^.*\-dev'; then - friendica_git="develop" - fi - - if echo "$addons" | grep -Eq '^.*\-dev'; then - addons_git="develop" - fi - - log 'Cloning Friendica '\'$friendica_git\'' with Addons '\'$addons_git\'' into '\'$dir\' - - # Removing the whole directory first - rm -fr $dir/friendica - - sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica ${dir}/friendica" - mkdir $dir/friendica/addon - sh -c "git clone -q -b ${addons_git} 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 -} - -check_database() { - TERM=dumb php -- <<'EOPHP' - -EOPHP -} - -# executes the Friendica console -console() { - if [ -f $WORKDIR/bin/console.php ]; then - cd $WORKDIR - php $WORKDIR/bin/console.php "$@" - fi -} - -# 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" - elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then - cd $SOURCEDIR/friendica - $SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica - fi -} - -copy_sources() { - installed_version="0.0.0.0" - if [ -f ${WORKDIR}/VERSION ]; then - installed_version="$(cat ${WORKDIR}/VERSION)" - fi - - if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; 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" || - echo "$image_version" | grep -Eq '^.*\-dev|-rc'; then - if [ "$(id -u)" -eq 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' --exclude='photo' --exclude='proxy' --exclude='.htconfig.php' --exclude='home.*' $SOURCEDIR/friendica/ $WORKDIR/ - - if [ -f $WORKDIR/view/smarty3 ]; then - chmod -R 777 $WORKDIR/view/smarty3 - fi - - # the stable packages already have the whole vendor stuff in their images - if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then - composer install - 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 - - log 'Installing Friendica' - - copy_sources - - if [ ! -f ${WORKDIR}/.htconfig.php ] && - [ -f ${SOURCEDIR}/config/htconfig.php ] && - [ "$AUTOINSTALL" = "true" ]; then - if check_database; then - run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php" - console autoinstall -f .htconfig.php - # TODO Workaround because of a strange permission issue - rm -fr ${WORKDIR}/view/smarty3/compiled - fi - fi -} - -update() { - if [ ! -f ${WORKDIR}/VERSION ]; then - # We want to update a given installation - # if there is no installation, exit - return - fi - - log 'Upgrading Friendica' - - copy_sources - - console dbstructure update -} - -configmail() { - if [ "$SMTP" = "localhost" ]; then - # SMTP is a required setting - # do nothing if it is "localhost" (= not changed) - return - fi - - sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd - sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd - - # add possible mail-senders - echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases - echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases - - # replace ssmtp.conf settings - cat << EOF > /etc/ssmtp/ssmtp.conf -# /etc/ssmtp/ssmtp.conf - -root=$SMTP_FROM@$HOSTNAME -hostname=$HOSTNAME -mailhub=$SMTP -FromLineOverride=YES -EOF - [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf -} - -if [ "$#" -eq 0 ]; then - friendica_help - exit 0 -fi - -case "$1" in - install) shift; install $@;; - update) shift; update $@ ;; - console) shift; console $@ ;; - composer) shift; composer $@ ;; - configmail) shift; configmail $@ ;; - *) friendica_help ;; -esac diff --git a/2018.08-dev/fpm-alpine/config/htconfig.php b/2018.08-dev/fpm-alpine/config/htconfig.php deleted file mode 100644 index 4b67aa8..0000000 --- a/2018.08-dev/fpm-alpine/config/htconfig.php +++ /dev/null @@ -1,137 +0,0 @@ -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; - -if (!empty(getenv('VALIDATION'))) { - $a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION')); - $a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION')); -} - -if (!empty(getenv('CACHE_DRIVER'))) { - $a->config['system']['cache_driver'] = strtolower(getenv('CACHE_DRIVER')); - - if (!empty(getenv('REDIS_HOST'))) { - $a->config['system']['redis_host'] = getenv('REDIS_HOST'); - } - - if (!empty(getenv('REDIS_PORT'))) { - $a->config['system']['redis_port'] = getenv('REDIS_PORT'); - } - - if (!empty(getenv('MEMCACHE_HOST'))) { - $a->config['system']['memcache_host'] = getenv('MEMCACHE_HOST'); - } - - if (!empty(getenv('MEMCACHE_PORT'))) { - $a->config['system']['memcache_port'] = getenv('MEMCACHE_PORT'); - } - - if (!empty(getenv('MEMCACHED_HOSTS'))) { - $a->config['system']['memcached_hosts'] = getenv('MEMCACHED_HOSTS'); - } -} \ No newline at end of file diff --git a/2018.08-dev/fpm-alpine/cron.sh b/2018.08-dev/fpm-alpine/cron.sh deleted file mode 100644 index 8c29dee..0000000 --- a/2018.08-dev/fpm-alpine/cron.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -trap "break;exit" HUP INT TERM - -while [ ! -f /var/www/html/.htconfig.php ]; do - sleep 1 -done - -while true; do - php -f /var/www/html/bin/worker.php - sleep 10m -done \ No newline at end of file diff --git a/2018.08-dev/fpm-alpine/entrypoint.sh b/2018.08-dev/fpm-alpine/entrypoint.sh deleted file mode 100644 index 8b75f8d..0000000 --- a/2018.08-dev/fpm-alpine/entrypoint.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -eu - -friendica install -q -friendica configmail -q - -exec "$@" \ No newline at end of file diff --git a/2018.08-dev/fpm/bin/friendica b/2018.08-dev/fpm/bin/friendica deleted file mode 100644 index e9abd27..0000000 --- a/2018.08-dev/fpm/bin/friendica +++ /dev/null @@ -1,278 +0,0 @@ -#!/bin/sh -set -eu - -SMTP=${SMTP:-localhost} -SMTP_FROM=${SMTP_FROM:-no-reply} - -SOURCEDIR=${SOURCEDIR:-/usr/src} -WORKDIR=${WORKDIR:-/var/www/html} - -SMTP_TLS=${SMTP_TLS:-} -SMTP_STARTTLS=${SMTP_STARTTLS:-} -SMTP_AUTH_USER=${SMTP_AUTH_USER:-} -SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-} -SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-} - -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)" -eq 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}" - - friendica_git=$friendica - addons_git=$addons - if echo "$friendica" | grep -Eq '^.*\-dev'; then - friendica_git="develop" - fi - - if echo "$addons" | grep -Eq '^.*\-dev'; then - addons_git="develop" - fi - - log 'Cloning Friendica '\'$friendica_git\'' with Addons '\'$addons_git\'' into '\'$dir\' - - # Removing the whole directory first - rm -fr $dir/friendica - - sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica ${dir}/friendica" - mkdir $dir/friendica/addon - sh -c "git clone -q -b ${addons_git} 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 -} - -check_database() { - TERM=dumb php -- <<'EOPHP' - -EOPHP -} - -# executes the Friendica console -console() { - if [ -f $WORKDIR/bin/console.php ]; then - cd $WORKDIR - php $WORKDIR/bin/console.php "$@" - fi -} - -# 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" - elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then - cd $SOURCEDIR/friendica - $SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica - fi -} - -copy_sources() { - installed_version="0.0.0.0" - if [ -f ${WORKDIR}/VERSION ]; then - installed_version="$(cat ${WORKDIR}/VERSION)" - fi - - if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; 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" || - echo "$image_version" | grep -Eq '^.*\-dev|-rc'; then - if [ "$(id -u)" -eq 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' --exclude='photo' --exclude='proxy' --exclude='.htconfig.php' --exclude='home.*' $SOURCEDIR/friendica/ $WORKDIR/ - - if [ -f $WORKDIR/view/smarty3 ]; then - chmod -R 777 $WORKDIR/view/smarty3 - fi - - # the stable packages already have the whole vendor stuff in their images - if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then - composer install - 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 - - log 'Installing Friendica' - - copy_sources - - if [ ! -f ${WORKDIR}/.htconfig.php ] && - [ -f ${SOURCEDIR}/config/htconfig.php ] && - [ "$AUTOINSTALL" = "true" ]; then - if check_database; then - run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php" - console autoinstall -f .htconfig.php - # TODO Workaround because of a strange permission issue - rm -fr ${WORKDIR}/view/smarty3/compiled - fi - fi -} - -update() { - if [ ! -f ${WORKDIR}/VERSION ]; then - # We want to update a given installation - # if there is no installation, exit - return - fi - - log 'Upgrading Friendica' - - copy_sources - - console dbstructure update -} - -configmail() { - if [ "$SMTP" = "localhost" ]; then - # SMTP is a required setting - # do nothing if it is "localhost" (= not changed) - return - fi - - sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd - sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd - - # add possible mail-senders - echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases - echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases - - # replace ssmtp.conf settings - cat << EOF > /etc/ssmtp/ssmtp.conf -# /etc/ssmtp/ssmtp.conf - -root=$SMTP_FROM@$HOSTNAME -hostname=$HOSTNAME -mailhub=$SMTP -FromLineOverride=YES -EOF - [ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf - [ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf -} - -if [ "$#" -eq 0 ]; then - friendica_help - exit 0 -fi - -case "$1" in - install) shift; install $@;; - update) shift; update $@ ;; - console) shift; console $@ ;; - composer) shift; composer $@ ;; - configmail) shift; configmail $@ ;; - *) friendica_help ;; -esac diff --git a/2018.08-dev/fpm/config/htconfig.php b/2018.08-dev/fpm/config/htconfig.php deleted file mode 100644 index 4b67aa8..0000000 --- a/2018.08-dev/fpm/config/htconfig.php +++ /dev/null @@ -1,137 +0,0 @@ -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; - -if (!empty(getenv('VALIDATION'))) { - $a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION')); - $a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION')); -} - -if (!empty(getenv('CACHE_DRIVER'))) { - $a->config['system']['cache_driver'] = strtolower(getenv('CACHE_DRIVER')); - - if (!empty(getenv('REDIS_HOST'))) { - $a->config['system']['redis_host'] = getenv('REDIS_HOST'); - } - - if (!empty(getenv('REDIS_PORT'))) { - $a->config['system']['redis_port'] = getenv('REDIS_PORT'); - } - - if (!empty(getenv('MEMCACHE_HOST'))) { - $a->config['system']['memcache_host'] = getenv('MEMCACHE_HOST'); - } - - if (!empty(getenv('MEMCACHE_PORT'))) { - $a->config['system']['memcache_port'] = getenv('MEMCACHE_PORT'); - } - - if (!empty(getenv('MEMCACHED_HOSTS'))) { - $a->config['system']['memcached_hosts'] = getenv('MEMCACHED_HOSTS'); - } -} \ No newline at end of file diff --git a/2018.08-dev/fpm/cron.sh b/2018.08-dev/fpm/cron.sh deleted file mode 100644 index 8c29dee..0000000 --- a/2018.08-dev/fpm/cron.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -trap "break;exit" HUP INT TERM - -while [ ! -f /var/www/html/.htconfig.php ]; do - sleep 1 -done - -while true; do - php -f /var/www/html/bin/worker.php - sleep 10m -done \ No newline at end of file diff --git a/2018.08-dev/fpm/entrypoint.sh b/2018.08-dev/fpm/entrypoint.sh deleted file mode 100644 index 8b75f8d..0000000 --- a/2018.08-dev/fpm/entrypoint.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -eu - -friendica install -q -friendica configmail -q - -exec "$@" \ No newline at end of file diff --git a/2018.05/apache/Dockerfile b/2018.09/apache/Dockerfile similarity index 92% rename from 2018.05/apache/Dockerfile rename to 2018.09/apache/Dockerfile index 79bd022..a4d4d2f 100644 --- a/2018.05/apache/Dockerfile +++ b/2018.09/apache/Dockerfile @@ -10,8 +10,6 @@ RUN set -ex; \ rsync \ bzip2 \ git \ -# For mail() support - ssmtp \ ; \ rm -rf /var/lib/apt/lists/*; @@ -88,6 +86,7 @@ RUN chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html +WORKDIR /var/www/html RUN a2enmod rewrite remoteip ;\ {\ @@ -102,18 +101,11 @@ RUN {\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ } > /usr/local/etc/php/conf.d/sendmail.ini; -ENV AUTOINSTALL false -ENV VALIDATION true -ENV SITENAME "Friendica Social Network" - -ENV FRIENDICA_VERSION 2018.05 -ENV FRIENDICA_ADDONS 2018.05 - -COPY bin/* /usr/local/bin/ -COPY config/* /usr/src/config/ -COPY *.sh / +COPY *.sh upgrade.exclude / RUN chmod +x /*.sh -RUN chmod +x /usr/local/bin/* + +ENV FRIENDICA_VERSION 2018.09 +ENV FRIENDICA_ADDONS 2018.09 RUN set -ex; \ curl -fsSL -o friendica.tar.gz \ @@ -127,7 +119,7 @@ RUN set -ex; \ mkdir /usr/src/friendica/addon; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ rm friendica_addons.tar.gz; \ - friendica composer install; + /usr/src/friendica/bin/composer.phar install --no-plugins --no-scripts --no-dev -d /usr/src/friendica; ENTRYPOINT ["/entrypoint.sh"] CMD ["apache2-foreground"] diff --git a/2018.09/apache/cron.sh b/2018.09/apache/cron.sh new file mode 100644 index 0000000..ce4d3ae --- /dev/null +++ b/2018.09/apache/cron.sh @@ -0,0 +1,11 @@ +#!/bin/sh +trap "break;exit" HUP INT TERM + +while [ ! -f /var/www/html/config/local.ini.php ]; do + sleep 1 +done + +# TODO let the database and the autoinstall time to complete - not winning a beauty contest +sleep 15s + +php /var/www/html/bin/daemon.php -f start diff --git a/2018.09/apache/entrypoint.sh b/2018.09/apache/entrypoint.sh new file mode 100644 index 0000000..ab38907 --- /dev/null +++ b/2018.09/apache/entrypoint.sh @@ -0,0 +1,171 @@ +#!/bin/sh +set -eu + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" -eq 0 ]; then + su - www-data -s /bin/sh -c "cd /var/www/html;$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" ] +} + +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + friendica_git="${FRIENDICA_VERSION}" + addons_git="${FRIENDICA_ADDONS}" + + if echo "$friendica_git" | grep -Eq '^.*\-dev'; then + friendica_git="develop" + fi + + if echo "$addons_git" | grep -Eq '^.*\-dev'; then + addons_git="develop" + fi + + echo "Downloading Friendica from GitHub '${friendica_git}' ..." + + # Removing the whole directory first + rm -fr /usr/src/friendica + sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica /usr/src/friendica" + + mkdir /usr/src/friendica/addon + sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons /usr/src/friendica/addon" + + echo "Download finished" + + /usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica +} + +# just check if we execute apache or php-fpm +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/VERSION ]; then + installed_version="$(cat /var/www/html/VERSION)" + fi + + check=false + # cloning from git is just possible for develop or Release Candidats + if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then + # just clone & check if it's a new install or upgrade + if [ "$installed_version" = "0.0.0.0" ] || [ "$FRIENDICA_UPGRADE" = "true" ]; then + clone_develop + image_version="$(cat /usr/src/friendica/VERSION)" + check=true + fi + else + image_version="$(cat /usr/src/friendica/VERSION)" + + # check it just in case the version is greater + if version_greater "$image_version" "$installed_version"; then + check=true + fi + + # no downgrading possible + 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')', 0 + exit 1; + fi + fi + + if [ "$check" = true ]; then + echo "Initializing Friendica $image_version ..." + + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading Friendica from $installed_version ..." + fi + + if [ "$(id -u)" -eq 0 ]; then + rsync_options="-rlDog --chown=www-data:www-data" + else + rsync_options="-rlD" + fi + + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/ + + # copy every *.ini.php from the config directory except they are already copied (in case of an upgrade) + for dir in config; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/ + fi + done + + # In case there is no .htaccess, copy it from the default dist file + if [ ! -f "/var/www/html/.htaccess" ]; then + cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess" + fi + + if [ -d /var/www/html/view/smarty3 ]; then + chmod -R 777 /var/www/html/view/smarty3 + fi + echo "Initializing finished" + + # install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New Friendica instance" + + install=false + if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then + echo "Installation with environment variables" + + # TODO Bug in PHP Path for automatic installation + #FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php} + FRIENDICA_TZ=${FRIENDICA_TZ:-America/LosAngeles} + FRIENDICA_LANG=${FRIENDICA_LANG:-en} + MYSQL_PORT=${MYSQL_PORT:-3306} + if [ -n "${MYSQL_USER+x}" ]; then + MYSQL_USERNAMEFULL=${MYSQL_USER} + else + MYSQL_USERNAMEFULL=${MYSQL_USERNAME} + fi + + # shellcheck disable=SC2016 + install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"' + + # shellcheck disable=SC2016 + install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"' + install=true + elif [ -f "/usr/src/config/local.ini.php" ]; then + echo "Installation with prepared local.ini.php" + + install_options="-f /usr/src/local.ini.php" + install=true + fi + + if [ "$install" = true ]; then + echo "Starting Friendica installation ..." + # TODO Let the database time to warm up - not winning a beauty contest + sleep 10s + run_as "/var/www/html/bin/console autoinstall $install_options" + + # TODO Workaround because of a strange permission issue + rm -fr /var/www/html/view/smarty3/compiled + + # load other config files (*.ini.php) to the config folder (currently only local.ini.php and addon.ini.php supported) + if [ -d "/usr/src/config" ]; then + rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/ + fi + + echo "Installation finished" + else + echo "Running web-based installer on first connect!" + fi + # upgrade + else + echo "Upgrading Friendica ..." + run_as '/var/www/html/bin/console dbstructure update' + echo "Upgrading finished" + fi + fi +fi + +exec "$@" diff --git a/2018.09/apache/upgrade.exclude b/2018.09/apache/upgrade.exclude new file mode 100644 index 0000000..732ba58 --- /dev/null +++ b/2018.09/apache/upgrade.exclude @@ -0,0 +1,7 @@ +/.git/ +/photo/ +/proxy/ +.htconfig.php +.htaccess +home.* +/config/ \ No newline at end of file diff --git a/2018.05/fpm-alpine/Dockerfile b/2018.09/fpm-alpine/Dockerfile similarity index 87% rename from 2018.05/fpm-alpine/Dockerfile rename to 2018.09/fpm-alpine/Dockerfile index 5123160..480987c 100644 --- a/2018.05/fpm-alpine/Dockerfile +++ b/2018.09/fpm-alpine/Dockerfile @@ -6,9 +6,7 @@ LABEL maintainer="Philipp Holzer " RUN set -ex; \ apk add --no-cache \ rsync \ - git \ - # For mail() support - ssmtp; + git; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ @@ -21,8 +19,8 @@ RUN set -ex; \ autoconf \ g++ \ make \ - openssl \ - openssl-dev \ + libressl \ + libressl-dev \ libpng \ libpng-dev \ libjpeg-turbo-dev \ @@ -75,28 +73,22 @@ RUN set -ex; \ apk add --virtual .friendica-phpext-rundeps $runDeps; \ apk del .build-deps; -RUN chown -R www-data:root /var/www; \ +RUN chown -R www-data:www-data /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html +WORKDIR /var/www/html RUN {\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ } > /usr/local/etc/php/conf.d/sendmail.ini; -ENV AUTOINSTALL false -ENV VALIDATION true -ENV SITENAME "Friendica Social Network" - -ENV FRIENDICA_VERSION 2018.05 -ENV FRIENDICA_ADDONS 2018.05 - -COPY bin/* /usr/local/bin/ -COPY config/* /usr/src/config/ -COPY *.sh / +COPY *.sh upgrade.exclude / RUN chmod +x /*.sh -RUN chmod +x /usr/local/bin/* + +ENV FRIENDICA_VERSION 2018.09 +ENV FRIENDICA_ADDONS 2018.09 RUN set -ex; \ curl -fsSL -o friendica.tar.gz \ @@ -110,7 +102,7 @@ RUN set -ex; \ mkdir /usr/src/friendica/addon; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ rm friendica_addons.tar.gz; \ - friendica composer install; + /usr/src/friendica/bin/composer.phar install --no-plugins --no-scripts --no-dev -d /usr/src/friendica; ENTRYPOINT ["/entrypoint.sh"] -CMD ["php-fpm"] \ No newline at end of file +CMD ["php-fpm"] diff --git a/2018.09/fpm-alpine/cron.sh b/2018.09/fpm-alpine/cron.sh new file mode 100644 index 0000000..ce4d3ae --- /dev/null +++ b/2018.09/fpm-alpine/cron.sh @@ -0,0 +1,11 @@ +#!/bin/sh +trap "break;exit" HUP INT TERM + +while [ ! -f /var/www/html/config/local.ini.php ]; do + sleep 1 +done + +# TODO let the database and the autoinstall time to complete - not winning a beauty contest +sleep 15s + +php /var/www/html/bin/daemon.php -f start diff --git a/2018.09/fpm-alpine/entrypoint.sh b/2018.09/fpm-alpine/entrypoint.sh new file mode 100644 index 0000000..ab38907 --- /dev/null +++ b/2018.09/fpm-alpine/entrypoint.sh @@ -0,0 +1,171 @@ +#!/bin/sh +set -eu + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" -eq 0 ]; then + su - www-data -s /bin/sh -c "cd /var/www/html;$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" ] +} + +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + friendica_git="${FRIENDICA_VERSION}" + addons_git="${FRIENDICA_ADDONS}" + + if echo "$friendica_git" | grep -Eq '^.*\-dev'; then + friendica_git="develop" + fi + + if echo "$addons_git" | grep -Eq '^.*\-dev'; then + addons_git="develop" + fi + + echo "Downloading Friendica from GitHub '${friendica_git}' ..." + + # Removing the whole directory first + rm -fr /usr/src/friendica + sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica /usr/src/friendica" + + mkdir /usr/src/friendica/addon + sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons /usr/src/friendica/addon" + + echo "Download finished" + + /usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica +} + +# just check if we execute apache or php-fpm +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/VERSION ]; then + installed_version="$(cat /var/www/html/VERSION)" + fi + + check=false + # cloning from git is just possible for develop or Release Candidats + if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then + # just clone & check if it's a new install or upgrade + if [ "$installed_version" = "0.0.0.0" ] || [ "$FRIENDICA_UPGRADE" = "true" ]; then + clone_develop + image_version="$(cat /usr/src/friendica/VERSION)" + check=true + fi + else + image_version="$(cat /usr/src/friendica/VERSION)" + + # check it just in case the version is greater + if version_greater "$image_version" "$installed_version"; then + check=true + fi + + # no downgrading possible + 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')', 0 + exit 1; + fi + fi + + if [ "$check" = true ]; then + echo "Initializing Friendica $image_version ..." + + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading Friendica from $installed_version ..." + fi + + if [ "$(id -u)" -eq 0 ]; then + rsync_options="-rlDog --chown=www-data:www-data" + else + rsync_options="-rlD" + fi + + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/ + + # copy every *.ini.php from the config directory except they are already copied (in case of an upgrade) + for dir in config; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/ + fi + done + + # In case there is no .htaccess, copy it from the default dist file + if [ ! -f "/var/www/html/.htaccess" ]; then + cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess" + fi + + if [ -d /var/www/html/view/smarty3 ]; then + chmod -R 777 /var/www/html/view/smarty3 + fi + echo "Initializing finished" + + # install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New Friendica instance" + + install=false + if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then + echo "Installation with environment variables" + + # TODO Bug in PHP Path for automatic installation + #FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php} + FRIENDICA_TZ=${FRIENDICA_TZ:-America/LosAngeles} + FRIENDICA_LANG=${FRIENDICA_LANG:-en} + MYSQL_PORT=${MYSQL_PORT:-3306} + if [ -n "${MYSQL_USER+x}" ]; then + MYSQL_USERNAMEFULL=${MYSQL_USER} + else + MYSQL_USERNAMEFULL=${MYSQL_USERNAME} + fi + + # shellcheck disable=SC2016 + install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"' + + # shellcheck disable=SC2016 + install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"' + install=true + elif [ -f "/usr/src/config/local.ini.php" ]; then + echo "Installation with prepared local.ini.php" + + install_options="-f /usr/src/local.ini.php" + install=true + fi + + if [ "$install" = true ]; then + echo "Starting Friendica installation ..." + # TODO Let the database time to warm up - not winning a beauty contest + sleep 10s + run_as "/var/www/html/bin/console autoinstall $install_options" + + # TODO Workaround because of a strange permission issue + rm -fr /var/www/html/view/smarty3/compiled + + # load other config files (*.ini.php) to the config folder (currently only local.ini.php and addon.ini.php supported) + if [ -d "/usr/src/config" ]; then + rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/ + fi + + echo "Installation finished" + else + echo "Running web-based installer on first connect!" + fi + # upgrade + else + echo "Upgrading Friendica ..." + run_as '/var/www/html/bin/console dbstructure update' + echo "Upgrading finished" + fi + fi +fi + +exec "$@" diff --git a/2018.09/fpm-alpine/upgrade.exclude b/2018.09/fpm-alpine/upgrade.exclude new file mode 100644 index 0000000..732ba58 --- /dev/null +++ b/2018.09/fpm-alpine/upgrade.exclude @@ -0,0 +1,7 @@ +/.git/ +/photo/ +/proxy/ +.htconfig.php +.htaccess +home.* +/config/ \ No newline at end of file diff --git a/2018.05/fpm/Dockerfile b/2018.09/fpm/Dockerfile similarity index 91% rename from 2018.05/fpm/Dockerfile rename to 2018.09/fpm/Dockerfile index 23ce007..aad9214 100644 --- a/2018.05/fpm/Dockerfile +++ b/2018.09/fpm/Dockerfile @@ -10,8 +10,6 @@ RUN set -ex; \ rsync \ bzip2 \ git \ -# For mail() support - ssmtp \ ; \ rm -rf /var/lib/apt/lists/*; @@ -88,24 +86,18 @@ RUN chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html +WORKDIR /var/www/html RUN {\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ } > /usr/local/etc/php/conf.d/sendmail.ini; -ENV AUTOINSTALL false -ENV VALIDATION true -ENV SITENAME "Friendica Social Network" - -ENV FRIENDICA_VERSION 2018.05 -ENV FRIENDICA_ADDONS 2018.05 - -COPY bin/* /usr/local/bin/ -COPY config/* /usr/src/config/ -COPY *.sh / +COPY *.sh upgrade.exclude / RUN chmod +x /*.sh -RUN chmod +x /usr/local/bin/* + +ENV FRIENDICA_VERSION 2018.09 +ENV FRIENDICA_ADDONS 2018.09 RUN set -ex; \ curl -fsSL -o friendica.tar.gz \ @@ -119,7 +111,7 @@ RUN set -ex; \ mkdir /usr/src/friendica/addon; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ rm friendica_addons.tar.gz; \ - friendica composer install; + /usr/src/friendica/bin/composer.phar install --no-plugins --no-scripts --no-dev -d /usr/src/friendica; ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] diff --git a/2018.09/fpm/cron.sh b/2018.09/fpm/cron.sh new file mode 100644 index 0000000..ce4d3ae --- /dev/null +++ b/2018.09/fpm/cron.sh @@ -0,0 +1,11 @@ +#!/bin/sh +trap "break;exit" HUP INT TERM + +while [ ! -f /var/www/html/config/local.ini.php ]; do + sleep 1 +done + +# TODO let the database and the autoinstall time to complete - not winning a beauty contest +sleep 15s + +php /var/www/html/bin/daemon.php -f start diff --git a/2018.09/fpm/entrypoint.sh b/2018.09/fpm/entrypoint.sh new file mode 100644 index 0000000..ab38907 --- /dev/null +++ b/2018.09/fpm/entrypoint.sh @@ -0,0 +1,171 @@ +#!/bin/sh +set -eu + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" -eq 0 ]; then + su - www-data -s /bin/sh -c "cd /var/www/html;$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" ] +} + +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + friendica_git="${FRIENDICA_VERSION}" + addons_git="${FRIENDICA_ADDONS}" + + if echo "$friendica_git" | grep -Eq '^.*\-dev'; then + friendica_git="develop" + fi + + if echo "$addons_git" | grep -Eq '^.*\-dev'; then + addons_git="develop" + fi + + echo "Downloading Friendica from GitHub '${friendica_git}' ..." + + # Removing the whole directory first + rm -fr /usr/src/friendica + sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica /usr/src/friendica" + + mkdir /usr/src/friendica/addon + sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons /usr/src/friendica/addon" + + echo "Download finished" + + /usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica +} + +# just check if we execute apache or php-fpm +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/VERSION ]; then + installed_version="$(cat /var/www/html/VERSION)" + fi + + check=false + # cloning from git is just possible for develop or Release Candidats + if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then + # just clone & check if it's a new install or upgrade + if [ "$installed_version" = "0.0.0.0" ] || [ "$FRIENDICA_UPGRADE" = "true" ]; then + clone_develop + image_version="$(cat /usr/src/friendica/VERSION)" + check=true + fi + else + image_version="$(cat /usr/src/friendica/VERSION)" + + # check it just in case the version is greater + if version_greater "$image_version" "$installed_version"; then + check=true + fi + + # no downgrading possible + 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')', 0 + exit 1; + fi + fi + + if [ "$check" = true ]; then + echo "Initializing Friendica $image_version ..." + + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading Friendica from $installed_version ..." + fi + + if [ "$(id -u)" -eq 0 ]; then + rsync_options="-rlDog --chown=www-data:www-data" + else + rsync_options="-rlD" + fi + + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/ + + # copy every *.ini.php from the config directory except they are already copied (in case of an upgrade) + for dir in config; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/ + fi + done + + # In case there is no .htaccess, copy it from the default dist file + if [ ! -f "/var/www/html/.htaccess" ]; then + cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess" + fi + + if [ -d /var/www/html/view/smarty3 ]; then + chmod -R 777 /var/www/html/view/smarty3 + fi + echo "Initializing finished" + + # install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New Friendica instance" + + install=false + if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then + echo "Installation with environment variables" + + # TODO Bug in PHP Path for automatic installation + #FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php} + FRIENDICA_TZ=${FRIENDICA_TZ:-America/LosAngeles} + FRIENDICA_LANG=${FRIENDICA_LANG:-en} + MYSQL_PORT=${MYSQL_PORT:-3306} + if [ -n "${MYSQL_USER+x}" ]; then + MYSQL_USERNAMEFULL=${MYSQL_USER} + else + MYSQL_USERNAMEFULL=${MYSQL_USERNAME} + fi + + # shellcheck disable=SC2016 + install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"' + + # shellcheck disable=SC2016 + install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"' + install=true + elif [ -f "/usr/src/config/local.ini.php" ]; then + echo "Installation with prepared local.ini.php" + + install_options="-f /usr/src/local.ini.php" + install=true + fi + + if [ "$install" = true ]; then + echo "Starting Friendica installation ..." + # TODO Let the database time to warm up - not winning a beauty contest + sleep 10s + run_as "/var/www/html/bin/console autoinstall $install_options" + + # TODO Workaround because of a strange permission issue + rm -fr /var/www/html/view/smarty3/compiled + + # load other config files (*.ini.php) to the config folder (currently only local.ini.php and addon.ini.php supported) + if [ -d "/usr/src/config" ]; then + rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/ + fi + + echo "Installation finished" + else + echo "Running web-based installer on first connect!" + fi + # upgrade + else + echo "Upgrading Friendica ..." + run_as '/var/www/html/bin/console dbstructure update' + echo "Upgrading finished" + fi + fi +fi + +exec "$@" diff --git a/2018.09/fpm/upgrade.exclude b/2018.09/fpm/upgrade.exclude new file mode 100644 index 0000000..732ba58 --- /dev/null +++ b/2018.09/fpm/upgrade.exclude @@ -0,0 +1,7 @@ +/.git/ +/photo/ +/proxy/ +.htconfig.php +.htaccess +home.* +/config/ \ No newline at end of file diff --git a/2018.08-dev/apache/Dockerfile b/2018.12-dev/apache/Dockerfile similarity index 91% rename from 2018.08-dev/apache/Dockerfile rename to 2018.12-dev/apache/Dockerfile index 95e353f..fb1ee2f 100644 --- a/2018.08-dev/apache/Dockerfile +++ b/2018.12-dev/apache/Dockerfile @@ -10,8 +10,6 @@ RUN set -ex; \ rsync \ bzip2 \ git \ -# For mail() support - ssmtp \ ; \ rm -rf /var/lib/apt/lists/*; @@ -88,6 +86,7 @@ RUN chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html +WORKDIR /var/www/html RUN a2enmod rewrite remoteip ;\ {\ @@ -102,18 +101,11 @@ RUN {\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ } > /usr/local/etc/php/conf.d/sendmail.ini; -ENV AUTOINSTALL false -ENV VALIDATION true -ENV SITENAME "Friendica Social Network" - -ENV FRIENDICA_VERSION 2018.08-dev -ENV FRIENDICA_ADDONS 2018.08-dev - -COPY bin/* /usr/local/bin/ -COPY config/* /usr/src/config/ -COPY *.sh / +COPY *.sh upgrade.exclude / RUN chmod +x /*.sh -RUN chmod +x /usr/local/bin/* + +ENV FRIENDICA_VERSION 2018.12-dev +ENV FRIENDICA_ADDONS 2018.12-dev ENTRYPOINT ["/entrypoint.sh"] diff --git a/2018.12-dev/apache/cron.sh b/2018.12-dev/apache/cron.sh new file mode 100644 index 0000000..ce4d3ae --- /dev/null +++ b/2018.12-dev/apache/cron.sh @@ -0,0 +1,11 @@ +#!/bin/sh +trap "break;exit" HUP INT TERM + +while [ ! -f /var/www/html/config/local.ini.php ]; do + sleep 1 +done + +# TODO let the database and the autoinstall time to complete - not winning a beauty contest +sleep 15s + +php /var/www/html/bin/daemon.php -f start diff --git a/2018.12-dev/apache/entrypoint.sh b/2018.12-dev/apache/entrypoint.sh new file mode 100644 index 0000000..ab38907 --- /dev/null +++ b/2018.12-dev/apache/entrypoint.sh @@ -0,0 +1,171 @@ +#!/bin/sh +set -eu + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" -eq 0 ]; then + su - www-data -s /bin/sh -c "cd /var/www/html;$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" ] +} + +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + friendica_git="${FRIENDICA_VERSION}" + addons_git="${FRIENDICA_ADDONS}" + + if echo "$friendica_git" | grep -Eq '^.*\-dev'; then + friendica_git="develop" + fi + + if echo "$addons_git" | grep -Eq '^.*\-dev'; then + addons_git="develop" + fi + + echo "Downloading Friendica from GitHub '${friendica_git}' ..." + + # Removing the whole directory first + rm -fr /usr/src/friendica + sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica /usr/src/friendica" + + mkdir /usr/src/friendica/addon + sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons /usr/src/friendica/addon" + + echo "Download finished" + + /usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica +} + +# just check if we execute apache or php-fpm +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/VERSION ]; then + installed_version="$(cat /var/www/html/VERSION)" + fi + + check=false + # cloning from git is just possible for develop or Release Candidats + if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then + # just clone & check if it's a new install or upgrade + if [ "$installed_version" = "0.0.0.0" ] || [ "$FRIENDICA_UPGRADE" = "true" ]; then + clone_develop + image_version="$(cat /usr/src/friendica/VERSION)" + check=true + fi + else + image_version="$(cat /usr/src/friendica/VERSION)" + + # check it just in case the version is greater + if version_greater "$image_version" "$installed_version"; then + check=true + fi + + # no downgrading possible + 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')', 0 + exit 1; + fi + fi + + if [ "$check" = true ]; then + echo "Initializing Friendica $image_version ..." + + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading Friendica from $installed_version ..." + fi + + if [ "$(id -u)" -eq 0 ]; then + rsync_options="-rlDog --chown=www-data:www-data" + else + rsync_options="-rlD" + fi + + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/ + + # copy every *.ini.php from the config directory except they are already copied (in case of an upgrade) + for dir in config; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/ + fi + done + + # In case there is no .htaccess, copy it from the default dist file + if [ ! -f "/var/www/html/.htaccess" ]; then + cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess" + fi + + if [ -d /var/www/html/view/smarty3 ]; then + chmod -R 777 /var/www/html/view/smarty3 + fi + echo "Initializing finished" + + # install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New Friendica instance" + + install=false + if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then + echo "Installation with environment variables" + + # TODO Bug in PHP Path for automatic installation + #FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php} + FRIENDICA_TZ=${FRIENDICA_TZ:-America/LosAngeles} + FRIENDICA_LANG=${FRIENDICA_LANG:-en} + MYSQL_PORT=${MYSQL_PORT:-3306} + if [ -n "${MYSQL_USER+x}" ]; then + MYSQL_USERNAMEFULL=${MYSQL_USER} + else + MYSQL_USERNAMEFULL=${MYSQL_USERNAME} + fi + + # shellcheck disable=SC2016 + install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"' + + # shellcheck disable=SC2016 + install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"' + install=true + elif [ -f "/usr/src/config/local.ini.php" ]; then + echo "Installation with prepared local.ini.php" + + install_options="-f /usr/src/local.ini.php" + install=true + fi + + if [ "$install" = true ]; then + echo "Starting Friendica installation ..." + # TODO Let the database time to warm up - not winning a beauty contest + sleep 10s + run_as "/var/www/html/bin/console autoinstall $install_options" + + # TODO Workaround because of a strange permission issue + rm -fr /var/www/html/view/smarty3/compiled + + # load other config files (*.ini.php) to the config folder (currently only local.ini.php and addon.ini.php supported) + if [ -d "/usr/src/config" ]; then + rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/ + fi + + echo "Installation finished" + else + echo "Running web-based installer on first connect!" + fi + # upgrade + else + echo "Upgrading Friendica ..." + run_as '/var/www/html/bin/console dbstructure update' + echo "Upgrading finished" + fi + fi +fi + +exec "$@" diff --git a/2018.12-dev/apache/upgrade.exclude b/2018.12-dev/apache/upgrade.exclude new file mode 100644 index 0000000..732ba58 --- /dev/null +++ b/2018.12-dev/apache/upgrade.exclude @@ -0,0 +1,7 @@ +/.git/ +/photo/ +/proxy/ +.htconfig.php +.htaccess +home.* +/config/ \ No newline at end of file diff --git a/2018.08-dev/fpm-alpine/Dockerfile b/2018.12-dev/fpm-alpine/Dockerfile similarity index 84% rename from 2018.08-dev/fpm-alpine/Dockerfile rename to 2018.12-dev/fpm-alpine/Dockerfile index 2723c60..8fb8ce1 100644 --- a/2018.08-dev/fpm-alpine/Dockerfile +++ b/2018.12-dev/fpm-alpine/Dockerfile @@ -6,9 +6,7 @@ LABEL maintainer="Philipp Holzer " RUN set -ex; \ apk add --no-cache \ rsync \ - git \ - # For mail() support - ssmtp; + git; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ @@ -21,8 +19,8 @@ RUN set -ex; \ autoconf \ g++ \ make \ - openssl \ - openssl-dev \ + libressl \ + libressl-dev \ libpng \ libpng-dev \ libjpeg-turbo-dev \ @@ -75,29 +73,23 @@ RUN set -ex; \ apk add --virtual .friendica-phpext-rundeps $runDeps; \ apk del .build-deps; -RUN chown -R www-data:root /var/www; \ +RUN chown -R www-data:www-data /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html +WORKDIR /var/www/html RUN {\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ } > /usr/local/etc/php/conf.d/sendmail.ini; -ENV AUTOINSTALL false -ENV VALIDATION true -ENV SITENAME "Friendica Social Network" - -ENV FRIENDICA_VERSION 2018.08-dev -ENV FRIENDICA_ADDONS 2018.08-dev - -COPY bin/* /usr/local/bin/ -COPY config/* /usr/src/config/ -COPY *.sh / +COPY *.sh upgrade.exclude / RUN chmod +x /*.sh -RUN chmod +x /usr/local/bin/* + +ENV FRIENDICA_VERSION 2018.12-dev +ENV FRIENDICA_ADDONS 2018.12-dev ENTRYPOINT ["/entrypoint.sh"] -CMD ["php-fpm"] \ No newline at end of file +CMD ["php-fpm"] diff --git a/2018.12-dev/fpm-alpine/cron.sh b/2018.12-dev/fpm-alpine/cron.sh new file mode 100644 index 0000000..ce4d3ae --- /dev/null +++ b/2018.12-dev/fpm-alpine/cron.sh @@ -0,0 +1,11 @@ +#!/bin/sh +trap "break;exit" HUP INT TERM + +while [ ! -f /var/www/html/config/local.ini.php ]; do + sleep 1 +done + +# TODO let the database and the autoinstall time to complete - not winning a beauty contest +sleep 15s + +php /var/www/html/bin/daemon.php -f start diff --git a/2018.12-dev/fpm-alpine/entrypoint.sh b/2018.12-dev/fpm-alpine/entrypoint.sh new file mode 100644 index 0000000..ab38907 --- /dev/null +++ b/2018.12-dev/fpm-alpine/entrypoint.sh @@ -0,0 +1,171 @@ +#!/bin/sh +set -eu + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" -eq 0 ]; then + su - www-data -s /bin/sh -c "cd /var/www/html;$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" ] +} + +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + friendica_git="${FRIENDICA_VERSION}" + addons_git="${FRIENDICA_ADDONS}" + + if echo "$friendica_git" | grep -Eq '^.*\-dev'; then + friendica_git="develop" + fi + + if echo "$addons_git" | grep -Eq '^.*\-dev'; then + addons_git="develop" + fi + + echo "Downloading Friendica from GitHub '${friendica_git}' ..." + + # Removing the whole directory first + rm -fr /usr/src/friendica + sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica /usr/src/friendica" + + mkdir /usr/src/friendica/addon + sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons /usr/src/friendica/addon" + + echo "Download finished" + + /usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica +} + +# just check if we execute apache or php-fpm +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/VERSION ]; then + installed_version="$(cat /var/www/html/VERSION)" + fi + + check=false + # cloning from git is just possible for develop or Release Candidats + if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then + # just clone & check if it's a new install or upgrade + if [ "$installed_version" = "0.0.0.0" ] || [ "$FRIENDICA_UPGRADE" = "true" ]; then + clone_develop + image_version="$(cat /usr/src/friendica/VERSION)" + check=true + fi + else + image_version="$(cat /usr/src/friendica/VERSION)" + + # check it just in case the version is greater + if version_greater "$image_version" "$installed_version"; then + check=true + fi + + # no downgrading possible + 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')', 0 + exit 1; + fi + fi + + if [ "$check" = true ]; then + echo "Initializing Friendica $image_version ..." + + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading Friendica from $installed_version ..." + fi + + if [ "$(id -u)" -eq 0 ]; then + rsync_options="-rlDog --chown=www-data:www-data" + else + rsync_options="-rlD" + fi + + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/ + + # copy every *.ini.php from the config directory except they are already copied (in case of an upgrade) + for dir in config; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/ + fi + done + + # In case there is no .htaccess, copy it from the default dist file + if [ ! -f "/var/www/html/.htaccess" ]; then + cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess" + fi + + if [ -d /var/www/html/view/smarty3 ]; then + chmod -R 777 /var/www/html/view/smarty3 + fi + echo "Initializing finished" + + # install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New Friendica instance" + + install=false + if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then + echo "Installation with environment variables" + + # TODO Bug in PHP Path for automatic installation + #FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php} + FRIENDICA_TZ=${FRIENDICA_TZ:-America/LosAngeles} + FRIENDICA_LANG=${FRIENDICA_LANG:-en} + MYSQL_PORT=${MYSQL_PORT:-3306} + if [ -n "${MYSQL_USER+x}" ]; then + MYSQL_USERNAMEFULL=${MYSQL_USER} + else + MYSQL_USERNAMEFULL=${MYSQL_USERNAME} + fi + + # shellcheck disable=SC2016 + install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"' + + # shellcheck disable=SC2016 + install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"' + install=true + elif [ -f "/usr/src/config/local.ini.php" ]; then + echo "Installation with prepared local.ini.php" + + install_options="-f /usr/src/local.ini.php" + install=true + fi + + if [ "$install" = true ]; then + echo "Starting Friendica installation ..." + # TODO Let the database time to warm up - not winning a beauty contest + sleep 10s + run_as "/var/www/html/bin/console autoinstall $install_options" + + # TODO Workaround because of a strange permission issue + rm -fr /var/www/html/view/smarty3/compiled + + # load other config files (*.ini.php) to the config folder (currently only local.ini.php and addon.ini.php supported) + if [ -d "/usr/src/config" ]; then + rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/ + fi + + echo "Installation finished" + else + echo "Running web-based installer on first connect!" + fi + # upgrade + else + echo "Upgrading Friendica ..." + run_as '/var/www/html/bin/console dbstructure update' + echo "Upgrading finished" + fi + fi +fi + +exec "$@" diff --git a/2018.12-dev/fpm-alpine/upgrade.exclude b/2018.12-dev/fpm-alpine/upgrade.exclude new file mode 100644 index 0000000..732ba58 --- /dev/null +++ b/2018.12-dev/fpm-alpine/upgrade.exclude @@ -0,0 +1,7 @@ +/.git/ +/photo/ +/proxy/ +.htconfig.php +.htaccess +home.* +/config/ \ No newline at end of file diff --git a/2018.08-dev/fpm/Dockerfile b/2018.12-dev/fpm/Dockerfile similarity index 90% rename from 2018.08-dev/fpm/Dockerfile rename to 2018.12-dev/fpm/Dockerfile index 32177c7..cac7281 100644 --- a/2018.08-dev/fpm/Dockerfile +++ b/2018.12-dev/fpm/Dockerfile @@ -10,8 +10,6 @@ RUN set -ex; \ rsync \ bzip2 \ git \ -# For mail() support - ssmtp \ ; \ rm -rf /var/lib/apt/lists/*; @@ -88,24 +86,18 @@ RUN chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html +WORKDIR /var/www/html RUN {\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ } > /usr/local/etc/php/conf.d/sendmail.ini; -ENV AUTOINSTALL false -ENV VALIDATION true -ENV SITENAME "Friendica Social Network" - -ENV FRIENDICA_VERSION 2018.08-dev -ENV FRIENDICA_ADDONS 2018.08-dev - -COPY bin/* /usr/local/bin/ -COPY config/* /usr/src/config/ -COPY *.sh / +COPY *.sh upgrade.exclude / RUN chmod +x /*.sh -RUN chmod +x /usr/local/bin/* + +ENV FRIENDICA_VERSION 2018.12-dev +ENV FRIENDICA_ADDONS 2018.12-dev ENTRYPOINT ["/entrypoint.sh"] diff --git a/2018.12-dev/fpm/cron.sh b/2018.12-dev/fpm/cron.sh new file mode 100644 index 0000000..ce4d3ae --- /dev/null +++ b/2018.12-dev/fpm/cron.sh @@ -0,0 +1,11 @@ +#!/bin/sh +trap "break;exit" HUP INT TERM + +while [ ! -f /var/www/html/config/local.ini.php ]; do + sleep 1 +done + +# TODO let the database and the autoinstall time to complete - not winning a beauty contest +sleep 15s + +php /var/www/html/bin/daemon.php -f start diff --git a/2018.12-dev/fpm/entrypoint.sh b/2018.12-dev/fpm/entrypoint.sh new file mode 100644 index 0000000..ab38907 --- /dev/null +++ b/2018.12-dev/fpm/entrypoint.sh @@ -0,0 +1,171 @@ +#!/bin/sh +set -eu + +# run an command with the www-data user +run_as() { + if [ "$(id -u)" -eq 0 ]; then + su - www-data -s /bin/sh -c "cd /var/www/html;$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" ] +} + +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + friendica_git="${FRIENDICA_VERSION}" + addons_git="${FRIENDICA_ADDONS}" + + if echo "$friendica_git" | grep -Eq '^.*\-dev'; then + friendica_git="develop" + fi + + if echo "$addons_git" | grep -Eq '^.*\-dev'; then + addons_git="develop" + fi + + echo "Downloading Friendica from GitHub '${friendica_git}' ..." + + # Removing the whole directory first + rm -fr /usr/src/friendica + sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica /usr/src/friendica" + + mkdir /usr/src/friendica/addon + sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons /usr/src/friendica/addon" + + echo "Download finished" + + /usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica +} + +# just check if we execute apache or php-fpm +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/VERSION ]; then + installed_version="$(cat /var/www/html/VERSION)" + fi + + check=false + # cloning from git is just possible for develop or Release Candidats + if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then + # just clone & check if it's a new install or upgrade + if [ "$installed_version" = "0.0.0.0" ] || [ "$FRIENDICA_UPGRADE" = "true" ]; then + clone_develop + image_version="$(cat /usr/src/friendica/VERSION)" + check=true + fi + else + image_version="$(cat /usr/src/friendica/VERSION)" + + # check it just in case the version is greater + if version_greater "$image_version" "$installed_version"; then + check=true + fi + + # no downgrading possible + 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')', 0 + exit 1; + fi + fi + + if [ "$check" = true ]; then + echo "Initializing Friendica $image_version ..." + + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading Friendica from $installed_version ..." + fi + + if [ "$(id -u)" -eq 0 ]; then + rsync_options="-rlDog --chown=www-data:www-data" + else + rsync_options="-rlD" + fi + + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/ + + # copy every *.ini.php from the config directory except they are already copied (in case of an upgrade) + for dir in config; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/ + fi + done + + # In case there is no .htaccess, copy it from the default dist file + if [ ! -f "/var/www/html/.htaccess" ]; then + cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess" + fi + + if [ -d /var/www/html/view/smarty3 ]; then + chmod -R 777 /var/www/html/view/smarty3 + fi + echo "Initializing finished" + + # install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New Friendica instance" + + install=false + if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then + echo "Installation with environment variables" + + # TODO Bug in PHP Path for automatic installation + #FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php} + FRIENDICA_TZ=${FRIENDICA_TZ:-America/LosAngeles} + FRIENDICA_LANG=${FRIENDICA_LANG:-en} + MYSQL_PORT=${MYSQL_PORT:-3306} + if [ -n "${MYSQL_USER+x}" ]; then + MYSQL_USERNAMEFULL=${MYSQL_USER} + else + MYSQL_USERNAMEFULL=${MYSQL_USERNAME} + fi + + # shellcheck disable=SC2016 + install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"' + + # shellcheck disable=SC2016 + install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"' + install=true + elif [ -f "/usr/src/config/local.ini.php" ]; then + echo "Installation with prepared local.ini.php" + + install_options="-f /usr/src/local.ini.php" + install=true + fi + + if [ "$install" = true ]; then + echo "Starting Friendica installation ..." + # TODO Let the database time to warm up - not winning a beauty contest + sleep 10s + run_as "/var/www/html/bin/console autoinstall $install_options" + + # TODO Workaround because of a strange permission issue + rm -fr /var/www/html/view/smarty3/compiled + + # load other config files (*.ini.php) to the config folder (currently only local.ini.php and addon.ini.php supported) + if [ -d "/usr/src/config" ]; then + rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/ + fi + + echo "Installation finished" + else + echo "Running web-based installer on first connect!" + fi + # upgrade + else + echo "Upgrading Friendica ..." + run_as '/var/www/html/bin/console dbstructure update' + echo "Upgrading finished" + fi + fi +fi + +exec "$@" diff --git a/2018.12-dev/fpm/upgrade.exclude b/2018.12-dev/fpm/upgrade.exclude new file mode 100644 index 0000000..732ba58 --- /dev/null +++ b/2018.12-dev/fpm/upgrade.exclude @@ -0,0 +1,7 @@ +/.git/ +/photo/ +/proxy/ +.htconfig.php +.htaccess +home.* +/config/ \ No newline at end of file diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index 936115a..a6f54f1 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -5,9 +5,7 @@ LABEL maintainer="Philipp Holzer " RUN set -ex; \ apk add --no-cache \ rsync \ - git \ - # For mail() support - ssmtp; + git; # install the PHP extensions we need # see https://friendi.ca/resources/requirements/ @@ -20,8 +18,8 @@ RUN set -ex; \ autoconf \ g++ \ make \ - openssl \ - openssl-dev \ + libressl \ + libressl-dev \ libpng \ libpng-dev \ libjpeg-turbo-dev \ @@ -74,29 +72,23 @@ RUN set -ex; \ apk add --virtual .friendica-phpext-rundeps $runDeps; \ apk del .build-deps; -RUN chown -R www-data:root /var/www; \ +RUN chown -R www-data:www-data /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html +WORKDIR /var/www/html %%VARIANT_EXTRAS%% RUN {\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ } > /usr/local/etc/php/conf.d/sendmail.ini; -ENV AUTOINSTALL false -ENV VALIDATION true -ENV SITENAME "Friendica Social Network" +COPY *.sh upgrade.exclude / +RUN chmod +x /*.sh ENV FRIENDICA_VERSION %%VERSION%% ENV FRIENDICA_ADDONS %%VERSION%% - -COPY bin/* /usr/local/bin/ -COPY config/* /usr/src/config/ -COPY *.sh / -RUN chmod +x /*.sh -RUN chmod +x /usr/local/bin/* %%INSTALL_EXTRAS%% ENTRYPOINT ["/entrypoint.sh"] -CMD ["%%CMD%%"] \ No newline at end of file +CMD ["%%CMD%%"] diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index 05e1764..2735ae1 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -9,8 +9,6 @@ RUN set -ex; \ rsync \ bzip2 \ git \ -# For mail() support - ssmtp \ ; \ rm -rf /var/lib/apt/lists/*; @@ -87,24 +85,18 @@ RUN chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html +WORKDIR /var/www/html %%VARIANT_EXTRAS%% RUN {\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ } > /usr/local/etc/php/conf.d/sendmail.ini; -ENV AUTOINSTALL false -ENV VALIDATION true -ENV SITENAME "Friendica Social Network" +COPY *.sh upgrade.exclude / +RUN chmod +x /*.sh ENV FRIENDICA_VERSION %%VERSION%% ENV FRIENDICA_ADDONS %%VERSION%% - -COPY bin/* /usr/local/bin/ -COPY config/* /usr/src/config/ -COPY *.sh / -RUN chmod +x /*.sh -RUN chmod +x /usr/local/bin/* %%INSTALL_EXTRAS%% ENTRYPOINT ["/entrypoint.sh"] diff --git a/README-MAINTENANCE.md b/README-MAINTENANCE.md index b3d69de..f01e76d 100644 --- a/README-MAINTENANCE.md +++ b/README-MAINTENANCE.md @@ -1,87 +1,69 @@ -# How to maintain this repository - -The structure and usage of this repository is influenced by other, official docker repositories. - -# Version directories - -**This is important.** -Never ever change a file/folder inside a directory without a `.` at the beginning (`2018.05-rc`, ...). -This folder will get updated automatically based on the templates you want to change. -All changes in such folders will get overwritten during an update. - -# Basic files and folders - -Most of the time you want to change one of the followed files. - -## [`.bin`](https://github.com/friendica/docker/tree/master/.bin) - -This directory holds the binary/shell files for docker images. -They get copied into the docker images at `/usr/local/bin`. - -## [`.config`](https://github.com/friendica/docker/tree/master/.config) - -This directory holds the config files for docker images. -They get copied into the docker images at `/usr/src/config`. - -### `htconfig.php` - -This file is based on the sample [`htconfig.php`](https://github.com/friendica/friendica/blob/559250b8b3a7a5d0e524d3e3e2d347d18d6c3a2a/htconfig.php) in the Friendica repository. - -The differences: -- Removed the `die()` at the beginning -- Removed all hard-coded DB settings -- Added environment variables for mailname, tz, language - -## Templates & shell-scripts - -- If you want to update/upgrade Dockerfiles, use the right `*.template` file for it. -- If you want to update/change the behavior of **every** start of Docker-image, change `docker-entrypoint.sh` -- If you want to update/change the behavior how cronjobs will get started, change `docker-cron.sh` - -# Maintenance scripts - -There are two important scripts in this repository for maintenance. - -## update.sh - -Creates a directory and the necessary files for each combination of version (2018.05-rc, 3.6, ...) and variant (apache, fpm, fpm-alpine): - -- Creating the right `Dockerfile` (from one of the two *.template files) -- Creating the `docker-*.sh` files (copy as *.sh) -- Coping `/.bin/*` to `bin/*` -- Coping `/.config/*` to `config/*` -- Recreating the version/variant environment in `.travis.yml` - -If you want to update the Docker-images to a newer version, just change the list in `update.sh` at -```shell -versions=( - 2018.05-rc -) -``` - -# generate-stackbrew-library.sh - -This file automatically creates a "manifest" for the docker-images. -Like: - -```console -# This file is generated via https://github.com/friendica/docker/blob/b46fae917321394e1482df59dc4e39daffbe5c59/generate-stackbrew-library.sh -Maintainers: Friendica (@friendica), Philipp Holzer (@[secure]) -GitRepo: https://github.com/friendica/docker.git - -Tags: 2018.05-rc-apache, rc-apache, apache, stable-apache, production-apache, 2018.05-rc, rc, latest, stable, production -Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, ppc64le, s390x -GitCommit: b46fae917321394e1482df59dc4e39daffbe5c59 -Directory: 2018.05-rc/apache - -Tags: 2018.05-rc-fpm, rc-fpm, fpm, stable-fpm, production-fpm -Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, ppc64le, s390x -GitCommit: b46fae917321394e1482df59dc4e39daffbe5c59 -Directory: 2018.05-rc/fpm - -Tags: 2018.05-rc-fpm-alpine, rc-fpm-alpine, fpm-alpine, stable-fpm-alpine, production-fpm-alpine -Architectures: amd64, arm32v6, arm64v8, i386, ppc64le, s390x -GitCommit: b46fae917321394e1482df59dc4e39daffbe5c59 -Directory: 2018.05-rc/fpm-alpine -This is the input-file for the official-images in a later step :-) +# How to maintain this repository + +The structure and usage of this repository is influenced by other, official docker repositories. + +# Version directories + +**This is important!** + +Never ever change a file/folder inside a directory without a `.` at the beginning (`2018.05-rc`, ...). +This folder will get updated automatically based on the templates you want to change. +All changes in such folders will get overwritten during an update. + +# Basic files and folders + +Most of the time you want to change one of the followed files. + +## Templates & shell-scripts + +- If you want to update/upgrade Dockerfiles, use the right `*.template` file for it. +- If you want to update/change the behavior of **every** start of Docker-image, change `docker-entrypoint.sh` +- If you want to update/change the behavior how cronjobs will get started, change `docker-cron.sh` + +# Maintenance scripts + +There are two important scripts in this repository for maintenance. + +## update.sh + +Creates a directory and the necessary files for each combination of version (2018.05-rc, 3.6, ...) and variant (apache, fpm, fpm-alpine): + +- Creating the right `Dockerfile` (from one of the two *.template files) +- Creating the `docker-*.sh` files (copy as *.sh) +- Coping `/.bin/*` to `bin/*` +- Coping `/.config/*` to `config/*` +- Recreating the version/variant environment in `.travis.yml` + +If you want to update the Docker-images to a newer version, just change the list in `update.sh` at +```shell +versions=( + 2018.05-rc +) +``` + +# generate-stackbrew-library.sh + +This file automatically creates a "manifest" for the docker-images. +Like: + +```console +# This file is generated via https://github.com/friendica/docker/blob/b46fae917321394e1482df59dc4e39daffbe5c59/generate-stackbrew-library.sh +Maintainers: Friendica (@friendica), Philipp Holzer (@[secure]) +GitRepo: https://github.com/friendica/docker.git + +Tags: 2018.05-rc-apache, rc-apache, apache, stable-apache, production-apache, 2018.05-rc, rc, latest, stable, production +Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, ppc64le, s390x +GitCommit: b46fae917321394e1482df59dc4e39daffbe5c59 +Directory: 2018.05-rc/apache + +Tags: 2018.05-rc-fpm, rc-fpm, fpm, stable-fpm, production-fpm +Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, ppc64le, s390x +GitCommit: b46fae917321394e1482df59dc4e39daffbe5c59 +Directory: 2018.05-rc/fpm + +Tags: 2018.05-rc-fpm-alpine, rc-fpm-alpine, fpm-alpine, stable-fpm-alpine, production-fpm-alpine +Architectures: amd64, arm32v6, arm64v8, i386, ppc64le, s390x +GitCommit: b46fae917321394e1482df59dc4e39daffbe5c59 +Directory: 2018.05-rc/fpm-alpine +This is the input-file for the official-images in a later step :-) ``` \ No newline at end of file diff --git a/README.md b/README.md index 9cd0fb3..948a3cb 100644 --- a/README.md +++ b/README.md @@ -1,329 +1,295 @@ -# 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) - -# 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/friendica/docker/9c954f4d/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. - -[![Try in PWD](https://github.com/play-with-docker/stacks/raw/cff22438cb4195ace27f9b15784bbb497047afa7/assets/images/button.png)](http://play-with-docker.com?stack=https://raw.githubusercontent.com/nupplaphil/friendica-docker/fec33c98be957436279b7074ca08068b18622627/stack.yml) -(Admin-E-Mail: `root@friendica.local`) - -## 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/server -``` - -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/server: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 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 creating **two** container (one for cron and one for the main app) -- Using one of the additional, prepared [`cron dockerfiles`](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/cron) - -# Environment variables - -This is the full list of all possible environment variables used for this image: - -**Common** -- `MAILNAME` E-Mail address of the administrator. (**required**) -- `TZ` The default localization of the Friendica server. (Default: `America/Los_Angeles`) -- `LANGUAGE` The default language of the Friendica server. (Default: `en`) -- `SITENAME` The default name of the Friendica server. (Default: `Friendica Social Network` ) -- `VALIDATION` The default setting if url/emails are getting validated. (Default: `true`) -- `AUTOINSTALL` if `true`, the automatic configuration will start. (Default: `false`) - -**SMTP/Mail** -- `SMTP` Address of the SMTP Mail-Gateway. (**required** - Default: `localhost`) -- `SMTP_FROM` Sender user-part of the address. (Default: `no-reply` - e.g. no-reply@friendica.local) -- `SMTP_AUTH_USER` Username for the SMTP Mail-Gateway. (Default: empty) -- `SMTP_AUTH_PASS` Password for the SMTP Mail-Gateway. (Default: empty) -- `SMTP_AUTH_METHOD` Authentication method for the SMTP Mail-Gateway. (Default: empty/plain text) - -**Database** (**required**) -- `MYSQL_USERNAME` Username for the database user using mysql. -- `MYSQL_USER` Username for the database user using 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. - -**Caching** -- `CACHE_DRIVER` Driver of the Friendica cache (`memcache`, `memcached` or `redis`) -- `MEMCACHE_HOST` Host of the memcache cache server. (Default: `127.0.0.1`) -- `MEMCACHE_PORT` Port of the memcache cache server. (Default: `11211`) -- `MEMCACHED_HOSTS` Hosts of the memcached cache server. (Default: `[['127.0.0.1', 11211]]`) -- `REDIS_HOST` Host of the redis cache server. (Default: `127.0.0.1`) -- `REDIS_PORT` Port of the redis cache server. (Default: `6379`) - - -## Administrator account - -Because Friendica links the administrator account to a specific mail address, you **have** to set a valid address for `MAILNAME`. - -## Mail settings - -The binary `ssmtp` is used for the `mail()` support of Friendica. - -You have to set the `--hostname/-h` parameter correctly to use the right domainname for the `mail()` command. - -You have to set a valid SMTP-MTA for the `SMTP` environment variable to enable mail support in Friendica. -A valid SMTP-MTA would be, for example, `mx.example.org`. - -## Database settings - -You have to link a running 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. - -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/server -``` - -Database: - -- `/var/lib/mysql` MySQL / MariaDB Data - -```console -$ docker run -d \ - -v mysql-vol-1:/var/lib/mysql \ - mariadb -``` - -## Automatic installation - -The Friendica image supports auto configuration via environment variables. -You can preconfigure everything that is asked on the install page on first run. -To enable the automatic installation, you have to set `AUTOINSTALL` to `true`. - -# Maintenance of the image - -## Updating to a newer version - -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 executing `friendica update` on the node. -Example: - -```console -$ 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 Docker images 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 - -# Running this image with docker-compose - -The easiest way to get a fully featured and functional setup is using a `docker-compose` file. -There are too many different possibilities to setup your system, so here are only some examples what you have to look for. - -At first make sure you have chosen the right base image (fpm or apache) and added the features you wanted (see below). -In every case you want to add a database container and docker volumes to get easy access to your persistent data. -When you want your server reachable from the internet adding HTTPS-encryption is mandatory! -See below for more information. - -## Base version - apache - -This version will use the apache image and add a mariaDB container. -The volumes are set to keep your data persistent. -This setup provides **no ssl encryption** and is intended to run behind a proxy. - -Make sure to set the variable `MYSQL_PASSWORD` before run this setup. - -```yaml -version: '2' - -services: - db: - image: mariadb - restart: always - volumes: - - db:/var/lib/mysql - environment: - - MYSQL_USER=friendica - - MYSQL_PASSWORD= - - MYSQL_DATABASE=friendica - - MYSQL_RANDOM_ROOT_PASSWORD=yes - - app: - image: friendica/server - restart: always - volumes: - - friendica:/var/www/html - ports: - - "8080:80" - environment: - - MYSQL_HOST=db - - MYSQL_PORT=3306 - - MYSQL_USER=friendica - - MYSQL_PASSWORD= - - MYSQL_DATABASE=friendica - - MAILNAME=root@friendica.local - hostname: friendica.local - depends_on: - - db - -volumes: - db: - friendica: -``` - -Then run `docker-compose up -d`, now you can access Friendica at http://localhost:8080/ from your system. - -## Base version - FPM - -When using the FPM image you need another container that acts as web server on port 80 and proxies requests to the Friendica container. -In this example a simple nginx container is combined with the Friendica-fpm image and a MariaDB database container. -The data is stored in docker volumes. -The nginx container also need access to static files from your Friendica installation. -It gets access to all the volumes mounted to Friendica via the `volumes_from` option. -The configuration for nginx is stored in the configuration file `nginx.conf` that is mounted into the container. - -An example can be found in the [examples section](https://github.com/friendica/docker/tree/master/.examples). - -As this setup does **not include encryption** it should to be run behind a proxy. - -Prerequisites for this example: -- Make sure to set the variable `MYSQL_PASSWORD` before you run the setup. -- Create a `nginx.conf` in the same directory as the docker-compose.yml file (take it from [example](https://github.com/friendica/docker/tree/master/.examples/docker-compose/with-traefik-proxy/mariadb-cron-smtp/fpm/web/nginx.conf)) - -```yaml -version: '2' - -services: - db: - image: mariadb - restart: always - volumes: - - db:/var/lib/mysql - environment: - - MYSQL_USER=friendica - - MYSQL_PASSWORD= - - MYSQL_DATABASE=friendica - - MYSQL_RANDOM_ROOT_PASSWORD=yes - - app: - image: friendica/server:fpm - restart: always - volumes: - - friendica:/var/www/html - environment: - - MYSQL_HOST=db - - MYSQL_PORT=3306 - - MYSQL_USER=friendica - - MYSQL_PASSWORD= - - MYSQL_DATABASE=friendica - - MAILNAME=root@friendica.local - hostname: friendica.local - networks: - - proxy-tier - - default - - web: - image: nginx - ports: - - 8080:80 - links: - - app - volumes: - - ./nginx.conf:/etc/nginx/nginx.conf:ro - restart: always - networks: - - proxy-tier - -volumes: - db: - friendica: - -networks: - proxy-tier: -``` - -Then run `docker-compose up -d`, now you can access Friendica at http://localhost:8080/ from your system. - -# 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. +# 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) + +# 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/friendica/docker/9c954f4d/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. + +[![Try in PWD](https://github.com/play-with-docker/stacks/raw/cff22438cb4195ace27f9b15784bbb497047afa7/assets/images/button.png)](http://play-with-docker.com?stack=https://raw.githubusercontent.com/nupplaphil/friendica-docker/fec33c98be957436279b7074ca08068b18622627/stack.yml) +(Admin-E-Mail: `root@friendica.local`) + +## 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/server +``` + +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/server: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 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 creating **two** container (one for cron and one for the main app) +- Using one of the additional, prepared [`cron dockerfiles`](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/cron) + +## Possible Environment Variables + +**Auto Install Settings** +- `FRIENDICA_ADMIN_MAIL` E-Mail address of the administrator. +- `FRIENDICA_TZ` The default localization of the Friendica server. +- `FRIENDICA_LANG` The default language of the Friendica server. +- `FRIENDICA_PHP_PATH` The path of the PHP binary. + +**Database** (**required at installation**) +- `MYSQL_USERNAME` Username for the database user using mysql. +- `MYSQL_USER` Username for the database user using 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 (Default: `3306`) + +**Develop/Release Candidat Settings** +- `FRIENDICA_UPGRADE` If set to `true`, a develop or release candidat node will get updated at startup. + +## Administrator account + +Because Friendica links the administrator account to a specific mail address, you **have** to set a valid address for `MAILNAME`. + +## Mail settings + +see the [example](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/README.md#smtpsetting) + +## Database settings + +You have to link a running 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. + +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/server +``` + +Database: + +- `/var/lib/mysql` MySQL / MariaDB Data + +```console +$ docker run -d \ + -v mysql-vol-1:/var/lib/mysql \ + mariadb +``` + +## Automatic installation + +The Friendica image supports auto configuration via environment variables. +You can preconfigure everything that is asked on the install page on first run. +To enable the automatic installation, there are two possibilities: + +### Environment Variables + +You have to set at least the following environment variables (others are optional). + +- `FRIENDICA_ADMIN_MAIL` E-Mail address of the administrator. +- `MYSQL_USERNAME` or `MYSQL_USER` 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. + +### Using a predefined config file + +You can create a `local.ini.php` and `COPY` it to `/usr/src/config`. +If no other environment variable is set, this `local.ini.php` will get copied to the config path. + +# Maintenance of the image + +## Updating to a newer version + +There are differences between the deveop (everything which ends with `-rc` or `-dev`) and the stable (the rest) branches. + +### Updating stable + +You have to pull the latest image from the hub (`docker pull friendica`). +The stable branch gets checked at every startup and will get updated if no installation was found or a new image is used. + +### Updating develop + +You don't need to pull the image for each commit in [friendica](https://github.com/friendica/friendica/). +Instead, the develop branch will get updated if no installation was found or the environment variable `FRIENDICA_UPGRADE` is set to `true`. + +It will clone the latest Friendica version and copy it to your working directory. + +# Running this image with docker-compose + +The easiest way to get a fully featured and functional setup is using a `docker-compose` file. +There are too many different possibilities to setup your system, so here are only some examples what you have to look for. + +At first make sure you have chosen the right base image (fpm or apache) and added the features you wanted (see below). +In every case you want to add a database container and docker volumes to get easy access to your persistent data. +When you want your server reachable from the internet adding HTTPS-encryption is mandatory! +See below for more information. + +## Base version - apache + +This version will use the apache image and add a mariaDB container. +The volumes are set to keep your data persistent. +This setup provides **no ssl encryption** and is intended to run behind a proxy. + +Make sure to set the variable `MYSQL_PASSWORD` before run this setup. + +```yaml +version: '2' + +services: + db: + image: mariadb + restart: always + volumes: + - db:/var/lib/mysql + environment: + - MYSQL_USER=friendica + - MYSQL_PASSWORD= + - MYSQL_DATABASE=friendica + - MYSQL_RANDOM_ROOT_PASSWORD=yes + + app: + image: friendica/server + restart: always + volumes: + - friendica:/var/www/html + ports: + - "8080:80" + environment: + - MYSQL_HOST=db + - MYSQL_USER=friendica + - MYSQL_PASSWORD= + - MYSQL_DATABASE=friendica + - FRIENDICA_ADMIN_MAIL=root@friendica.local + hostname: friendica.local + depends_on: + - db + +volumes: + db: + friendica: +``` + +Then run `docker-compose up -d`, now you can access Friendica at http://localhost:8080/ from your system. + +## Base version - FPM + +When using the FPM image you need another container that acts as web server on port 80 and proxies requests to the Friendica container. +In this example a simple nginx container is combined with the Friendica-fpm image and a MariaDB database container. +The data is stored in docker volumes. +The nginx container also need access to static files from your Friendica installation. +It gets access to all the volumes mounted to Friendica via the `volumes_from` option. +The configuration for nginx is stored in the configuration file `nginx.conf` that is mounted into the container. + +An example can be found in the [examples section](https://github.com/friendica/docker/tree/master/.examples). + +As this setup does **not include encryption** it should to be run behind a proxy. + +Prerequisites for this example: +- Make sure to set the variable `MYSQL_PASSWORD` before you run the setup. +- Create a `nginx.conf` in the same directory as the docker-compose.yml file (take it from [example](https://github.com/friendica/docker/tree/master/.examples/docker-compose/with-traefik-proxy/mariadb-cron-smtp/fpm/web/nginx.conf)) + +```yaml +version: '2' + +services: + db: + image: mariadb + restart: always + volumes: + - db:/var/lib/mysql + environment: + - MYSQL_USER=friendica + - MYSQL_PASSWORD= + - MYSQL_DATABASE=friendica + - MYSQL_RANDOM_ROOT_PASSWORD=yes + + app: + image: friendica/server:fpm + restart: always + volumes: + - friendica:/var/www/html + environment: + - MYSQL_HOST=db + - MYSQL_USER=friendica + - MYSQL_PASSWORD= + - MYSQL_DATABASE=friendica + - FRIENDICA_ADMIN_MAIL=root@friendica.local + hostname: friendica.local + networks: + - proxy-tier + - default + + web: + image: nginx + ports: + - 8080:80 + links: + - app + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + restart: always + networks: + - proxy-tier + +volumes: + db: + friendica: + +networks: + proxy-tier: +``` + +Then run `docker-compose up -d`, now you can access Friendica at http://localhost:8080/ from your system. + +# 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. diff --git a/docker-cron.sh b/docker-cron.sh index 8c29dee..ce4d3ae 100644 --- a/docker-cron.sh +++ b/docker-cron.sh @@ -1,11 +1,11 @@ #!/bin/sh trap "break;exit" HUP INT TERM -while [ ! -f /var/www/html/.htconfig.php ]; do +while [ ! -f /var/www/html/config/local.ini.php ]; do sleep 1 done -while true; do - php -f /var/www/html/bin/worker.php - sleep 10m -done \ No newline at end of file +# TODO let the database and the autoinstall time to complete - not winning a beauty contest +sleep 15s + +php /var/www/html/bin/daemon.php -f start diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 8b75f8d..ab38907 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,7 +1,171 @@ #!/bin/sh set -eu -friendica install -q -friendica configmail -q +# run an command with the www-data user +run_as() { + if [ "$(id -u)" -eq 0 ]; then + su - www-data -s /bin/sh -c "cd /var/www/html;$1" + else + sh -c "$1" + fi +} -exec "$@" \ No newline at end of file +# 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" ] +} + +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +# clones the whole develop branch (Friendica and Addons) +clone_develop() { + friendica_git="${FRIENDICA_VERSION}" + addons_git="${FRIENDICA_ADDONS}" + + if echo "$friendica_git" | grep -Eq '^.*\-dev'; then + friendica_git="develop" + fi + + if echo "$addons_git" | grep -Eq '^.*\-dev'; then + addons_git="develop" + fi + + echo "Downloading Friendica from GitHub '${friendica_git}' ..." + + # Removing the whole directory first + rm -fr /usr/src/friendica + sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica /usr/src/friendica" + + mkdir /usr/src/friendica/addon + sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons /usr/src/friendica/addon" + + echo "Download finished" + + /usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica +} + +# just check if we execute apache or php-fpm +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/VERSION ]; then + installed_version="$(cat /var/www/html/VERSION)" + fi + + check=false + # cloning from git is just possible for develop or Release Candidats + if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then + # just clone & check if it's a new install or upgrade + if [ "$installed_version" = "0.0.0.0" ] || [ "$FRIENDICA_UPGRADE" = "true" ]; then + clone_develop + image_version="$(cat /usr/src/friendica/VERSION)" + check=true + fi + else + image_version="$(cat /usr/src/friendica/VERSION)" + + # check it just in case the version is greater + if version_greater "$image_version" "$installed_version"; then + check=true + fi + + # no downgrading possible + 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')', 0 + exit 1; + fi + fi + + if [ "$check" = true ]; then + echo "Initializing Friendica $image_version ..." + + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading Friendica from $installed_version ..." + fi + + if [ "$(id -u)" -eq 0 ]; then + rsync_options="-rlDog --chown=www-data:www-data" + else + rsync_options="-rlD" + fi + + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/ + + # copy every *.ini.php from the config directory except they are already copied (in case of an upgrade) + for dir in config; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/ + fi + done + + # In case there is no .htaccess, copy it from the default dist file + if [ ! -f "/var/www/html/.htaccess" ]; then + cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess" + fi + + if [ -d /var/www/html/view/smarty3 ]; then + chmod -R 777 /var/www/html/view/smarty3 + fi + echo "Initializing finished" + + # install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New Friendica instance" + + install=false + if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then + echo "Installation with environment variables" + + # TODO Bug in PHP Path for automatic installation + #FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php} + FRIENDICA_TZ=${FRIENDICA_TZ:-America/LosAngeles} + FRIENDICA_LANG=${FRIENDICA_LANG:-en} + MYSQL_PORT=${MYSQL_PORT:-3306} + if [ -n "${MYSQL_USER+x}" ]; then + MYSQL_USERNAMEFULL=${MYSQL_USER} + else + MYSQL_USERNAMEFULL=${MYSQL_USERNAME} + fi + + # shellcheck disable=SC2016 + install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"' + + # shellcheck disable=SC2016 + install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"' + install=true + elif [ -f "/usr/src/config/local.ini.php" ]; then + echo "Installation with prepared local.ini.php" + + install_options="-f /usr/src/local.ini.php" + install=true + fi + + if [ "$install" = true ]; then + echo "Starting Friendica installation ..." + # TODO Let the database time to warm up - not winning a beauty contest + sleep 10s + run_as "/var/www/html/bin/console autoinstall $install_options" + + # TODO Workaround because of a strange permission issue + rm -fr /var/www/html/view/smarty3/compiled + + # load other config files (*.ini.php) to the config folder (currently only local.ini.php and addon.ini.php supported) + if [ -d "/usr/src/config" ]; then + rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/ + fi + + echo "Installation finished" + else + echo "Running web-based installer on first connect!" + fi + # upgrade + else + echo "Upgrading Friendica ..." + run_as '/var/www/html/bin/console dbstructure update' + echo "Upgrading finished" + fi + fi +fi + +exec "$@" diff --git a/stack.yml b/stack.yml index 39a135e..692fd1c 100644 --- a/stack.yml +++ b/stack.yml @@ -1,55 +1,51 @@ -version: '3.2' - -services: - db: - image: mariadb - restart: always - volumes: - - db:/var/lib/mysql - environment: - - MYSQL_USER=friendica - - MYSQL_PASSWORD=friendica - - MYSQL_DATABASE=friendica - - MYSQL_RANDOM_ROOT_PASSWORD=yes - - app: - image: friendica/server - restart: always - ports: - - 8080:80 - volumes: - - friendica:/var/www/html - environment: - - AUTOINSTALL=true - - MYSQL_HOST=db - - MYSQL_PORT=3306 - - MYSQL_USER=friendica - - MYSQL_PASSWORD=friendica - - MYSQL_DATABASE=friendica - - MAILNAME=root@friendica.local - - SITENAME=Friendica PWD Test Node - - VALIDATION=false - hostname: friendica.local - depends_on: - - db - - cron: - image: friendica/server - restart: always - volumes: - - friendica:/var/www/html - entrypoint: /cron.sh - environment: - - MYSQL_HOST=db - - MYSQL_PORT=3306 - - MYSQL_USER=friendica - - MYSQL_PASSWORD=friendica - - MYSQL_DATABASE=friendica - - MAILNAME=root@friendica.local - - SITENAME=Friendica PWD Test Node - depends_on: - - db - -volumes: - db: +version: '3.2' + +services: + db: + image: mariadb + restart: always + volumes: + - db:/var/lib/mysql + environment: + - MYSQL_USER=friendica + - MYSQL_PASSWORD=friendica + - MYSQL_DATABASE=friendica + - MYSQL_RANDOM_ROOT_PASSWORD=yes + + app: + image: friendica/server + restart: always + ports: + - 8080:80 + volumes: + - friendica:/var/www/html + environment: + - MYSQL_HOST=db + - MYSQL_USER=friendica + - MYSQL_PASSWORD=friendica + - MYSQL_DATABASE=friendica + - FRIENDICA_ADMIN_MAIL=root@friendica.local + - SITENAME=Friendica PWD Test Node + hostname: friendica.local + depends_on: + - db + + cron: + image: friendica/server + restart: always + volumes: + - friendica:/var/www/html + entrypoint: /cron.sh + environment: + - MYSQL_HOST=db + - MYSQL_USER=friendica + - MYSQL_PASSWORD=friendica + - MYSQL_DATABASE=friendica + - FRIENDICA_ADMIN_MAIL=root@friendica.local + - SITENAME=Friendica PWD Test Node + depends_on: + - db + +volumes: + db: friendica: \ No newline at end of file diff --git a/update.sh b/update.sh index 0886257..95cfc98 100755 --- a/update.sh +++ b/update.sh @@ -30,7 +30,7 @@ declare -A pecl_versions=( ) declare -A install_extras=( - ['stable']='\nRUN set -ex; \\\n curl -fsSL -o friendica.tar.gz \\\n "https://github.com/friendica/friendica/archive/${FRIENDICA_VERSION}.tar.gz"; \\\n tar -xzf friendica.tar.gz -C /usr/src/; \\\n rm friendica.tar.gz; \\\n mv -f /usr/src/friendica-${FRIENDICA_VERSION}/ /usr/src/friendica; \\\n chmod 777 /usr/src/friendica/view/smarty3; \\\n curl -fsSL -o friendica_addons.tar.gz \\\n "https://github.com/friendica/friendica-addons/archive/${FRIENDICA_ADDONS}.tar.gz"; \\\n mkdir /usr/src/friendica/addon; \\\n tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \\\n rm friendica_addons.tar.gz; \\\n friendica composer install;' + ['stable']='\nRUN set -ex; \\\n curl -fsSL -o friendica.tar.gz \\\n "https://github.com/friendica/friendica/archive/${FRIENDICA_VERSION}.tar.gz"; \\\n tar -xzf friendica.tar.gz -C /usr/src/; \\\n rm friendica.tar.gz; \\\n mv -f /usr/src/friendica-${FRIENDICA_VERSION}/ /usr/src/friendica; \\\n chmod 777 /usr/src/friendica/view/smarty3; \\\n curl -fsSL -o friendica_addons.tar.gz \\\n "https://github.com/friendica/friendica-addons/archive/${FRIENDICA_ADDONS}.tar.gz"; \\\n mkdir /usr/src/friendica/addon; \\\n tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \\\n rm friendica_addons.tar.gz; \\\n /usr/src/friendica/bin/composer.phar install --no-plugins --no-scripts --no-dev -d /usr/src/friendica;' ['develop']='' ) @@ -41,8 +41,8 @@ variants=( ) versions=( - 2018.05 - 2018.08-dev + 2018.12-dev + 2018.09 ) travisEnv= @@ -84,11 +84,8 @@ function create_variant() { cp "docker-$name.sh" "$dir/$name.sh" done - # Copy the config directory - cp -rT .config "$dir/config" - - # Copy the bin directory - cp -rT .bin "$dir/bin" + # Copy the upgrade.exclude + cp upgrade.exclude "$dir/" travisEnvAmd64='\n - env: VERSION='"$1"' VARIANT='"$variant"' ARCH=amd64'"$travisEnvAmd64" for arch in i386 amd64; do diff --git a/upgrade.exclude b/upgrade.exclude new file mode 100644 index 0000000..732ba58 --- /dev/null +++ b/upgrade.exclude @@ -0,0 +1,7 @@ +/.git/ +/photo/ +/proxy/ +.htconfig.php +.htaccess +home.* +/config/ \ No newline at end of file