Bugfixing & Upgrading

- upgrade version
- fixing alpine Dockerfile (openssl to libressl)
- adding examples for SSMTP
- README updates & bugfixing
- Removed shell-script "friendica"
- Removed old .htconfig
- Adding SMTP example
- Upgrading docker-compose files
- Added upgrade.exclude list
This commit is contained in:
Philipp Holzer 2018-09-09 22:22:24 +02:00
parent b876d92b54
commit 8493e35da4
No known key found for this signature in database
GPG Key ID: 517BE60E2CE5C8A5
77 changed files with 2419 additions and 3988 deletions

View File

@ -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 <command> [<args>]"
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'
<?php
// database might not exist, so let's wait for it (just to be safe)
$stderr = fopen('php://stderr', 'w');
require_once '/usr/src/config/htconfig.php';
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
$maxTries = 10;
$connected = false;
do {
try {
// This docker image is using the PDO library
$mysql = @new PDO($connection, $db_user, $db_pass);
$connected = true;
} catch (PDOException $e) {
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
$connected = false;
--$maxTries;
if ($maxTries <= 0) {
exit(1);
}
sleep(3);
}
} while (!$connected);
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
?>
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

View File

@ -1,137 +0,0 @@
<?php
// Custom htconfig.php for Docker usage.
// Uses a lot of environment variables
// Use environment variables for mysql if they are set beforehand
if (!empty(getenv('MYSQL_HOST'))
&& !empty(getenv('MYSQL_PORT'))
&& (!empty(getenv('MYSQL_USERNAME')) || !empty(getenv('MYSQL_USER')))
&& !empty(getenv('MYSQL_PASSWORD'))
&& !empty(getenv('MYSQL_DATABASE'))) {
$db_host = getenv('MYSQL_HOST') . ':' . getenv('MYSQL_PORT');
if (!empty(getenv('MYSQL_USERNAME'))) {
$db_user = getenv('MYSQL_USERNAME');
} elseif (!empty(getenv('MYSQL_USER'))) {
$db_user = getenv('MYSQL_USER');
}
$db_pass = getenv('MYSQL_PASSWORD');
$db_data = getenv('MYSQL_DATABASE');
}
// Set the database connection charset to full Unicode (utf8mb4).
// Changing this value will likely corrupt the special characters.
// You have been warned.
$a->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');
}
}

View File

@ -16,6 +16,25 @@ 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 <a id="smtpsetting"></a>
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

View File

@ -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/

View File

@ -0,0 +1,12 @@
<?php return <<<INI
[system]
cache_driver=redis
lock_driver=redis
redis_host=redis
pidfile = /var/run/friendica.pid
INI;
// Keep this line

View File

@ -16,17 +16,15 @@ services:
restart: always
app:
image: friendica/server:apache
build: ./app
restart: always
volumes:
- friendica:/var/www/html
environment:
- AUTOINSTALL=true
- CACHE_DRIVER=redis
- REDIS_HOST=redis
- MAILNAME=
- TZ=
- LANGUAGE=
- FRIENDICA_ADMIN_MAIL=
- FRIENDICA_TZ=
- FRIENDICA_LANG=
- SITENAME=
- SMTP=
env_file:
- db.env
@ -37,20 +35,14 @@ services:
- "80:80"
cron:
image: friendica/server:apache
build: ./app
restart: always
volumes:
- friendica:/var/www/html
entrypoint: /cron.sh
environment:
- CACHE_DRIVER=redis
- REDIS_HOST=redis
- MAILNAME=
- TZ=
- LANGUAGE=
- SITENAME=
- SMTP=
env_file:
- db.env
depends_on:
- db
hostname: friendica.local

View File

@ -0,0 +1,36 @@
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 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/

View File

@ -0,0 +1,12 @@
<?php return <<<INI
[system]
cache_driver=redis
lock_driver=redis
redis_host=redis
pidfile = /var/run/friendica.pid
INI;
// Keep this line

View File

