2
0
Fork 0
mirror of https://github.com/friendica/docker synced 2024-09-25 19:01:19 +02:00

Merge pull request #30 from nupplaphil/upgrade_repo

Bugfixing & Upgrading
This commit is contained in:
Hypolite Petovan 2018-10-08 22:48:17 -04:00 committed by GitHub
commit 6a42a2f355
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
75 changed files with 2368 additions and 3976 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

@ -1,68 +1,68 @@
# Examples section # Examples section
In this subfolder are some examples how to use the docker images. In this subfolder are some examples how to use the docker images.
There are two section: There are two section:
* [`dockerfiles`](https://github.com/friendica/docker/tree/master/.examples/dockerfiles) * [`dockerfiles`](https://github.com/friendica/docker/tree/master/.examples/dockerfiles)
* [`docker-compose`](https://github.com/friendica/docker/tree/master/.examples/docker-compose) * [`docker-compose`](https://github.com/friendica/docker/tree/master/.examples/docker-compose)
The `dockerfiles` are derived images that add or alter certain functionalities of the default docker images. The `dockerfiles` are derived images that add or alter certain functionalities of the default docker images.
In the `docker-compose` subfolder are examples for deployment of the application. In the `docker-compose` subfolder are examples for deployment of the application.
## Dockerfiles ## Dockerfiles
The Dockerfiles use the default images as base image and build on top of it. The Dockerfiles use the default images as base image and build on top of it.
Examples | Descriptions 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). [cron](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/cron) | uses supervisor to run the cron job inside the container (so no extra container is needed).
## docker-compose ## docker-compose
In `docker-compose` additional services are bundled to create a complex Friendica installation. In `docker-compose` additional services are bundled to create a complex Friendica installation.
The examples are designed to run out-of-the-box. The examples are designed to run out-of-the-box.
Before running the examples, you have to modify the `db.env` and `docker-compose.yml` file and fill in your custom information. Before running the examples, you have to modify the `db.env` and `docker-compose.yml` file and fill in your custom information.
The docker-compose examples make heavily use of derived Dockerfiles to add configuration files into the containers. The docker-compose examples make heavily use of derived Dockerfiles to add configuration files into the containers.
This way they should also work on remote docker systems as _Docker for Windows_. This way they should also work on remote docker systems as _Docker for Windows_.
when running docker-compose on the same host as the docker daemon, another possibility would be to simply mount the files in the volumes section in the `docker-compose.yml` file. when running docker-compose on the same host as the docker daemon, another possibility would be to simply mount the files in the volumes section in the `docker-compose.yml` file.
### insecure ### insecure
This examples should only be used for **testing** on the local network because it uses a unencrypted http connection. These examples should only be used for **testing** on the local network because they use an unencrypted http connection.
When you want to have your server reachable from the internet adding HTTPS-encryption is mandatory! When you want to have your server reachable from the internet adding HTTPS-encryption is mandatory!
For this use one of the [with-traefik-proxy](#with-traefik-proxy) examples. For this use one of the [with-traefik-proxy](#with-traefik-proxy) examples.
To use this example complete the following steps: To use one of these examples, complete the following steps:
1. choose a password for the database user in `db.env` behind `MYSQL_PASSWORD=` 1. choose a password for the database user in `db.env` behind `MYSQL_PASSWORD=`
2. run `docker-compose build --pull` to pull the mose recent base images and build the custom dockerfiles 2. run `docker-compose build --pull` to pull the mose recent base images and build the custom dockerfiles
3. start Friendica with `docker-compose up -d` 3. start Friendica with `docker-compose up -d`
If you want to update your installation to a newer version, repeat 3 and 4. If you want to update your installation to a newer version, repeat 3 and 4.
**Note**: If you are on a develop branch (*-dev or *-rc) you have to update Friendica with the command `docker-compose exec app friendica update` **Note**: If you are on a develop branch (*-dev or *-rc) you have to set the environment variable `FRIENDICA_UPGRADE=true` to update Friendica.
### with-traefik-proxy ### with-traefik-proxy
The traefik proxy adds a proxy layer between Friendica and the internet. The traefik proxy adds a proxy layer between Friendica and the internet.
The proxy is designed to server multiple sites on the same host machine. The proxy is designed to server multiple sites on the same host machine.
The advantage in adding this layer is the ability to use [Let's Encrypt](https://letsencrypt.org/) out certification handling of the box. The advantage in adding this layer is the ability to use [Let's Encrypt](https://letsencrypt.org/) out certification handling of the box.
Therefore you have to use adjust the `labels:` inside the `docker-compose.yml` to let traefik know what domains it should route and what certifications it should request. Therefore you have to use adjust the `labels:` inside the `docker-compose.yml` to let traefik know what domains it should route and what certifications it should request.
To use this example complete the following steps: To use this example complete the following steps:
1. open `docker-compose.yml` 1. open `docker-compose.yml`
1. insert your friendica domain behind `hostname:` 1. insert your friendica domain behind `hostname:`
2. insert your friendica domain at `traefik.friendica.rule=Host:friendica.local` 2. insert your friendica domain at `traefik.friendica.rule=Host:friendica.local`
2. choose a password for the database user in `db.env` behind `MYSQL_PASSWORD=` 2. choose a password for the database user in `db.env` behind `MYSQL_PASSWORD=`
3. open `proxy/traefik.toml` 3. open `proxy/traefik.toml`
1. replace `domain = "example.org"` with your friendica domain 1. replace `domain = "example.org"` with your friendica domain
2. replace `email = "root@example.org"` with a valid email 2. replace `email = "root@example.org"` with a valid email
4. run `docker-compose build --pull` to pull the most recent base images and build the custom dockerfiles 4. run `docker-compose build --pull` to pull the most recent base images and build the custom dockerfiles
5. start Friendica with `docker-compose up -d` 5. start Friendica with `docker-compose up -d`
If you want to update your installation to a newer version, repeat 4 and 5. If you want to update your installation to a newer version, repeat 4 and 5.
**Note**: If you are on a develop branch (*-dev or *-rc) you have to update Friendica with the command `docker-compose exec app friendica update` **Note**: If you are on a develop branch (*-dev or *-rc) you have to set the environment variable `FRIENDICA_UPGRADE=true` to update Friendica.

View file

@ -0,0 +1,4 @@
FROM friendica/server:apache
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

@ -1,5 +1,5 @@
MYSQL_PASSWORD= MYSQL_PASSWORD=
MYSQL_DATABASE=friendica MYSQL_DATABASE=friendica
MYSQL_USER=friendica MYSQL_USER=friendica
MYSQL_HOST=db MYSQL_HOST=db
MYSQL_PORT=3306 MYSQL_PORT=3306

View file

@ -1,60 +1,49 @@
version: '2.1' version: '2.1'
services: services:
db: db:
image: mariadb image: mariadb
restart: always restart: always
volumes: volumes:
- db:/var/lib/mysql/ - db:/var/lib/mysql/
environment: environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes - MYSQL_RANDOM_ROOT_PASSWORD=yes
env_file: env_file:
- db.env - db.env
redis: redis:
image: redis image: redis
restart: always restart: always
app: app:
image: friendica/server:apache build: ./app
restart: always restart: always
volumes: volumes:
- friendica:/var/www/html - friendica:/var/www/html
environment: environment:
- AUTOINSTALL=true - FRIENDICA_ADMIN_MAIL=
- CACHE_DRIVER=redis - FRIENDICA_TZ=
- REDIS_HOST=redis - FRIENDICA_LANG=
- MAILNAME= - SITENAME=
- TZ= - SMTP=
- LANGUAGE= env_file:
- SMTP= - db.env
env_file: depends_on:
- db.env - db
depends_on: hostname: friendica.local
- db ports:
hostname: friendica.local - "80:80"
ports:
- "80:80" cron:
build: ./app
cron: restart: always
image: friendica/server:apache volumes:
restart: always - friendica:/var/www/html
volumes: entrypoint: /cron.sh
- friendica:/var/www/html depends_on:
entrypoint: /cron.sh - db
environment: hostname: friendica.local
- CACHE_DRIVER=redis
- REDIS_HOST=redis volumes:
- MAILNAME= db:
- TZ=
- LANGUAGE=
- SMTP=
env_file:
- db.env
depends_on:
- db
hostname: friendica.local
volumes:
db:
friendica: friendica:

View file

@ -0,0 +1,4 @@
FROM friendica/server:fpm-alpine
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

@ -1,70 +1,59 @@
version: '2.1' version: '2.1'
services: services:
db: db:
image: mariadb image: mariadb
restart: always restart: always
volumes: volumes:
- db:/var/lib/mysql/ - db:/var/lib/mysql/
environment: environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes - MYSQL_RANDOM_ROOT_PASSWORD=yes
env_file: env_file:
- db.env - db.env
redis: redis:
image: redis image: redis
restart: always restart: always
app: app:
image: friendica/server:fpm-alpine build: ./app
restart: always restart: always
volumes: volumes:
- friendica:/var/www/html - friendica:/var/www/html
environment: environment:
- AUTOINSTALL=true - FRIENDICA_ADMIN_MAIL=
- CACHE_DRIVER=redis - FRIENDICA_TZ=
- REDIS_HOST=redis - FRIENDICA_LANG=
- MAILNAME= - SITENAME=
- TZ= - SMTP=
- LANGUAGE= env_file:
- SMTP= - db.env
env_file: depends_on:
- db.env - db
depends_on: hostname: friendica.local
- db
hostname: friendica.local cron:
build: ./app
cron: restart: always
image: friendica/server:fpm-alpine volumes:
restart: always - friendica:/var/www/html
volumes: entrypoint: /cron.sh
- friendica:/var/www/html depends_on:
entrypoint: /cron.sh - db
environment: - app
- CACHE_DRIVER=redis hostname: friendica.local
- REDIS_HOST=redis
- MAILNAME= web:
- TZ= image: nginx
- LANGUAGE= restart: always
- SMTP= volumes:
env_file: - friendica:/var/www/html:ro
- db.env - ./web/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on: depends_on:
- db - app
- app ports:
hostname: friendica.local - "80:80"
web: volumes:
image: nginx db:
restart: always
volumes:
- friendica:/var/www/html:ro
- ./web/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- app
ports:
- "80:80"
volumes:
db:
friendica: friendica:

View file

@ -0,0 +1,4 @@
FROM friendica/server:fpm
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

@ -1,68 +1,59 @@
version: '2.1' version: '2.1'
services: services:
db: db:
image: mariadb image: mariadb
restart: always restart: always
volumes: volumes:
- db:/var/lib/mysql/ - db:/var/lib/mysql/
environment: environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes - MYSQL_RANDOM_ROOT_PASSWORD=yes
env_file: env_file:
- db.env - db.env
redis: redis:
image: redis image: redis
restart: always restart: always
app: app:
image: friendica/server:fpm build: ./app
restart: always restart: always
volumes: volumes:
- friendica:/var/www/html - friendica:/var/www/html
environment: environment:
- AUTOINSTALL=true - FRIENDICA_ADMIN_MAIL=
- CACHE_DRIVER=redis - FRIENDICA_TZ=
- REDIS_HOST=redis - FRIENDICA_LANG=
- MAILNAME= - SITENAME=
- TZ= - SMTP=
- LANGUAGE= env_file:
env_file: - db.env
- db.env depends_on:
depends_on: - db
- db hostname: friendica.local
hostname: friendica.local
cron:
cron: build: ./app
image: friendica/server:fpm restart: always
restart: always volumes:
volumes: - friendica:/var/www/html
- friendica:/var/www/html entrypoint: /cron.sh
entrypoint: /cron.sh depends_on:
environment: - db
- CACHE_DRIVER=redis - app
- REDIS_HOST=redis hostname: friendica.local
- MAILNAME=
- TZ= web:
- LANGUAGE= image: nginx
env_file: restart: always
- db.env volumes:
depends_on: - friendica:/var/www/html:ro
- db - ./web/nginx.conf:/etc/nginx/nginx.conf:ro
- app depends_on:
hostname: friendica.local - app
ports:
web: - "80:80"
image: nginx
restart: always volumes:
volumes: db:
- friendica:/var/www/html:ro
- ./web/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- app
ports:
- "80:80"
volumes:
db:
friendica: friendica:

View file

@ -1,87 +1,86 @@
version: '2.1' version: '2.1'
services: services:
db: db:
image: mariadb image: mariadb
restart: always restart: always
volumes: volumes:
- db:/var/lib/mysql/ - db:/var/lib/mysql/
environment: environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes - MYSQL_RANDOM_ROOT_PASSWORD=yes
env_file: env_file:
- db.env - db.env
app: app:
build: ./app build: ./app
restart: always restart: always
volumes: volumes:
- friendica:/var/www/html - friendica:/var/www/html
environment: environment:
- AUTOINSTALL=true - FRIENDICA_ADMIN_MAIL=
- MAILNAME= - FRIENDICA_TZ=
- TZ= - FRIENDICA_LANG=
- LANGUAGE= env_file:
env_file: - db.env
- db.env depends_on:
depends_on: - db
- db hostname: friendica.local
hostname: friendica.local
cron:
cron: build: ./app
build: ./app restart: always
restart: always volumes:
volumes: - friendica:/var/www/html
- friendica:/var/www/html entrypoint: /cron.sh
entrypoint: /cron.sh environment:
environment: - MAILNAME=
- MAILNAME= - TZ=
- TZ= - LANGUAGE=
- LANGUAGE= env_file:
env_file: - db.env
- db.env depends_on:
depends_on: - db
- db - app
- app hostname: friendica.local
hostname: friendica.local
web:
web: image: nginx
image: nginx restart: always
restart: always volumes:
volumes: - friendica:/var/www/html:ro
- friendica:/var/www/html:ro - ./web/nginx.conf:/etc/nginx/nginx.conf:ro
- ./web/nginx.conf:/etc/nginx/nginx.conf:ro depends_on:
depends_on: - app
- app networks:
networks: - default
- default - proxy-tier
- proxy-tier labels:
labels: - "traefik.backend=friendica"
- "traefik.backend=friendica" - "traefik.frontend.entryPoints=https,http"
- "traefik.frontend.entryPoints=https,http" - "traefik.frontend.headers.STSSeconds=15768000"
- "traefik.frontend.headers.STSSeconds=15768000" - "traefik.frontend.headers.STSIncludeSubdomains=false"
- "traefik.frontend.headers.STSIncludeSubdomains=false" - "traefik.frontend.headers.forceSTSHeader=true"
- "traefik.frontend.headers.forceSTSHeader=true" - "traefik.friendica.frontend.rule=Host:friendica.local"
- "traefik.friendica.frontend.rule=Host:friendica.local" - "traefik.friendica.frontend.port=80"
- "traefik.friendica.frontend.port=80" - "traefik.enable=true"
- "traefik.enable=true" - "traefik.docker.network=proxy-tier"
- "traefik.docker.network=proxy-tier"
proxy:
proxy: build: ./proxy
build: ./proxy restart: always
restart: always ports:
ports: - "80:80"
- "80:80" - "443:443"
- "443:443" volumes:
volumes: - /var/run/docker.sock:/var/run/docker.sock
- /var/run/docker.sock:/var/run/docker.sock container_name: traefik
container_name: traefik networks:
networks: - default
- default - proxy-tier
- proxy-tier
volumes:
volumes: db:
db: friendica:
friendica:
networks:
networks:
proxy-tier: proxy-tier:

View file

@ -11,4 +11,4 @@ RUN set -ex; \
COPY supervisord.conf /etc/supervisor/supervisord.conf COPY supervisord.conf /etc/supervisor/supervisord.conf
CMD ["/usr/bin/supervisord"] CMD ["/usr/bin/supervisord"]

View file

@ -11,4 +11,4 @@ RUN set -ex; \
COPY supervisord.conf /etc/supervisor/supervisord.conf COPY supervisord.conf /etc/supervisor/supervisord.conf
CMD ["/usr/bin/supervisord"] CMD ["/usr/bin/supervisord"]

View file

@ -54,23 +54,23 @@ jobs:
- ./generate-stackbrew-library.sh - ./generate-stackbrew-library.sh
- stage: test images (amd64) - stage: test images (amd64)
env: VERSION=2018.08-dev VARIANT=fpm-alpine ARCH=amd64 env: VERSION=2018.09 VARIANT=fpm-alpine ARCH=amd64
- env: VERSION=2018.08-dev VARIANT=fpm ARCH=amd64 - env: VERSION=2018.09 VARIANT=fpm ARCH=amd64
- env: VERSION=2018.08-dev VARIANT=apache ARCH=amd64 - env: VERSION=2018.09 VARIANT=apache ARCH=amd64
- env: VERSION=2018.05 VARIANT=fpm-alpine ARCH=amd64 - env: VERSION=2018.12-dev VARIANT=fpm-alpine ARCH=amd64
- env: VERSION=2018.05 VARIANT=fpm ARCH=amd64 - env: VERSION=2018.12-dev VARIANT=fpm ARCH=amd64
- env: VERSION=2018.05 VARIANT=apache ARCH=amd64 - env: VERSION=2018.12-dev VARIANT=apache ARCH=amd64
- stage: test images (full) - stage: test images (full)
env: VERSION=2018.08-dev VARIANT=fpm-alpine ARCH=amd64 env: VERSION=2018.09 VARIANT=fpm-alpine ARCH=amd64
- env: VERSION=2018.08-dev VARIANT=fpm-alpine ARCH=i386 - env: VERSION=2018.09 VARIANT=fpm-alpine ARCH=i386
- env: VERSION=2018.08-dev VARIANT=fpm ARCH=amd64 - env: VERSION=2018.09 VARIANT=fpm ARCH=amd64
- env: VERSION=2018.08-dev VARIANT=fpm ARCH=i386 - env: VERSION=2018.09 VARIANT=fpm ARCH=i386
- env: VERSION=2018.08-dev VARIANT=apache ARCH=amd64 - env: VERSION=2018.09 VARIANT=apache ARCH=amd64
- env: VERSION=2018.08-dev VARIANT=apache ARCH=i386 - env: VERSION=2018.09 VARIANT=apache ARCH=i386
- env: VERSION=2018.05 VARIANT=fpm-alpine ARCH=amd64 - env: VERSION=2018.12-dev VARIANT=fpm-alpine ARCH=amd64
- env: VERSION=2018.05 VARIANT=fpm-alpine ARCH=i386 - env: VERSION=2018.12-dev VARIANT=fpm-alpine ARCH=i386
- env: VERSION=2018.05 VARIANT=fpm ARCH=amd64 - env: VERSION=2018.12-dev VARIANT=fpm ARCH=amd64
- env: VERSION=2018.05 VARIANT=fpm ARCH=i386 - env: VERSION=2018.12-dev VARIANT=fpm ARCH=i386
- env: VERSION=2018.05 VARIANT=apache ARCH=amd64 - env: VERSION=2018.12-dev VARIANT=apache ARCH=amd64
- env: VERSION=2018.05 VARIANT=apache ARCH=i386 - 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

@ -88,6 +88,7 @@ RUN chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME /var/www/html
WORKDIR /var/www/html
RUN a2enmod rewrite remoteip ;\ RUN a2enmod rewrite remoteip ;\
{\ {\
@ -102,18 +103,11 @@ RUN {\
echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\
} > /usr/local/etc/php/conf.d/sendmail.ini; } > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false COPY *.sh upgrade.exclude /
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 /
RUN chmod +x /*.sh RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
ENV FRIENDICA_VERSION 2018.09
ENV FRIENDICA_ADDONS 2018.09
RUN set -ex; \ RUN set -ex; \
curl -fsSL -o friendica.tar.gz \ curl -fsSL -o friendica.tar.gz \
@ -127,7 +121,7 @@ RUN set -ex; \
mkdir /usr/src/friendica/addon; \ mkdir /usr/src/friendica/addon; \
tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \
rm friendica_addons.tar.gz; \ rm friendica_addons.tar.gz; \
friendica composer install; /usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica;
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"] 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,195 @@
#!/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" ]
}
# 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 -d /usr/src/friendica
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
smtp_from=${SMTP_FROM:-no-reply}
# Setup SSMTP
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd
# add possible mail-senders
{
echo "www-data:$smtp_from@$HOSTNAME:$SMTP" ;
echo "root::$smtp_from@$HOSTNAME:$SMTP" ;
} > /etc/ssmtp/revaliases;
# replace ssmtp.conf settings
{
echo "root=:$smtp_from@$HOSTNAME" ;
echo "hostname=$HOSTNAME" ;
echo "mailhub=$SMTP" ;
echo "FromLineOverride=YES" ;
if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi
if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi
if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi
if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi
if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi
} > /etc/ssmtp/ssmtp.conf
echo "Setup finished"
fi
}
# just check if we execute apache or php-fpm
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
setup_ssmtp
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/
# 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 "cd /var/www/html; php /var/www/html/bin/console.php 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 'cd /var/www/html; php /var/www/html/bin/console.php dbstructure update'
echo "Upgrading finished"
fi
fi
fi
exec "$@"

View file

@ -0,0 +1,8 @@
/.git/
/photo/
/proxy/
.htconfig.php
.htaccess
home.*
/config/local.ini.php
/config/addon.ini.php

View file

@ -7,7 +7,7 @@ RUN set -ex; \
apk add --no-cache \ apk add --no-cache \
rsync \ rsync \
git \ git \
# For mail() support # For mail() support
ssmtp; ssmtp;
# install the PHP extensions we need # install the PHP extensions we need
@ -21,8 +21,8 @@ RUN set -ex; \
autoconf \ autoconf \
g++ \ g++ \
make \ make \
openssl \ libressl \
openssl-dev \ libressl-dev \
libpng \ libpng \
libpng-dev \ libpng-dev \
libjpeg-turbo-dev \ libjpeg-turbo-dev \
@ -75,28 +75,22 @@ RUN set -ex; \
apk add --virtual .friendica-phpext-rundeps $runDeps; \ apk add --virtual .friendica-phpext-rundeps $runDeps; \
apk del .build-deps; 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 chmod -R g=u /var/www
VOLUME /var/www/html VOLUME /var/www/html
WORKDIR /var/www/html
RUN {\ RUN {\
echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\
} > /usr/local/etc/php/conf.d/sendmail.ini; } > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false COPY *.sh upgrade.exclude /
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 /
RUN chmod +x /*.sh RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
ENV FRIENDICA_VERSION 2018.09
ENV FRIENDICA_ADDONS 2018.09
RUN set -ex; \ RUN set -ex; \
curl -fsSL -o friendica.tar.gz \ curl -fsSL -o friendica.tar.gz \
@ -110,7 +104,7 @@ RUN set -ex; \
mkdir /usr/src/friendica/addon; \ mkdir /usr/src/friendica/addon; \
tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \
rm friendica_addons.tar.gz; \ rm friendica_addons.tar.gz; \
friendica composer install; /usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica;
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"] 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,195 @@
#!/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" ]
}
# 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 -d /usr/src/friendica
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
smtp_from=${SMTP_FROM:-no-reply}
# Setup SSMTP
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd
# add possible mail-senders
{
echo "www-data:$smtp_from@$HOSTNAME:$SMTP" ;
echo "root::$smtp_from@$HOSTNAME:$SMTP" ;
} > /etc/ssmtp/revaliases;
# replace ssmtp.conf settings
{
echo "root=:$smtp_from@$HOSTNAME" ;
echo "hostname=$HOSTNAME" ;
echo "mailhub=$SMTP" ;
echo "FromLineOverride=YES" ;
if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi
if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi
if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi
if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi
if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi
} > /etc/ssmtp/ssmtp.conf
echo "Setup finished"
fi
}
# just check if we execute apache or php-fpm
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
setup_ssmtp
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/
# 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 "cd /var/www/html; php /var/www/html/bin/console.php 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 'cd /var/www/html; php /var/www/html/bin/console.php dbstructure update'
echo "Upgrading finished"
fi
fi
fi
exec "$@"

View file

@ -0,0 +1,8 @@
/.git/
/photo/
/proxy/
.htconfig.php
.htaccess
home.*
/config/local.ini.php
/config/addon.ini.php

View file

@ -88,24 +88,18 @@ RUN chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME /var/www/html
WORKDIR /var/www/html
RUN {\ RUN {\
echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\
} > /usr/local/etc/php/conf.d/sendmail.ini; } > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false COPY *.sh upgrade.exclude /
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 /
RUN chmod +x /*.sh RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
ENV FRIENDICA_VERSION 2018.09
ENV FRIENDICA_ADDONS 2018.09
RUN set -ex; \ RUN set -ex; \
curl -fsSL -o friendica.tar.gz \ curl -fsSL -o friendica.tar.gz \
@ -119,7 +113,7 @@ RUN set -ex; \
mkdir /usr/src/friendica/addon; \ mkdir /usr/src/friendica/addon; \
tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \
rm friendica_addons.tar.gz; \ rm friendica_addons.tar.gz; \
friendica composer install; /usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica;
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"] 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

195
2018.09/fpm/entrypoint.sh Normal file
View file

@ -0,0 +1,195 @@
#!/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" ]
}
# 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 -d /usr/src/friendica
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
smtp_from=${SMTP_FROM:-no-reply}
# Setup SSMTP
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd
# add possible mail-senders
{
echo "www-data:$smtp_from@$HOSTNAME:$SMTP" ;
echo "root::$smtp_from@$HOSTNAME:$SMTP" ;
} > /etc/ssmtp/revaliases;
# replace ssmtp.conf settings
{
echo "root=:$smtp_from@$HOSTNAME" ;
echo "hostname=$HOSTNAME" ;
echo "mailhub=$SMTP" ;
echo "FromLineOverride=YES" ;
if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi
if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi
if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi
if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi
if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi
} > /etc/ssmtp/ssmtp.conf
echo "Setup finished"
fi
}
# just check if we execute apache or php-fpm
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
setup_ssmtp
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/
# 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 "cd /var/www/html; php /var/www/html/bin/console.php 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 'cd /var/www/html; php /var/www/html/bin/console.php dbstructure update'
echo "Upgrading finished"
fi
fi
fi
exec "$@"

View file

@ -0,0 +1,8 @@
/.git/
/photo/
/proxy/
.htconfig.php
.htaccess
home.*
/config/local.ini.php
/config/addon.ini.php

View file

@ -88,6 +88,7 @@ RUN chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME /var/www/html
WORKDIR /var/www/html
RUN a2enmod rewrite remoteip ;\ RUN a2enmod rewrite remoteip ;\
{\ {\
@ -102,18 +103,11 @@ RUN {\
echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\
} > /usr/local/etc/php/conf.d/sendmail.ini; } > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false COPY *.sh upgrade.exclude /
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 /
RUN chmod +x /*.sh 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"] 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,195 @@
#!/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" ]
}
# 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 -d /usr/src/friendica
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
smtp_from=${SMTP_FROM:-no-reply}
# Setup SSMTP
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd
# add possible mail-senders
{
echo "www-data:$smtp_from@$HOSTNAME:$SMTP" ;
echo "root::$smtp_from@$HOSTNAME:$SMTP" ;
} > /etc/ssmtp/revaliases;
# replace ssmtp.conf settings
{
echo "root=:$smtp_from@$HOSTNAME" ;
echo "hostname=$HOSTNAME" ;
echo "mailhub=$SMTP" ;
echo "FromLineOverride=YES" ;
if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi
if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi
if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi
if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi
if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi
} > /etc/ssmtp/ssmtp.conf
echo "Setup finished"
fi
}
# just check if we execute apache or php-fpm
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
setup_ssmtp
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/
# 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 "cd /var/www/html; php /var/www/html/bin/console.php 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 'cd /var/www/html; php /var/www/html/bin/console.php dbstructure update'
echo "Upgrading finished"
fi
fi
fi
exec "$@"

View file

@ -0,0 +1,8 @@
/.git/
/photo/
/proxy/
.htconfig.php
.htaccess
home.*
/config/local.ini.php
/config/addon.ini.php

View file

@ -7,7 +7,7 @@ RUN set -ex; \
apk add --no-cache \ apk add --no-cache \
rsync \ rsync \
git \ git \
# For mail() support # For mail() support
ssmtp; ssmtp;
# install the PHP extensions we need # install the PHP extensions we need
@ -21,8 +21,8 @@ RUN set -ex; \
autoconf \ autoconf \
g++ \ g++ \
make \ make \
openssl \ libressl \
openssl-dev \ libressl-dev \
libpng \ libpng \
libpng-dev \ libpng-dev \
libjpeg-turbo-dev \ libjpeg-turbo-dev \
@ -75,29 +75,23 @@ RUN set -ex; \
apk add --virtual .friendica-phpext-rundeps $runDeps; \ apk add --virtual .friendica-phpext-rundeps $runDeps; \
apk del .build-deps; 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 chmod -R g=u /var/www
VOLUME /var/www/html VOLUME /var/www/html
WORKDIR /var/www/html
RUN {\ RUN {\
echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\
} > /usr/local/etc/php/conf.d/sendmail.ini; } > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false COPY *.sh upgrade.exclude /
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 /
RUN chmod +x /*.sh 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"] ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"] 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,195 @@
#!/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" ]
}
# 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 -d /usr/src/friendica
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
smtp_from=${SMTP_FROM:-no-reply}
# Setup SSMTP
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd
# add possible mail-senders
{
echo "www-data:$smtp_from@$HOSTNAME:$SMTP" ;
echo "root::$smtp_from@$HOSTNAME:$SMTP" ;
} > /etc/ssmtp/revaliases;
# replace ssmtp.conf settings
{
echo "root=:$smtp_from@$HOSTNAME" ;
echo "hostname=$HOSTNAME" ;
echo "mailhub=$SMTP" ;
echo "FromLineOverride=YES" ;
if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi
if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi
if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi
if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi
if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi
} > /etc/ssmtp/ssmtp.conf
echo "Setup finished"
fi
}
# just check if we execute apache or php-fpm
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
setup_ssmtp
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/
# 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 "cd /var/www/html; php /var/www/html/bin/console.php 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 'cd /var/www/html; php /var/www/html/bin/console.php dbstructure update'
echo "Upgrading finished"
fi
fi
fi
exec "$@"

View file

@ -0,0 +1,8 @@
/.git/
/photo/
/proxy/
.htconfig.php
.htaccess
home.*
/config/local.ini.php
/config/addon.ini.php

View file

@ -88,24 +88,18 @@ RUN chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME /var/www/html
WORKDIR /var/www/html
RUN {\ RUN {\
echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\
} > /usr/local/etc/php/conf.d/sendmail.ini; } > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false COPY *.sh upgrade.exclude /
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 /
RUN chmod +x /*.sh 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"] 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,195 @@
#!/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" ]
}
# 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 -d /usr/src/friendica
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
smtp_from=${SMTP_FROM:-no-reply}
# Setup SSMTP
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd
# add possible mail-senders
{
echo "www-data:$smtp_from@$HOSTNAME:$SMTP" ;
echo "root::$smtp_from@$HOSTNAME:$SMTP" ;
} > /etc/ssmtp/revaliases;
# replace ssmtp.conf settings
{
echo "root=:$smtp_from@$HOSTNAME" ;
echo "hostname=$HOSTNAME" ;
echo "mailhub=$SMTP" ;
echo "FromLineOverride=YES" ;
if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi
if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi
if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi
if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi
if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi
} > /etc/ssmtp/ssmtp.conf
echo "Setup finished"
fi
}
# just check if we execute apache or php-fpm
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
setup_ssmtp
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/
# 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 "cd /var/www/html; php /var/www/html/bin/console.php 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 'cd /var/www/html; php /var/www/html/bin/console.php dbstructure update'
echo "Upgrading finished"
fi
fi
fi
exec "$@"

View file

@ -0,0 +1,8 @@
/.git/
/photo/
/proxy/
.htconfig.php
.htaccess
home.*
/config/local.ini.php
/config/addon.ini.php

View file

@ -6,7 +6,7 @@ RUN set -ex; \
apk add --no-cache \ apk add --no-cache \
rsync \ rsync \
git \ git \
# For mail() support # For mail() support
ssmtp; ssmtp;
# install the PHP extensions we need # install the PHP extensions we need
@ -20,8 +20,8 @@ RUN set -ex; \
autoconf \ autoconf \
g++ \ g++ \
make \ make \
openssl \ libressl \
openssl-dev \ libressl-dev \
libpng \ libpng \
libpng-dev \ libpng-dev \
libjpeg-turbo-dev \ libjpeg-turbo-dev \
@ -74,29 +74,23 @@ RUN set -ex; \
apk add --virtual .friendica-phpext-rundeps $runDeps; \ apk add --virtual .friendica-phpext-rundeps $runDeps; \
apk del .build-deps; 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 chmod -R g=u /var/www
VOLUME /var/www/html VOLUME /var/www/html
WORKDIR /var/www/html
%%VARIANT_EXTRAS%% %%VARIANT_EXTRAS%%
RUN {\ RUN {\
echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\
} > /usr/local/etc/php/conf.d/sendmail.ini; } > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false COPY *.sh upgrade.exclude /
ENV VALIDATION true RUN chmod +x /*.sh
ENV SITENAME "Friendica Social Network"
ENV FRIENDICA_VERSION %%VERSION%% ENV FRIENDICA_VERSION %%VERSION%%
ENV FRIENDICA_ADDONS %%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%% %%INSTALL_EXTRAS%%
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
CMD ["%%CMD%%"] CMD ["%%CMD%%"]

View file

@ -87,24 +87,18 @@ RUN chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME /var/www/html
WORKDIR /var/www/html
%%VARIANT_EXTRAS%% %%VARIANT_EXTRAS%%
RUN {\ RUN {\
echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\
} > /usr/local/etc/php/conf.d/sendmail.ini; } > /usr/local/etc/php/conf.d/sendmail.ini;
ENV AUTOINSTALL false COPY *.sh upgrade.exclude /
ENV VALIDATION true RUN chmod +x /*.sh
ENV SITENAME "Friendica Social Network"
ENV FRIENDICA_VERSION %%VERSION%% ENV FRIENDICA_VERSION %%VERSION%%
ENV FRIENDICA_ADDONS %%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%% %%INSTALL_EXTRAS%%
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]

View file

@ -1,87 +1,69 @@
# How to maintain this repository # How to maintain this repository
The structure and usage of this repository is influenced by other, official docker repositories. The structure and usage of this repository is influenced by other, official docker repositories.
# Version directories # 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. Never ever change a file/folder inside a directory without a `.` at the beginning (`2018.05-rc`, ...).
All changes in such folders will get overwritten during an update. This folder will get updated automatically based on the templates you want to change.
All changes in such folders will get overwritten during an update.
# Basic files and folders
# Basic files and folders
Most of the time you want to change one of the followed files.
Most of the time you want to change one of the followed files.
## [`.bin`](https://github.com/friendica/docker/tree/master/.bin)
## Templates & shell-scripts
This directory holds the binary/shell files for docker images.
They get copied into the docker images at `/usr/local/bin`. - If you want to update/upgrade Dockerfiles, use the right `*.template` file for it.
- If you want to update/change the behavior of **every** start of Docker-image, change `docker-entrypoint.sh`
## [`.config`](https://github.com/friendica/docker/tree/master/.config) - If you want to update/change the behavior how cronjobs will get started, change `docker-cron.sh`
This directory holds the config files for docker images. # Maintenance scripts
They get copied into the docker images at `/usr/src/config`.
There are two important scripts in this repository for maintenance.
### `htconfig.php`
## update.sh
This file is based on the sample [`htconfig.php`](https://github.com/friendica/friendica/blob/559250b8b3a7a5d0e524d3e3e2d347d18d6c3a2a/htconfig.php) in the Friendica repository.
Creates a directory and the necessary files for each combination of version (2018.05-rc, 3.6, ...) and variant (apache, fpm, fpm-alpine):
The differences:
- Removed the `die()` at the beginning - Creating the right `Dockerfile` (from one of the two *.template files)
- Removed all hard-coded DB settings - Creating the `docker-*.sh` files (copy as *.sh)
- Added environment variables for mailname, tz, language - Coping `/.bin/*` to `bin/*`
- Coping `/.config/*` to `config/*`
## Templates & shell-scripts - Recreating the version/variant environment in `.travis.yml`
- If you want to update/upgrade Dockerfiles, use the right `*.template` file for it. If you want to update the Docker-images to a newer version, just change the list in `update.sh` at
- If you want to update/change the behavior of **every** start of Docker-image, change `docker-entrypoint.sh` ```shell
- If you want to update/change the behavior how cronjobs will get started, change `docker-cron.sh` versions=(
2018.05-rc
# Maintenance scripts )
```
There are two important scripts in this repository for maintenance.
# generate-stackbrew-library.sh
## update.sh
This file automatically creates a "manifest" for the docker-images.
Creates a directory and the necessary files for each combination of version (2018.05-rc, 3.6, ...) and variant (apache, fpm, fpm-alpine): Like:
- Creating the right `Dockerfile` (from one of the two *.template files) ```console
- Creating the `docker-*.sh` files (copy as *.sh) # This file is generated via https://github.com/friendica/docker/blob/b46fae917321394e1482df59dc4e39daffbe5c59/generate-stackbrew-library.sh
- Coping `/.bin/*` to `bin/*` Maintainers: Friendica <info@friendi.ca> (@friendica), Philipp Holzer <admin@philipp.info> (@[secure])
- Coping `/.config/*` to `config/*` GitRepo: https://github.com/friendica/docker.git
- Recreating the version/variant environment in `.travis.yml`
Tags: 2018.05-rc-apache, rc-apache, apache, stable-apache, production-apache, 2018.05-rc, rc, latest, stable, production
If you want to update the Docker-images to a newer version, just change the list in `update.sh` at Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, ppc64le, s390x
```shell GitCommit: b46fae917321394e1482df59dc4e39daffbe5c59
versions=( Directory: 2018.05-rc/apache
2018.05-rc
) Tags: 2018.05-rc-fpm, rc-fpm, fpm, stable-fpm, production-fpm
``` Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, ppc64le, s390x
GitCommit: b46fae917321394e1482df59dc4e39daffbe5c59
# generate-stackbrew-library.sh Directory: 2018.05-rc/fpm
This file automatically creates a "manifest" for the docker-images. Tags: 2018.05-rc-fpm-alpine, rc-fpm-alpine, fpm-alpine, stable-fpm-alpine, production-fpm-alpine
Like: Architectures: amd64, arm32v6, arm64v8, i386, ppc64le, s390x
GitCommit: b46fae917321394e1482df59dc4e39daffbe5c59
```console Directory: 2018.05-rc/fpm-alpine
# This file is generated via https://github.com/friendica/docker/blob/b46fae917321394e1482df59dc4e39daffbe5c59/generate-stackbrew-library.sh This is the input-file for the official-images in a later step :-)
Maintainers: Friendica <info@friendi.ca> (@friendica), Philipp Holzer <admin@philipp.info> (@[secure])
GitRepo: https://github.com/friendica/docker.git
Tags: 2018.05-rc-apache, rc-apache, apache, stable-apache, production-apache, 2018.05-rc, rc, latest, stable, production
Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, ppc64le, s390x
GitCommit: b46fae917321394e1482df59dc4e39daffbe5c59
Directory: 2018.05-rc/apache
Tags: 2018.05-rc-fpm, rc-fpm, fpm, stable-fpm, production-fpm
Architectures: amd64, arm32v5, arm32v7, arm64v8, i386, ppc64le, s390x
GitCommit: b46fae917321394e1482df59dc4e39daffbe5c59
Directory: 2018.05-rc/fpm
Tags: 2018.05-rc-fpm-alpine, rc-fpm-alpine, fpm-alpine, stable-fpm-alpine, production-fpm-alpine
Architectures: amd64, arm32v6, arm64v8, i386, ppc64le, s390x
GitCommit: b46fae917321394e1482df59dc4e39daffbe5c59
Directory: 2018.05-rc/fpm-alpine
This is the input-file for the official-images in a later step :-)
``` ```

640
README.md
View file

@ -1,329 +1,311 @@
# Docker Image for Friendica # Docker Image for Friendica
[![Build Status Travis](https://travis-ci.org/friendica/docker.svg?branch=master)](https://travis-ci.org/friendica/docker) [![Build Status Travis](https://travis-ci.org/friendica/docker.svg?branch=master)](https://travis-ci.org/friendica/docker)
This repository holds the official Docker Image for [Friendica](https://friendi.ca) This repository holds the official Docker Image for [Friendica](https://friendi.ca)
# What is Friendica? # What is Friendica?
Friendica is a decentralised communications platform that integrates social communication. Friendica is a decentralised communications platform that integrates social communication.
Our platform links to independent social projects and corporate services. Our platform links to independent social projects and corporate services.
![logo](https://cdn.rawgit.com/friendica/docker/9c954f4d/friendica.svg) ![logo](https://cdn.rawgit.com/friendica/docker/9c954f4d/friendica.svg)
# How to use this image # How to use this image
The images are designed to be used in a micro-service environment. The images are designed to be used in a micro-service environment.
There are two types of the image you can choose from. There are two types of the image you can choose from.
The `apache` tag contains a full Friendica installation including an apache web server. The `apache` tag contains a full Friendica installation including an apache web server.
It is designed to be easy to use and gets you running pretty fast. It is designed to be easy to use and gets you running pretty fast.
This is also the default for the `latest` tag and version tags that are not further specified. This is also the default for the `latest` tag and version tags that are not further specified.
The second option is a `fpm` container. The second option is a `fpm` container.
It is based on the [php-fpm](https://hub.docker.com/_/php/) image and runs a fastCGI-Process that serves your Friendica server. It is based on the [php-fpm](https://hub.docker.com/_/php/) image and runs a fastCGI-Process that serves your Friendica server.
To use this image it must be combined with any Webserver that can proxy the http requests to the FastCGI-port of the container. To use this image it must be combined with any Webserver that can proxy the http requests to the FastCGI-port of the container.
[![Try in PWD](https://github.com/play-with-docker/stacks/raw/cff22438cb4195ace27f9b15784bbb497047afa7/assets/images/button.png)](http://play-with-docker.com?stack=https://raw.githubusercontent.com/nupplaphil/friendica-docker/fec33c98be957436279b7074ca08068b18622627/stack.yml) [![Try in PWD](https://github.com/play-with-docker/stacks/raw/cff22438cb4195ace27f9b15784bbb497047afa7/assets/images/button.png)](http://play-with-docker.com?stack=https://raw.githubusercontent.com/nupplaphil/friendica-docker/fec33c98be957436279b7074ca08068b18622627/stack.yml)
(Admin-E-Mail: `root@friendica.local`) (Admin-E-Mail: `root@friendica.local`)
## Using the apache image ## Using the apache image
You need at least one other mariadb/mysql-container to link it to Friendica. You need at least one other mariadb/mysql-container to link it to Friendica.
The apache image contains a webserver and exposes port 80. The apache image contains a webserver and exposes port 80.
To start the container type: To start the container type:
```console ```console
$ docker run -d -p 8080:80 --link some-mysql:mysql friendica/server $ docker run -d -p 8080:80 --link some-mysql:mysql friendica/server
``` ```
Now you can access the Friendica installation wizard at http://localhost:8080/ from your host system. Now you can access the Friendica installation wizard at http://localhost:8080/ from your host system.
## Using the fpm image ## Using the fpm image
To use the fpm image you need an additional web server that can proxy http-request to the fpm-port of the container. To use the fpm image you need an additional web server that can proxy http-request to the fpm-port of the container.
For fpm connection this container exposes port 9000. For fpm connection this container exposes port 9000.
In most cases you might want use another container or your host as proxy. In most cases you might want use another container or your host as proxy.
If you use your host you can address your Friendica container directly on port 9000. If you use your host you can address your Friendica container directly on port 9000.
If you use another container, make sure that you add them to the same docker network (via `docker run --network <NAME> ...` or a `docker-compose` file). If you use another container, make sure that you add them to the same docker network (via `docker run --network <NAME> ...` or a `docker-compose` file).
In both cases you don't want to map the fpm port to you host. In both cases you don't want to map the fpm port to you host.
```console ```console
$ docker run -d friendica/server:fpm $ docker run -d friendica/server:fpm
``` ```
As the fastCGI-Process is not capable of serving static files (style sheets, images, ...) the webserver needs access to these files. As the fastCGI-Process is not capable of serving static files (style sheets, images, ...) the webserver needs access to these files.
This can be achieved with the `volumes-from` option. This can be achieved with the `volumes-from` option.
You can find more information in the docker-compose section. You can find more information in the docker-compose section.
## Using the cron job ## Using the cron job
There are three options to enable the cron-job for Friendica: There are three options to enable the cron-job for Friendica:
- Using the default Image and activate the cron-job (see [Installation](https://friendi.ca/resources/installation/), sector `Activating scheduled tasks`) - Using the default Image and activate the cron-job (see [Installation](https://friendi.ca/resources/installation/), sector `Activating scheduled tasks`)
- Using the default image (apache, fpm, fpm-alpine) and creating **two** container (one for cron and one for the main app) - Using 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) - 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.
**Common** - `FRIENDICA_TZ` The default localization of the Friendica server.
- `MAILNAME` E-Mail address of the administrator. (**required**) - `FRIENDICA_LANG` The default language of the Friendica server.
- `TZ` The default localization of the Friendica server. (Default: `America/Los_Angeles`) - `FRIENDICA_PHP_PATH` The path of the PHP binary.
- `LANGUAGE` The default language of the Friendica server. (Default: `en`)
- `SITENAME` The default name of the Friendica server. (Default: `Friendica Social Network` ) **Database** (**required at installation**)
- `VALIDATION` The default setting if url/emails are getting validated. (Default: `true`) - `MYSQL_USERNAME` Username for the database user using mysql.
- `AUTOINSTALL` if `true`, the automatic configuration will start. (Default: `false`) - `MYSQL_USER` Username for the database user using mariadb.
- `MYSQL_PASSWORD` Password for the database user using mysql / mariadb.
**SMTP/Mail** - `MYSQL_DATABASE` Name of the database using mysql / mariadb.
- `SMTP` Address of the SMTP Mail-Gateway. (**required** - Default: `localhost`) - `MYSQL_HOST` Hostname of the database server using mysql / mariadb.
- `SMTP_FROM` Sender user-part of the address. (Default: `no-reply` - e.g. no-reply@friendica.local) - `MYSQL_PORT` Port of the database server using mysql / mariadb (Default: `3306`)
- `SMTP_AUTH_USER` Username for the SMTP Mail-Gateway. (Default: empty)
- `SMTP_AUTH_PASS` Password for the SMTP Mail-Gateway. (Default: empty) **Develop/Release Candidat Settings**
- `SMTP_AUTH_METHOD` Authentication method for the SMTP Mail-Gateway. (Default: empty/plain text) - `FRIENDICA_UPGRADE` If set to `true`, a develop or release candidat node will get updated at startup.
**Database** (**required**) ## Administrator account
- `MYSQL_USERNAME` Username for the database user using mysql.
- `MYSQL_USER` Username for the database user using mariadb. Because Friendica links the administrator account to a specific mail address, you **have** to set a valid address for `MAILNAME`.
- `MYSQL_PASSWORD` Password for the database user using mysql / mariadb.
- `MYSQL_DATABASE` Name of the database using mysql / mariadb. ## Mail settings
- `MYSQL_HOST` Hostname of the database server using mysql / mariadb.
- `MYSQL_PORT` Port of the database server using mysql / mariadb. The binary `ssmtp` is used for the `mail()` support of Friendica.
**Caching** You have to set the `--hostname/-h` parameter correctly to use the right domainname for the `mail()` command.
- `CACHE_DRIVER` Driver of the Friendica cache (`memcache`, `memcached` or `redis`)
- `MEMCACHE_HOST` Host of the memcache cache server. (Default: `127.0.0.1`) You have to set a valid SMTP-MTA for the `SMTP` environment variable to enable mail support in Friendica.
- `MEMCACHE_PORT` Port of the memcache cache server. (Default: `11211`) A valid SMTP-MTA would be, for example, `mx.example.org`.
- `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`) The following environment variables are possible for the SMTP examples.
- `REDIS_PORT` Port of the redis cache server. (Default: `6379`)
- `SITENAME` The name of the Friendica node. (**required**)
- `SMTP` Address of the SMTP Mail-Gateway. (**required**)
## Administrator account - `SMTP_FROM` Sender user-part of the address. (Default: `no-reply` - e.g. no-reply@friendica.local)
- `SMTP_TLS` Use TLS for connecting the SMTP Mail-Gateway. (Default: empty)
Because Friendica links the administrator account to a specific mail address, you **have** to set a valid address for `MAILNAME`. - `SMTP_STARTTLS` Use STARTTLS for connecting the SMTP Mail-Gateway. (Default: empty)
- `SMTP_AUTH_USER` Username for the SMTP Mail-Gateway. (Default: empty)
## Mail settings - `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)
The binary `ssmtp` is used for the `mail()` support of Friendica.
## Database settings
You have to set the `--hostname/-h` parameter correctly to use the right domainname for the `mail()` command.
You have to link a running database container, e. g. `--link my-mysql:mysql`, and then use `mysql` as the database host on setup.
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`. ## Persistent data
## Database settings The Friendica installation and all data beyond what lives in the database (file uploads, etc) is stored in the [unnamed docker volume](https://docs.docker.com/engine/tutorials/dockervolumes/#adding-a-data-volume) volume `/var/www/html`.
The docker daemon will store that data within the docker directory `/var/lib/docker/volumes/...`.
You have to link a running database container, e. g. `--link my-mysql:mysql`, and then use `mysql` as the database host on setup. That means your data is saved even if the container crashes, is stopped or deleted.
## Persistent data To make your data persistent to upgrading and get access for backups is using named docker volume or mount a host folder.
To achieve this you need one volume for your database container and Friendica.
The Friendica installation and all data beyond what lives in the database (file uploads, etc) is stored in the [unnamed docker volume](https://docs.docker.com/engine/tutorials/dockervolumes/#adding-a-data-volume) volume `/var/www/html`.
The docker daemon will store that data within the docker directory `/var/lib/docker/volumes/...`. Friendica:
That means your data is saved even if the container crashes, is stopped or deleted.
- `/var/www/html/` folder where all Friendica data lives
To make your data persistent to upgrading and get access for backups is using named docker volume or mount a host folder.
To achieve this you need one volume for your database container and Friendica. ```console
$ docker run -d \
Friendica: -v friendica-vol-1:/var/www/html \
friendica/server
- `/var/www/html/` folder where all Friendica data lives ```
```console Database:
$ docker run -d \
-v friendica-vol-1:/var/www/html \ - `/var/lib/mysql` MySQL / MariaDB Data
friendica/server
``` ```console
$ docker run -d \
Database: -v mysql-vol-1:/var/lib/mysql \
mariadb
- `/var/lib/mysql` MySQL / MariaDB Data ```
```console ## Automatic installation
$ docker run -d \
-v mysql-vol-1:/var/lib/mysql \ The Friendica image supports auto configuration via environment variables.
mariadb You can preconfigure everything that is asked on the install page on first run.
``` To enable the automatic installation, there are two possibilities:
## Automatic installation ### Environment Variables
The Friendica image supports auto configuration via environment variables. You have to set at least the following environment variables (others are optional).
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`. - `FRIENDICA_ADMIN_MAIL` E-Mail address of the administrator.
- `MYSQL_USERNAME` or `MYSQL_USER` Username for the database user using mysql/mariadb.
# Maintenance of the image - `MYSQL_PASSWORD` Password for the database user using mysql / mariadb.
- `MYSQL_DATABASE` Name of the database using mysql / mariadb.
## Updating to a newer version - `MYSQL_HOST` Hostname of the database server using mysql / mariadb.
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. ### Using a predefined config file
They have both in common that normally we do not automatically overwrite your working directory with the new version. You can create a `local.ini.php` and `COPY` it to `/usr/src/config`.
Instead you need to explicit run `friendica update` for the node for updating files&database. If no other environment variable is set, this `local.ini.php` will get copied to the config path.
### Updating stable # Maintenance of the image
You have to pull the latest image from the hub (`docker pull friendica`). ## Updating to a newer version
### Updating develop There are differences between the deveop (everything which ends with `-rc` or `-dev`) and the stable (the rest) branches.
You don't need to pull the image for each commit in [friendica](https://github.com/friendica/friendica/). ### Updating stable
Instead you can just update your node with executing `friendica update` on the node.
Example: 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.
```console
$ docker exec -ti friendica_running_node friendica update ### Updating develop
```
You don't need to pull the image for each commit in [friendica](https://github.com/friendica/friendica/).
It will clone the latest Friendica version and copy it to your working directory. Instead, the develop branch will get updated if no installation was found or the environment variable `FRIENDICA_UPGRADE` is set to `true`.
## The `friendica` CLI It will clone the latest Friendica version and copy it to your working directory.
To make the usage of the Docker images smooth, we created a little CLI. # Running this image with docker-compose
It wraps the common commands for Friendica and adds new commands.
The easiest way to get a fully featured and functional setup is using a `docker-compose` file.
You can call it with There are too many different possibilities to setup your system, so here are only some examples what you have to look for.
```console At first make sure you have chosen the right base image (fpm or apache) and added the features you wanted (see below).
$ docker exec -ti friendica_running_node friendica <command> In every case you want to add a database container and docker volumes to get easy access to your persistent data.
``` When you want your server reachable from the internet adding HTTPS-encryption is mandatory!
See below for more information.
Commands:
## Base version - apache
- `console` Executes an command in the Friendica console (`bin/console.php` wrapper)
- `composer` Executes the composer.phar executable for Friendica (`bin/composer.phar` wrapper) This version will use the apache image and add a mariaDB container.
- `install` Installs Friendica on a empty environment (gets called automatically during first start) The volumes are set to keep your data persistent.
- `update` Updates Friendica on a **existing** environment This setup provides **no ssl encryption** and is intended to run behind a proxy.
# Running this image with docker-compose Make sure to set the variable `MYSQL_PASSWORD` before run this setup.
The easiest way to get a fully featured and functional setup is using a `docker-compose` file. ```yaml
There are too many different possibilities to setup your system, so here are only some examples what you have to look for. version: '2'
At first make sure you have chosen the right base image (fpm or apache) and added the features you wanted (see below). services:
In every case you want to add a database container and docker volumes to get easy access to your persistent data. db:
When you want your server reachable from the internet adding HTTPS-encryption is mandatory! image: mariadb
See below for more information. restart: always
volumes:
## Base version - apache - db:/var/lib/mysql
environment:
This version will use the apache image and add a mariaDB container. - MYSQL_USER=friendica
The volumes are set to keep your data persistent. - MYSQL_PASSWORD=
This setup provides **no ssl encryption** and is intended to run behind a proxy. - MYSQL_DATABASE=friendica
- MYSQL_RANDOM_ROOT_PASSWORD=yes
Make sure to set the variable `MYSQL_PASSWORD` before run this setup.
app:
```yaml image: friendica/server
version: '2' restart: always
volumes:
services: - friendica:/var/www/html
db: ports:
image: mariadb - "8080:80"
restart: always environment:
volumes: - MYSQL_HOST=db
- db:/var/lib/mysql - MYSQL_USER=friendica
environment: - MYSQL_PASSWORD=
- MYSQL_USER=friendica - MYSQL_DATABASE=friendica
- MYSQL_PASSWORD= - FRIENDICA_ADMIN_MAIL=root@friendica.local
- MYSQL_DATABASE=friendica hostname: friendica.local
- MYSQL_RANDOM_ROOT_PASSWORD=yes depends_on:
- db
app:
image: friendica/server volumes:
restart: always db:
volumes: friendica:
- friendica:/var/www/html ```
ports:
- "8080:80" Then run `docker-compose up -d`, now you can access Friendica at http://localhost:8080/ from your system.
environment:
- MYSQL_HOST=db ## Base version - FPM
- MYSQL_PORT=3306
- MYSQL_USER=friendica When using the FPM image you need another container that acts as web server on port 80 and proxies requests to the Friendica container.
- MYSQL_PASSWORD= In this example a simple nginx container is combined with the Friendica-fpm image and a MariaDB database container.
- MYSQL_DATABASE=friendica The data is stored in docker volumes.
- MAILNAME=root@friendica.local The nginx container also need access to static files from your Friendica installation.
hostname: friendica.local It gets access to all the volumes mounted to Friendica via the `volumes_from` option.
depends_on: The configuration for nginx is stored in the configuration file `nginx.conf` that is mounted into the container.
- db
An example can be found in the [examples section](https://github.com/friendica/docker/tree/master/.examples).
volumes:
db: As this setup does **not include encryption** it should to be run behind a proxy.
friendica:
``` Prerequisites for this example:
- Make sure to set the variable `MYSQL_PASSWORD` before you run the setup.
Then run `docker-compose up -d`, now you can access Friendica at http://localhost:8080/ from your system. - Create a `nginx.conf` in the same directory as the docker-compose.yml file (take it from [example](https://github.com/friendica/docker/tree/master/.examples/docker-compose/with-traefik-proxy/mariadb-cron-smtp/fpm/web/nginx.conf))
## Base version - FPM ```yaml
version: '2'
When using the FPM image you need another container that acts as web server on port 80 and proxies requests to the Friendica container.
In this example a simple nginx container is combined with the Friendica-fpm image and a MariaDB database container. services:
The data is stored in docker volumes. db:
The nginx container also need access to static files from your Friendica installation. image: mariadb
It gets access to all the volumes mounted to Friendica via the `volumes_from` option. restart: always
The configuration for nginx is stored in the configuration file `nginx.conf` that is mounted into the container. volumes:
- db:/var/lib/mysql
An example can be found in the [examples section](https://github.com/friendica/docker/tree/master/.examples). environment:
- MYSQL_USER=friendica
As this setup does **not include encryption** it should to be run behind a proxy. - MYSQL_PASSWORD=
- MYSQL_DATABASE=friendica
Prerequisites for this example: - MYSQL_RANDOM_ROOT_PASSWORD=yes
- Make sure to set the variable `MYSQL_PASSWORD` before you run the setup.
- Create a `nginx.conf` in the same directory as the docker-compose.yml file (take it from [example](https://github.com/friendica/docker/tree/master/.examples/docker-compose/with-traefik-proxy/mariadb-cron-smtp/fpm/web/nginx.conf)) app:
image: friendica/server:fpm
```yaml restart: always
version: '2' volumes:
- friendica:/var/www/html
services: environment:
db: - MYSQL_HOST=db
image: mariadb - MYSQL_USER=friendica
restart: always - MYSQL_PASSWORD=
volumes: - MYSQL_DATABASE=friendica
- db:/var/lib/mysql - FRIENDICA_ADMIN_MAIL=root@friendica.local
environment: hostname: friendica.local
- MYSQL_USER=friendica networks:
- MYSQL_PASSWORD= - proxy-tier
- MYSQL_DATABASE=friendica - default
- MYSQL_RANDOM_ROOT_PASSWORD=yes
web:
app: image: nginx
image: friendica/server:fpm ports:
restart: always - 8080:80
volumes: links:
- friendica:/var/www/html - app
environment: volumes:
- MYSQL_HOST=db - ./nginx.conf:/etc/nginx/nginx.conf:ro
- MYSQL_PORT=3306 restart: always
- MYSQL_USER=friendica networks:
- MYSQL_PASSWORD= - proxy-tier
- MYSQL_DATABASE=friendica
- MAILNAME=root@friendica.local volumes:
hostname: friendica.local db:
networks: friendica:
- proxy-tier
- default networks:
proxy-tier:
web: ```
image: nginx
ports: Then run `docker-compose up -d`, now you can access Friendica at http://localhost:8080/ from your system.
- 8080:80
links: # Questions / Issues
- app
volumes: If you got any questions or problems using the image, please visit our [Github Repository](https://github.com/friendica/docker) and write an issue.
- ./nginx.conf:/etc/nginx/nginx.conf:ro
restart: always
networks:
- proxy-tier
volumes:
db:
friendica:
networks:
proxy-tier:
```
Then run `docker-compose up -d`, now you can access Friendica at http://localhost:8080/ from your system.
# Questions / Issues
If you got any questions or problems using the image, please visit our [Github Repository](https://github.com/friendica/docker) and write an issue.

View file

@ -1,11 +1,11 @@
#!/bin/sh #!/bin/sh
trap "break;exit" HUP INT TERM 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 sleep 1
done done
while true; do # TODO let the database and the autoinstall time to complete - not winning a beauty contest
php -f /var/www/html/bin/worker.php sleep 15s
sleep 10m
done php /var/www/html/bin/daemon.php -f start

View file

@ -1,7 +1,195 @@
#!/bin/sh #!/bin/sh
set -eu set -eu
friendica install -q # run an command with the www-data user
friendica configmail -q run_as() {
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "cd /var/www/html;$1"
else
sh -c "$1"
fi
}
exec "$@" # 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() {
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 -d /usr/src/friendica
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
smtp_from=${SMTP_FROM:-no-reply}
# Setup SSMTP
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd
# add possible mail-senders
{
echo "www-data:$smtp_from@$HOSTNAME:$SMTP" ;
echo "root::$smtp_from@$HOSTNAME:$SMTP" ;
} > /etc/ssmtp/revaliases;
# replace ssmtp.conf settings
{
echo "root=:$smtp_from@$HOSTNAME" ;
echo "hostname=$HOSTNAME" ;
echo "mailhub=$SMTP" ;
echo "FromLineOverride=YES" ;
if [ -n "${SMTP_TLS+x}" ]; then echo "UseTLS=$SMTP_TLS"; fi
if [ -n "${SMTP_STARTTLS+x}" ]; then echo "UseSTARTTLS=$SMTP_STARTTLS"; fi
if [ -n "${SMTP_AUTH_USER+x}" ]; then echo "AuthUser=$SMTP_AUTH_USER"; fi
if [ -n "${SMTP_AUTH_PASS+x}" ]; then echo "AuthPass=$SMTP_AUTH_PASS";fi
if [ -n "${SMTP_AUTH_METHOD+x}" ]; then echo "AuthMethod=$SMTP_AUTH_METHOD"; fi
} > /etc/ssmtp/ssmtp.conf
echo "Setup finished"
fi
}
# just check if we execute apache or php-fpm
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
setup_ssmtp
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/
# 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 "cd /var/www/html; php /var/www/html/bin/console.php 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 'cd /var/www/html; php /var/www/html/bin/console.php dbstructure update'
echo "Upgrading finished"
fi
fi
fi
exec "$@"

View file

@ -2,9 +2,9 @@
set -Eeuo pipefail set -Eeuo pipefail
declare -A release_channel=( declare -A release_channel=(
[production]='2018.05' [production]='2018.09'
[stable]='2018.05' [stable]='2018.09'
[latest]='2018.05' [latest]='2018.09'
) )
self="$(basename "$BASH_SOURCE")" self="$(basename "$BASH_SOURCE")"

104
stack.yml
View file

@ -1,55 +1,51 @@
version: '3.2' version: '3.2'
services: services:
db: db:
image: mariadb image: mariadb
restart: always restart: always
volumes: volumes:
- db:/var/lib/mysql - db:/var/lib/mysql
environment: environment:
- MYSQL_USER=friendica - MYSQL_USER=friendica
- MYSQL_PASSWORD=friendica - MYSQL_PASSWORD=friendica
- MYSQL_DATABASE=friendica - MYSQL_DATABASE=friendica
- MYSQL_RANDOM_ROOT_PASSWORD=yes - MYSQL_RANDOM_ROOT_PASSWORD=yes
app: app:
image: friendica/server image: friendica/server
restart: always restart: always
ports: ports:
- 8080:80 - 8080:80
volumes: volumes:
- friendica:/var/www/html - friendica:/var/www/html
environment: environment:
- AUTOINSTALL=true - MYSQL_HOST=db
- MYSQL_HOST=db - MYSQL_USER=friendica
- MYSQL_PORT=3306 - MYSQL_PASSWORD=friendica
- MYSQL_USER=friendica - MYSQL_DATABASE=friendica
- MYSQL_PASSWORD=friendica - FRIENDICA_ADMIN_MAIL=root@friendica.local
- MYSQL_DATABASE=friendica - SITENAME=Friendica PWD Test Node
- MAILNAME=root@friendica.local hostname: friendica.local
- SITENAME=Friendica PWD Test Node depends_on:
- VALIDATION=false - db
hostname: friendica.local
depends_on: cron:
- db image: friendica/server
restart: always
cron: volumes:
image: friendica/server - friendica:/var/www/html
restart: always entrypoint: /cron.sh
volumes: environment:
- friendica:/var/www/html - MYSQL_HOST=db
entrypoint: /cron.sh - MYSQL_USER=friendica
environment: - MYSQL_PASSWORD=friendica
- MYSQL_HOST=db - MYSQL_DATABASE=friendica
- MYSQL_PORT=3306 - FRIENDICA_ADMIN_MAIL=root@friendica.local
- MYSQL_USER=friendica - SITENAME=Friendica PWD Test Node
- MYSQL_PASSWORD=friendica depends_on:
- MYSQL_DATABASE=friendica - db
- MAILNAME=root@friendica.local
- SITENAME=Friendica PWD Test Node volumes:
depends_on: db:
- db
volumes:
db:
friendica: friendica:

View file

@ -30,7 +30,7 @@ declare -A pecl_versions=(
) )
declare -A install_extras=( 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-dev -d /usr/src/friendica;'
['develop']='' ['develop']=''
) )
@ -41,8 +41,8 @@ variants=(
) )
versions=( versions=(
2018.05 2018.12-dev
2018.08-dev 2018.09
) )
travisEnv= travisEnv=
@ -84,11 +84,8 @@ function create_variant() {
cp "docker-$name.sh" "$dir/$name.sh" cp "docker-$name.sh" "$dir/$name.sh"
done done
# Copy the config directory # Copy the upgrade.exclude
cp -rT .config "$dir/config" cp upgrade.exclude "$dir/"
# Copy the bin directory
cp -rT .bin "$dir/bin"
travisEnvAmd64='\n - env: VERSION='"$1"' VARIANT='"$variant"' ARCH=amd64'"$travisEnvAmd64" travisEnvAmd64='\n - env: VERSION='"$1"' VARIANT='"$variant"' ARCH=amd64'"$travisEnvAmd64"
for arch in i386 amd64; do for arch in i386 amd64; do

8
upgrade.exclude Normal file
View file

@ -0,0 +1,8 @@
/.git/
/photo/
/proxy/
.htconfig.php
.htaccess
home.*
/config/local.ini.php
/config/addon.ini.php