@ -16,17 +16,15 @@ services:
restart: always
app:
image: friendica/server:fpm-alpine
build: ./app
restart: always
volumes:
- friendica:/var/www/html
environment:
- AUTOINSTALL=true
- CACHE_DRIVER=redis
- REDIS_HOST=redis
- MAILNAME=
- TZ=
- LANGUAGE=
- FRIENDICA_ADMIN_MAIL=
- FRIENDICA_TZ=
- FRIENDICA_LANG=
- SITENAME=
- SMTP=
env_file:
- db.env
@ -35,20 +33,17 @@ services:
hostname: friendica.local
cron:
image: friendica/server:fpm-alpine
build: ./app
restart: always
volumes:
- friendica:/var/www/html
entrypoint: /cron.sh
environment:
- CACHE_DRIVER=redis
- REDIS_HOST=redis
- MAILNAME=
- TZ=
- LANGUAGE=
- FRIENDICA_ADMIN_MAIL=
- FRIENDICA_TZ=
- FRIENDICA_LANG=
- SITENAME=
- SMTP=
env_file:
- db.env
depends_on:
- db
- app

View File

@ -0,0 +1,41 @@
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 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/

View File

@ -0,0 +1,12 @@
<?php return <<<INI
[system]
cache_driver=redis
lock_driver=redis
redis_host=redis
pidfile = /var/run/friendica.pid
INI;
// Keep this line

View File

@ -16,17 +16,16 @@ services:
restart: always
app:
image: friendica/server:fpm
build: ./app
restart: always
volumes:
- friendica:/var/www/html
environment:
- AUTOINSTALL=true
- CACHE_DRIVER=redis
- REDIS_HOST=redis
- MAILNAME=
- TZ=
- LANGUAGE=
- FRIENDICA_ADMIN_MAIL=
- FRIENDICA_TZ=
- FRIENDICA_LANG=
- SITENAME=
- SMTP=
env_file:
- db.env
depends_on:
@ -34,19 +33,17 @@ services:
hostname: friendica.local
cron:
image: friendica/server:fpm
build: ./app
restart: always
volumes:
- friendica:/var/www/html
entrypoint: /cron.sh
environment:
- CACHE_DRIVER=redis
- REDIS_HOST=redis
- MAILNAME=
- TZ=
- LANGUAGE=
env_file:
- db.env
- FRIENDICA_ADMIN_MAIL=
- FRIENDICA_TZ=
- FRIENDICA_LANG=
- SITENAME=
- SMTP=
depends_on:
- db
- app

View File

@ -17,10 +17,9 @@ services:
volumes:
- friendica:/var/www/html
environment:
- AUTOINSTALL=true
- MAILNAME=
- TZ=
- LANGUAGE=
- FRIENDICA_ADMIN_MAIL=
- FRIENDICA_TZ=
- FRIENDICA_LANG=
env_file:
- db.env
depends_on:

View File

@ -0,0 +1,37 @@
FROM friendica/server:apache
# entrypoint.sh and cron.sh dependencies
RUN set -ex; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
# For mail() support
ssmtp \
; \
rm -rf /var/lib/apt/lists/*;
ENV SMTP localhost
ENV SMTP_FROM no-reply
ENV SITENAME "Testsite"
# Setup SSMTP
RUN sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd ;\
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd ;\
# add possible mail-senders
{\
echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" ;\
echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" ;\
} > /etc/ssmtp/revaliases;\
# replace ssmtp.conf settings
{\
echo "root=$SMTP_FROM@$HOSTNAME" ;\
echo "hostname=$HOSTNAME" ;\
echo "mailhub=$SMTP" ;\
echo "FromLineOverride=YES" ;\
[ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" ;\
[ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" ;\
[ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" ;\
[ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" ;\
[ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" ;\
} > /etc/ssmtp/ssmtp.conf;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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 <command> [<args>]"
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'
<?php
// database might not exist, so let's wait for it (just to be safe)
$stderr = fopen('php://stderr', 'w');
require_once '/usr/src/config/htconfig.php';
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
$maxTries = 10;
$connected = false;
do {
try {
// This docker image is using the PDO library
$mysql = @new PDO($connection, $db_user, $db_pass);
$connected = true;
} catch (PDOException $e) {
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
$connected = false;
--$maxTries;
if ($maxTries <= 0) {
exit(1);
}
sleep(3);
}
} while (!$connected);
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
?>
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

View File

@ -1,137 +0,0 @@
<?php
// Custom htconfig.php for Docker usage.
// Uses a lot of environment variables
// Use environment variables for mysql if they are set beforehand
if (!empty(getenv('MYSQL_HOST'))
&& !empty(getenv('MYSQL_PORT'))
&& (!empty(getenv('MYSQL_USERNAME')) || !empty(getenv('MYSQL_USER')))
&& !empty(getenv('MYSQL_PASSWORD'))
&& !empty(getenv('MYSQL_DATABASE'))) {
$db_host = getenv('MYSQL_HOST') . ':' . getenv('MYSQL_PORT');
if (!empty(getenv('MYSQL_USERNAME'))) {
$db_user = getenv('MYSQL_USERNAME');
} elseif (!empty(getenv('MYSQL_USER'))) {
$db_user = getenv('MYSQL_USER');
}
$db_pass = getenv('MYSQL_PASSWORD');
$db_data = getenv('MYSQL_DATABASE');
}
// Set the database connection charset to full Unicode (utf8mb4).
// Changing this value will likely corrupt the special characters.
// You have been warned.
$a->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');
}
}

View File

@ -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

View File

@ -1,7 +0,0 @@
#!/bin/sh
set -eu
friendica install -q
friendica configmail -q
exec "$@"

View File

@ -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 <command> [<args>]"
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'
<?php
// database might not exist, so let's wait for it (just to be safe)
$stderr = fopen('php://stderr', 'w');
require_once '/usr/src/config/htconfig.php';
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
$maxTries = 10;
$connected = false;
do {
try {
// This docker image is using the PDO library
$mysql = @new PDO($connection, $db_user, $db_pass);
$connected = true;
} catch (PDOException $e) {
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
$connected = false;
--$maxTries;
if ($maxTries <= 0) {
exit(1);
}
sleep(3);
}
} while (!$connected);
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
?>
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

View File

@ -1,137 +0,0 @@
<?php
// Custom htconfig.php for Docker usage.
// Uses a lot of environment variables
// Use environment variables for mysql if they are set beforehand
if (!empty(getenv('MYSQL_HOST'))
&& !empty(getenv('MYSQL_PORT'))
&& (!empty(getenv('MYSQL_USERNAME')) || !empty(getenv('MYSQL_USER')))
&& !empty(getenv('MYSQL_PASSWORD'))
&& !empty(getenv('MYSQL_DATABASE'))) {
$db_host = getenv('MYSQL_HOST') . ':' . getenv('MYSQL_PORT');
if (!empty(getenv('MYSQL_USERNAME'))) {
$db_user = getenv('MYSQL_USERNAME');
} elseif (!empty(getenv('MYSQL_USER'))) {
$db_user = getenv('MYSQL_USER');
}
$db_pass = getenv('MYSQL_PASSWORD');
$db_data = getenv('MYSQL_DATABASE');
}
// Set the database connection charset to full Unicode (utf8mb4).
// Changing this value will likely corrupt the special characters.
// You have been warned.
$a->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');
}
}

View File

@ -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

View File

@ -1,7 +0,0 @@
#!/bin/sh
set -eu
friendica install -q
friendica configmail -q
exec "$@"

View File

@ -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 <command> [<args>]"
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'
<?php
// database might not exist, so let's wait for it (just to be safe)
$stderr = fopen('php://stderr', 'w');
require_once '/usr/src/config/htconfig.php';
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
$maxTries = 10;
$connected = false;
do {
try {
// This docker image is using the PDO library
$mysql = @new PDO($connection, $db_user, $db_pass);
$connected = true;
} catch (PDOException $e) {
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
$connected = false;
--$maxTries;
if ($maxTries <= 0) {
exit(1);
}
sleep(3);
}
} while (!$connected);
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
?>
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

View File

@ -1,137 +0,0 @@
<?php
// Custom htconfig.php for Docker usage.
// Uses a lot of environment variables
// Use environment variables for mysql if they are set beforehand
if (!empty(getenv('MYSQL_HOST'))
&& !empty(getenv('MYSQL_PORT'))
&& (!empty(getenv('MYSQL_USERNAME')) || !empty(getenv('MYSQL_USER')))
&& !empty(getenv('MYSQL_PASSWORD'))
&& !empty(getenv('MYSQL_DATABASE'))) {
$db_host = getenv('MYSQL_HOST') . ':' . getenv('MYSQL_PORT');
if (!empty(getenv('MYSQL_USERNAME'))) {
$db_user = getenv('MYSQL_USERNAME');
} elseif (!empty(getenv('MYSQL_USER'))) {
$db_user = getenv('MYSQL_USER');
}
$db_pass = getenv('MYSQL_PASSWORD');
$db_data = getenv('MYSQL_DATABASE');
}
// Set the database connection charset to full Unicode (utf8mb4).
// Changing this value will likely corrupt the special characters.
// You have been warned.
$a->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');
}
}

View File

@ -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

View File

@ -1,7 +0,0 @@
#!/bin/sh
set -eu
friendica install -q
friendica configmail -q
exec "$@"

View File

@ -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 <command> [<args>]"
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'
<?php
// database might not exist, so let's wait for it (just to be safe)
$stderr = fopen('php://stderr', 'w');
require_once '/usr/src/config/htconfig.php';
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
$maxTries = 10;
$connected = false;
do {
try {
// This docker image is using the PDO library
$mysql = @new PDO($connection, $db_user, $db_pass);
$connected = true;
} catch (PDOException $e) {
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
$connected = false;
--$maxTries;
if ($maxTries <= 0) {
exit(1);
}
sleep(3);
}
} while (!$connected);
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
?>
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

View File

@ -1,137 +0,0 @@
<?php
// Custom htconfig.php for Docker usage.
// Uses a lot of environment variables
// Use environment variables for mysql if they are set beforehand
if (!empty(getenv('MYSQL_HOST'))
&& !empty(getenv('MYSQL_PORT'))
&& (!empty(getenv('MYSQL_USERNAME')) || !empty(getenv('MYSQL_USER')))
&& !empty(getenv('MYSQL_PASSWORD'))
&& !empty(getenv('MYSQL_DATABASE'))) {
$db_host = getenv('MYSQL_HOST') . ':' . getenv('MYSQL_PORT');
if (!empty(getenv('MYSQL_USERNAME'))) {
$db_user = getenv('MYSQL_USERNAME');
} elseif (!empty(getenv('MYSQL_USER'))) {
$db_user = getenv('MYSQL_USER');
}
$db_pass = getenv('MYSQL_PASSWORD');
$db_data = getenv('MYSQL_DATABASE');
}
// Set the database connection charset to full Unicode (utf8mb4).
// Changing this value will likely corrupt the special characters.
// You have been warned.
$a->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');
}
}

View File

@ -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

View File

@ -1,7 +0,0 @@
#!/bin/sh
set -eu
friendica install -q
friendica configmail -q
exec "$@"

View File

@ -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 <command> [<args>]"
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'
<?php
// database might not exist, so let's wait for it (just to be safe)
$stderr = fopen('php://stderr', 'w');
require_once '/usr/src/config/htconfig.php';
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
$maxTries = 10;
$connected = false;
do {
try {
// This docker image is using the PDO library
$mysql = @new PDO($connection, $db_user, $db_pass);
$connected = true;
} catch (PDOException $e) {
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
$connected = false;
--$maxTries;
if ($maxTries <= 0) {
exit(1);
}
sleep(3);
}
} while (!$connected);
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
?>
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

View File

@ -1,137 +0,0 @@
<?php
// Custom htconfig.php for Docker usage.
// Uses a lot of environment variables
// Use environment variables for mysql if they are set beforehand
if (!empty(getenv('MYSQL_HOST'))
&& !empty(getenv('MYSQL_PORT'))
&& (!empty(getenv('MYSQL_USERNAME')) || !empty(getenv('MYSQL_USER')))
&& !empty(getenv('MYSQL_PASSWORD'))
&& !empty(getenv('MYSQL_DATABASE'))) {
$db_host = getenv('MYSQL_HOST') . ':' . getenv('MYSQL_PORT');
if (!empty(getenv('MYSQL_USERNAME'))) {
$db_user = getenv('MYSQL_USERNAME');
} elseif (!empty(getenv('MYSQL_USER'))) {
$db_user = getenv('MYSQL_USER');
}
$db_pass = getenv('MYSQL_PASSWORD');
$db_data = getenv('MYSQL_DATABASE');
}
// Set the database connection charset to full Unicode (utf8mb4).
// Changing this value will likely corrupt the special characters.
// You have been warned.
$a->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');
}
}

View File

@ -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

View File

@ -1,7 +0,0 @@
#!/bin/sh
set -eu
friendica install -q
friendica configmail -q
exec "$@"

View File

@ -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 <command> [<args>]"
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'
<?php
// database might not exist, so let's wait for it (just to be safe)
$stderr = fopen('php://stderr', 'w');
require_once '/usr/src/config/htconfig.php';
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
$maxTries = 10;
$connected = false;
do {
try {
// This docker image is using the PDO library
$mysql = @new PDO($connection, $db_user, $db_pass);
$connected = true;
} catch (PDOException $e) {
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
$connected = false;
--$maxTries;
if ($maxTries <= 0) {
exit(1);
}
sleep(3);
}
} while (!$connected);
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
?>
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

View File

@ -1,137 +0,0 @@
<?php
// Custom htconfig.php for Docker usage.
// Uses a lot of environment variables
// Use environment variables for mysql if they are set beforehand
if (!empty(getenv('MYSQL_HOST'))
&& !empty(getenv('MYSQL_PORT'))
&& (!empty(getenv('MYSQL_USERNAME')) || !empty(getenv('MYSQL_USER')))
&& !empty(getenv('MYSQL_PASSWORD'))
&& !empty(getenv('MYSQL_DATABASE'))) {
$db_host = getenv('MYSQL_HOST') . ':' . getenv('MYSQL_PORT');
if (!empty(getenv('MYSQL_USERNAME'))) {
$db_user = getenv('MYSQL_USERNAME');
} elseif (!empty(getenv('MYSQL_USER'))) {
$db_user = getenv('MYSQL_USER');
}
$db_pass = getenv('MYSQL_PASSWORD');
$db_data = getenv('MYSQL_DATABASE');
}
// Set the database connection charset to full Unicode (utf8mb4).
// Changing this value will likely corrupt the special characters.
// You have been warned.
$a->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');
}
}

View File

@ -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

View File

@ -1,7 +0,0 @@
#!/bin/sh
set -eu
friendica install -q
friendica configmail -q
exec "$@"

View File

@ -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"]

11
2018.09/apache/cron.sh Normal file
View File

@ -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

View File

@ -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 "$@"

View File

@ -0,0 +1,7 @@
/.git/
/photo/
/proxy/
.htconfig.php
.htaccess
home.*
/config/

View File

@ -6,9 +6,7 @@ LABEL maintainer="Philipp Holzer <admin@philipp.info>"
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"]

View File

@ -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

View File

@ -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 "$@"

View File

@ -0,0 +1,7 @@
/.git/
/photo/
/proxy/
.htconfig.php
.htaccess
home.*
/config/

View File

@ -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"]

11
2018.09/fpm/cron.sh Normal file
View File

@ -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

171
2018.09/fpm/entrypoint.sh Normal file
View File

@ -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 "$@"

View File

@ -0,0 +1,7 @@
/.git/
/photo/
/proxy/
.htconfig.php
.htaccess
home.*
/config/

View File

@ -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"]

View File

@ -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

View File

@ -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 "$@"

View File

@ -0,0 +1,7 @@
/.git/
/photo/
/proxy/
.htconfig.php
.htaccess
home.*
/config/

View File

@ -6,9 +6,7 @@ LABEL maintainer="Philipp Holzer <admin@philipp.info>"
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.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"]

View File

@ -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

View File

@ -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 "$@"

View File

@ -0,0 +1,7 @@
/.git/
/photo/
/proxy/
.htconfig.php
.htaccess
home.*
/config/

View File

@ -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"]

11
2018.12-dev/fpm/cron.sh Normal file
View File

@ -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

View File

@ -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 "$@"

View File

@ -0,0 +1,7 @@
/.git/
/photo/
/proxy/
.htconfig.php
.htaccess
home.*
/config/

View File

@ -5,9 +5,7 @@ LABEL maintainer="Philipp Holzer <admin@philipp.info>"
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,28 +72,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
%%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"]

View File

@ -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"]

View File

@ -4,7 +4,8 @@ The structure and usage of this repository is influenced by other, official dock
# Version directories
**This is important.**
**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.
@ -13,25 +14,6 @@ All changes in such folders will get overwritten during an update.
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.

View File

@ -64,41 +64,24 @@ There are three options to enable the cron-job for Friendica:
- 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
## Possible Environment Variables
This is the full list of all possible environment variables used for this image:
**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.
**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**)
**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.
**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`)
- `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
@ -106,12 +89,7 @@ Because Friendica links the administrator account to a specific mail address, yo
## 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`.
see the [example](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/README.md#smtpsetting)
## Database settings
@ -150,51 +128,41 @@ $ docker run -d \
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`.
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 [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.
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 you can just update your node with executing `friendica update` on the node.
Example:
```console
$ docker exec -ti friendica_running_node friendica update
```
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.
## 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 <command>
```
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.
@ -237,11 +205,10 @@ services:
- "8080:80"
environment:
- MYSQL_HOST=db
- MYSQL_PORT=3306
- MYSQL_USER=friendica
- MYSQL_PASSWORD=
- MYSQL_DATABASE=friendica
- MAILNAME=root@friendica.local
- FRIENDICA_ADMIN_MAIL=root@friendica.local
hostname: friendica.local
depends_on:
- db
@ -292,11 +259,10 @@ services:
- friendica:/var/www/html
environment:
- MYSQL_HOST=db
- MYSQL_PORT=3306
- MYSQL_USER=friendica
- MYSQL_PASSWORD=
- MYSQL_DATABASE=friendica
- MAILNAME=root@friendica.local
- FRIENDICA_ADMIN_MAIL=root@friendica.local
hostname: friendica.local
networks:
- proxy-tier

View File

@ -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
# 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

View File

@ -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
}
# 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 "$@"

View File

@ -20,15 +20,12 @@ services:
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
- FRIENDICA_ADMIN_MAIL=root@friendica.local
- SITENAME=Friendica PWD Test Node
- VALIDATION=false
hostname: friendica.local
depends_on:
- db
@ -41,11 +38,10 @@ services:
entrypoint: /cron.sh
environment:
- MYSQL_HOST=db
- MYSQL_PORT=3306
- MYSQL_USER=friendica
- MYSQL_PASSWORD=friendica
- MYSQL_DATABASE=friendica
- MAILNAME=root@friendica.local
- FRIENDICA_ADMIN_MAIL=root@friendica.local
- SITENAME=Friendica PWD Test Node
depends_on:
- db

View File

@ -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

7
upgrade.exclude Normal file
View File

@ -0,0 +1,7 @@
/.git/
/photo/
/proxy/
.htconfig.php
.htaccess
home.*
/config/