Bugfixing & Upgrading

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

View File

@ -1,278 +0,0 @@
#!/bin/sh
set -eu
SMTP=${SMTP:-localhost}
SMTP_FROM=${SMTP_FROM:-no-reply}
SOURCEDIR=${SOURCEDIR:-/usr/src}
WORKDIR=${WORKDIR:-/var/www/html}
SMTP_TLS=${SMTP_TLS:-}
SMTP_STARTTLS=${SMTP_STARTTLS:-}
SMTP_AUTH_USER=${SMTP_AUTH_USER:-}
SMTP_AUTH_PASS=${SMTP_AUTH_PASS:-}
SMTP_AUTH_METHOD=${SMTP_AUTH_METHOD:-}
VERBOSE=1
for arg; do
case "$arg" in
-q|--quit)
if [ "$VERBOSE" -eq 2 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
VERBOSE=0
break
;;
-v|--verbose)
if [ "$VERBOSE" -eq 0 ]; then
echo 'You cannot use verbose and quiet at the same time'
exit 1
fi
VERBOSE=2
break
;;
esac
done
# run an command with the www-data user
run_as() {
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
fi
}
# log event
log() {
currVerb=1
if [ "$#" -eq 2 ]; then
currVerb=$2
fi
if [ "$VERBOSE" -ge "$currVerb" ]; then
echo "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
dir="${1:-$SOURCEDIR}"
friendica="${2:-$FRIENDICA_VERSION}"
addons="${3:-$FRIENDICA_ADDONS}"
friendica_git=$friendica
addons_git=$addons
if echo "$friendica" | grep -Eq '^.*\-dev'; then
friendica_git="develop"
fi
if echo "$addons" | grep -Eq '^.*\-dev'; then
addons_git="develop"
fi
log 'Cloning Friendica '\'$friendica_git\'' with Addons '\'$addons_git\'' into '\'$dir\'
# Removing the whole directory first
rm -fr $dir/friendica
sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica ${dir}/friendica"
mkdir $dir/friendica/addon
sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons ${dir}/friendica/addon"
}
# help of this shell script
friendica_help() {
echo "Usage: friendica <command> [<args>]"
echo ""
echo "Commands:"
echo " console Executes an command in the Friendica console"
echo " composer Executes the composer.phar executable for Friendica"
echo " install Installs Friendica"
echo " update Updates Friendica"
exit 0
}
check_database() {
TERM=dumb php -- <<'EOPHP'
<?php
// database might not exist, so let's wait for it (just to be safe)
$stderr = fopen('php://stderr', 'w');
require_once '/usr/src/config/htconfig.php';
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
$maxTries = 10;
$connected = false;
do {
try {
// This docker image is using the PDO library
$mysql = @new PDO($connection, $db_user, $db_pass);
$connected = true;
} catch (PDOException $e) {
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
$connected = false;
--$maxTries;
if ($maxTries <= 0) {
exit(1);
}
sleep(3);
}
} while (!$connected);
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
?>
EOPHP
}
# executes the Friendica console
console() {
if [ -f $WORKDIR/bin/console.php ]; then
cd $WORKDIR
php $WORKDIR/bin/console.php "$@"
fi
}
# executes the composer.phar binary of Friendica
composer() {
if [ -f $WORKDIR/bin/composer.phar ]; then
run_as "cd $WORKDIR;$WORKDIR/bin/composer.phar $@ -d $WORKDIR"
elif [ -f $SOURCEDIR/friendica/bin/composer.phar ]; then
cd $SOURCEDIR/friendica
$SOURCEDIR/friendica/bin/composer.phar "$@" -d $SOURCEDIR/friendica
fi
}
copy_sources() {
installed_version="0.0.0.0"
if [ -f ${WORKDIR}/VERSION ]; then
installed_version="$(cat ${WORKDIR}/VERSION)"
fi
if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then
clone_develop
fi
image_version="0.0.0.0"
if [ -f $SOURCEDIR/friendica/VERSION ]; then
image_version="$(cat $SOURCEDIR/friendica/VERSION)"
else
# no given installation and not using the developer branch => nothing to do
log 'Friendica command '\'$1\'' failed, because of no version found', 0
exit 1;
fi
if version_greater "$installed_version" "$image_version"; then
log 'Can'\''t copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ('$image_version')', 0
exit 1;
fi
if version_greater "$image_version" "$installed_version" ||
echo "$image_version" | grep -Eq '^.*\-dev|-rc'; then
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:root"
else
rsync_options="-rlD"
fi
log 'Copying Friendica sources ('$image_version') from '\'$SOURCEDIR'/friendica'\'' to '\'$WORKDIR\'
rsync $rsync_options --delete --exclude='.git' --exclude='photo' --exclude='proxy' --exclude='.htconfig.php' --exclude='home.*' $SOURCEDIR/friendica/ $WORKDIR/
if [ -f $WORKDIR/view/smarty3 ]; then
chmod -R 777 $WORKDIR/view/smarty3
fi
# the stable packages already have the whole vendor stuff in their images
if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then
composer install
fi
fi
}
# install Friendica
install() {
if [ -f ${WORKDIR}/VERSION ]; then
# If there is a given installation of Friendica and we should not update it => exit
# We have to explicit update Friendica to avoid breaking something
return
fi
log 'Installing Friendica'
copy_sources
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
[ "$AUTOINSTALL" = "true" ]; then
if check_database; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
fi
}
update() {
if [ ! -f ${WORKDIR}/VERSION ]; then
# We want to update a given installation
# if there is no installation, exit
return
fi
log 'Upgrading Friendica'
copy_sources
console dbstructure update
}
configmail() {
if [ "$SMTP" = "localhost" ]; then
# SMTP is a required setting
# do nothing if it is "localhost" (= not changed)
return
fi
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/Linux\ User/${SITENAME}/g" /etc/passwd
# add possible mail-senders
echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" >> /etc/ssmtp/revaliases
# replace ssmtp.conf settings
cat << EOF > /etc/ssmtp/ssmtp.conf
# /etc/ssmtp/ssmtp.conf
root=$SMTP_FROM@$HOSTNAME
hostname=$HOSTNAME
mailhub=$SMTP
FromLineOverride=YES
EOF
[ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf
}
if [ "$#" -eq 0 ]; then
friendica_help
exit 0
fi
case "$1" in
install) shift; install $@;;
update) shift; update $@ ;;
console) shift; console $@ ;;
composer) shift; composer $@ ;;
configmail) shift; configmail $@ ;;
*) friendica_help ;;
esac

View File

@ -1,137 +0,0 @@
<?php
// Custom htconfig.php for Docker usage.
// Uses a lot of environment variables
// Use environment variables for mysql if they are set beforehand
if (!empty(getenv('MYSQL_HOST'))
&& !empty(getenv('MYSQL_PORT'))
&& (!empty(getenv('MYSQL_USERNAME')) || !empty(getenv('MYSQL_USER')))
&& !empty(getenv('MYSQL_PASSWORD'))
&& !empty(getenv('MYSQL_DATABASE'))) {
$db_host = getenv('MYSQL_HOST') . ':' . getenv('MYSQL_PORT');
if (!empty(getenv('MYSQL_USERNAME'))) {
$db_user = getenv('MYSQL_USERNAME');
} elseif (!empty(getenv('MYSQL_USER'))) {
$db_user = getenv('MYSQL_USER');
}
$db_pass = getenv('MYSQL_PASSWORD');
$db_data = getenv('MYSQL_DATABASE');
}
// Set the database connection charset to full Unicode (utf8mb4).
// Changing this value will likely corrupt the special characters.
// You have been warned.
$a->config['system']['db_charset'] = "utf8mb4";
// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles".
// It can be changed later and only applies to timestamps for anonymous viewers.
if (!empty(getenv('TZ'))) {
$default_timezone = getenv('TZ');
} else {
$default_timezone = 'America/Los_Angeles';
}
// Default system language
if (!empty(getenv('LANGUAGE'))) {
$a->config['system']['language'] = getenv('LANGUAGE');
} else {
$a->config['system']['language'] = 'en';
}
// What is your site name?
if (!empty(getenv('SITENAME'))) {
$a->config['sitename'] = getenv('SITENAME');
} else {
$a->config['sitename'] = "Friendica Social Network";
}
// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED.
// Be certain to create your own personal account before setting
// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on
// the registration page. REGISTER_APPROVE requires you set 'admin_email'
// to the email address of an already registered person who can authorise
// and/or approve/deny the request.
// In order to perform system administration via the admin panel, admin_email
// must precisely match the email address of the person logged in.
$a->config['register_policy'] = REGISTER_OPEN;
$a->config['register_text'] = '';
if (!empty(getenv('MAILNAME'))) {
$a->config['admin_email'] = getenv('MAILNAME');
} else {
$a->config['admin_email'] = '';
}
// Maximum size of an imported message, 0 is unlimited
$a->config['max_import_size'] = 200000;
// maximum size of uploaded photos
$a->config['system']['maximagesize'] = 800000;
// Location of PHP command line processor
$a->config['php_path'] = 'php';
// Server-to-server private message encryption (RINO) is allowed by default.
// set to 0 to disable, 1 to enable
$a->config['system']['rino_encrypt'] = 1;
// allowed themes (change this from admin panel after installation)
$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero,smoothly';
// default system theme
$a->config['system']['theme'] = 'vier';
// By default allow pseudonyms
$a->config['system']['no_regfullname'] = true;
//Deny public access to the local directory
//$a->config['system']['block_local_dir'] = false;
// Location of the global directory
$a->config['system']['directory'] = 'https://dir.friendica.social';
// Allowed protocols in link URLs; HTTP protocols always are accepted
$a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid', 'gopher'];
// Authentication cookie lifetime, in days
$a->config['system']['auth_cookie_lifetime'] = 7;
if (!empty(getenv('VALIDATION'))) {
$a->config['system']['disable_url_validation'] = strtolower(getenv('VALIDATION'));
$a->config['system']['disable_email_validation'] = strtolower(getenv('VALIDATION'));
}
if (!empty(getenv('CACHE_DRIVER'))) {
$a->config['system']['cache_driver'] = strtolower(getenv('CACHE_DRIVER'));
if (!empty(getenv('REDIS_HOST'))) {
$a->config['system']['redis_host'] = getenv('REDIS_HOST');
}
if (!empty(getenv('REDIS_PORT'))) {
$a->config['system']['redis_port'] = getenv('REDIS_PORT');
}
if (!empty(getenv('MEMCACHE_HOST'))) {
$a->config['system']['memcache_host'] = getenv('MEMCACHE_HOST');
}
if (!empty(getenv('MEMCACHE_PORT'))) {
$a->config['system']['memcache_port'] = getenv('MEMCACHE_PORT');
}
if (!empty(getenv('MEMCACHED_HOSTS'))) {
$a->config['system']['memcached_hosts'] = getenv('MEMCACHED_HOSTS');
}
}

View File

@ -1,68 +1,87 @@
# 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).
[smtp](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/smtp) | adds SMTP support to the Friendica container (necessary if you want to have mail support in Friendica).
## docker-compose
### SMTP settings <a id="smtpsetting"></a>
In `docker-compose` additional services are bundled to create a complex Friendica installation.
The examples are designed to run out-of-the-box. The binary `ssmtp` is used for the `mail()` support of Friendica.
Before running the examples, you have to modify the `db.env` and `docker-compose.yml` file and fill in your custom information. You have to set the `--hostname/-h` parameter correctly to use the right domainname for the `mail()` command.
The docker-compose examples make heavily use of derived Dockerfiles to add configuration files into the containers. You have to set a valid SMTP-MTA for the `SMTP` environment variable to enable mail support in Friendica.
This way they should also work on remote docker systems as _Docker for Windows_. A valid SMTP-MTA would be, for example, `mx.example.org`.
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.
The following environment variables are possible for the SMTP examples.
### insecure
- `SITENAME` The name of the Friendica node. (**required** - Default: `Testsite`)
This examples should only be used for **testing** on the local network because it uses a unencrypted http connection. - `SMTP` Address of the SMTP Mail-Gateway. (**required** - Default: `localhost`)
When you want to have your server reachable from the internet adding HTTPS-encryption is mandatory! - `SMTP_FROM` Sender user-part of the address. (Default: `no-reply` - e.g. no-reply@friendica.local)
For this use one of the [with-traefik-proxy](#with-traefik-proxy) examples. - `SMTP_AUTH_USER` Username for the SMTP Mail-Gateway. (Default: empty)
- `SMTP_AUTH_PASS` Password for the SMTP Mail-Gateway. (Default: empty)
To use this example complete the following steps: - `SMTP_AUTH_METHOD` Authentication method for the SMTP Mail-Gateway. (Default: empty/plain text)
1. choose a password for the database user in `db.env` behind `MYSQL_PASSWORD=` ## docker-compose
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` In `docker-compose` additional services are bundled to create a complex Friendica installation.
The examples are designed to run out-of-the-box.
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` Before running the examples, you have to modify the `db.env` and `docker-compose.yml` file and fill in your custom information.
### with-traefik-proxy 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_.
The traefik proxy adds a proxy layer between Friendica and the internet. 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.
The proxy is designed to server multiple sites on the same host machine.
### insecure
The advantage in adding this layer is the ability to use [Let's Encrypt](https://letsencrypt.org/) out certification handling of the box.
This examples should only be used for **testing** on the local network because it uses a unencrypted http connection.
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. When you want to have your server reachable from the internet adding HTTPS-encryption is mandatory!
For this use one of the [with-traefik-proxy](#with-traefik-proxy) examples.
To use this example complete the following steps:
To use this example complete the following steps:
1. open `docker-compose.yml`
1. insert your friendica domain behind `hostname:` 1. choose a password for the database user in `db.env` behind `MYSQL_PASSWORD=`
2. insert your friendica domain at `traefik.friendica.rule=Host:friendica.local` 2. run `docker-compose build --pull` to pull the mose recent base images and build the custom dockerfiles
2. choose a password for the database user in `db.env` behind `MYSQL_PASSWORD=` 3. start Friendica with `docker-compose up -d`
3. open `proxy/traefik.toml`
1. replace `domain = "example.org"` with your friendica domain If you want to update your installation to a newer version, repeat 3 and 4.
2. replace `email = "root@example.org"` with a valid email **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`
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` ### with-traefik-proxy
If you want to update your installation to a newer version, repeat 4 and 5. The traefik proxy adds a proxy layer between Friendica and the internet.
The proxy is designed to server multiple sites on the same host machine.
The advantage in adding this layer is the ability to use [Let's Encrypt](https://letsencrypt.org/) out certification handling of the box.
Therefore you have to use adjust the `labels:` inside the `docker-compose.yml` to let traefik know what domains it should route and what certifications it should request.
To use this example complete the following steps:
1. open `docker-compose.yml`
1. insert your friendica domain behind `hostname:`
2. insert your friendica domain at `traefik.friendica.rule=Host:friendica.local`
2. choose a password for the database user in `db.env` behind `MYSQL_PASSWORD=`
3. open `proxy/traefik.toml`
1. replace `domain = "example.org"` with your friendica domain
2. replace `email = "root@example.org"` with a valid email
4. run `docker-compose build --pull` to pull the most recent base images and build the custom dockerfiles
5. start Friendica with `docker-compose up -d`
If you want to update your installation to a newer version, repeat 4 and 5.
**Note**: If you are on a develop branch (*-dev or *-rc) you have to update Friendica with the command `docker-compose exec app friendica update` **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`

View File

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

View File

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

View File

@ -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,52 @@
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 environment:
entrypoint: /cron.sh - SITENAME=
environment: - SMTP=
- CACHE_DRIVER=redis depends_on:
- REDIS_HOST=redis - db
- MAILNAME= hostname: friendica.local
- TZ=
- LANGUAGE= volumes:
- SMTP= db:
env_file:
- db.env
depends_on:
- db
hostname: friendica.local
volumes:
db:
friendica: friendica:

View File

@ -0,0 +1,36 @@
FROM friendica/server:fpm-alpine
RUN set -ex; \
apk add --no-cache \
# For mail() support
ssmtp;
ENV SMTP localhost
ENV SMTP_FROM no-reply
ENV SITENAME "Testsite"
# Setup SSMTP
RUN set -ex; \
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd ;\
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd ;\
# add possible mail-senders
{\
echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" ;\
echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" ;\
} > /etc/ssmtp/revaliases;\
# replace ssmtp.conf settings
{\
echo "root=$SMTP_FROM@$HOSTNAME" ;\
echo "hostname=$HOSTNAME" ;\
echo "mailhub=$SMTP" ;\
echo "FromLineOverride=YES" ;\
[ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" ;\
[ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" ;\
[ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" ;\
[ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" ;\
[ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" ;\
} > /etc/ssmtp/ssmtp.conf;
RUN mkdir -p /usr/src/config
COPY addon.ini.php /usr/src/config/

View File

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

View File

@ -1,70 +1,65 @@
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 environment:
entrypoint: /cron.sh - FRIENDICA_ADMIN_MAIL=
environment: - FRIENDICA_TZ=
- CACHE_DRIVER=redis - FRIENDICA_LANG=
- REDIS_HOST=redis - SITENAME=
- MAILNAME= - SMTP=
- TZ= depends_on:
- LANGUAGE= - db
- SMTP= - app
env_file: hostname: friendica.local
- db.env
depends_on: web:
- db image: nginx
- app restart: always
hostname: friendica.local volumes:
- friendica:/var/www/html:ro
web: - ./web/nginx.conf:/etc/nginx/nginx.conf:ro
image: nginx depends_on:
restart: always - app
volumes: ports:
- friendica:/var/www/html:ro - "80:80"
- ./web/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on: volumes:
- app db:
ports:
- "80:80"
volumes:
db:
friendica: friendica:

View File

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

View File

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

View File

@ -1,68 +1,65 @@
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 environment:
environment: - FRIENDICA_ADMIN_MAIL=
- CACHE_DRIVER=redis - FRIENDICA_TZ=
- REDIS_HOST=redis - FRIENDICA_LANG=
- MAILNAME= - SITENAME=
- TZ= - SMTP=
- LANGUAGE= depends_on:
env_file: - db
- db.env - app
depends_on: hostname: friendica.local
- db
- app web:
hostname: friendica.local image: nginx
restart: always
web: volumes:
image: nginx - friendica:/var/www/html:ro
restart: always - ./web/nginx.conf:/etc/nginx/nginx.conf:ro
volumes: depends_on:
- friendica:/var/www/html:ro - app
- ./web/nginx.conf:/etc/nginx/nginx.conf:ro ports:
depends_on: - "80:80"
- app
ports: volumes:
- "80:80" db:
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

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

View File

@ -0,0 +1,32 @@
FROM friendica/server:fpm-alpine
RUN set -ex; \
apk add --no-cache \
# For mail() support
ssmtp;
ENV SMTP localhost
ENV SMTP_FROM no-reply
ENV SITENAME "Testsite"
# Setup SSMTP
RUN sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd ;\
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd ;\
# add possible mail-senders
{\
echo "www-data:$SMTP_FROM@$HOSTNAME:$SMTP" ;\
echo "root:$SMTP_FROM@$HOSTNAME:$SMTP" ;\
} > /etc/ssmtp/revaliases;\
# replace ssmtp.conf settings
{\
echo "root=$SMTP_FROM@$HOSTNAME" ;\
echo "hostname=$HOSTNAME" ;\
echo "mailhub=$SMTP" ;\
echo "FromLineOverride=YES" ;\
[ -z "$SMTP_TLS" ] || echo "UseTLS=$SMTP_TLS" ;\
[ -z "$SMTP_STARTTLS" ] || echo "UseSTARTTLS=$SMTP_STARTTLS" ;\
[ -z "$SMTP_AUTH_USER" ] || echo "AuthUser=$SMTP_AUTH_USER" ;\
[ -z "$SMTP_AUTH_PASS" ] || echo "AuthPass=$SMTP_AUTH_PASS" ;\
[ -z "$SMTP_AUTH_METHOD" ] || echo "AuthMethod=$SMTP_AUTH_METHOD" ;\
} > /etc/ssmtp/ssmtp.conf;

View File

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

View File

@ -54,23 +54,23 @@ jobs:
- ./generate-stackbrew-library.sh - ./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

@ -10,8 +10,6 @@ RUN set -ex; \
rsync \ rsync \
bzip2 \ bzip2 \
git \ git \
# For mail() support
ssmtp \
; \ ; \
rm -rf /var/lib/apt/lists/*; rm -rf /var/lib/apt/lists/*;
@ -88,6 +86,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 +101,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 +119,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-plugins --no-scripts --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,171 @@
#!/bin/sh
set -eu
# run an command with the www-data user
run_as() {
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "cd /var/www/html;$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
directory_empty() {
[ -z "$(ls -A "$1/")" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
if echo "$friendica_git" | grep -Eq '^.*\-dev'; then
friendica_git="develop"
fi
if echo "$addons_git" | grep -Eq '^.*\-dev'; then
addons_git="develop"
fi
echo "Downloading Friendica from GitHub '${friendica_git}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica /usr/src/friendica"
mkdir /usr/src/friendica/addon
sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons /usr/src/friendica/addon"
echo "Download finished"
/usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica
}
# just check if we execute apache or php-fpm
if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
installed_version="0.0.0.0"
if [ -f /var/www/html/VERSION ]; then
installed_version="$(cat /var/www/html/VERSION)"
fi
check=false
# cloning from git is just possible for develop or Release Candidats
if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then
# just clone & check if it's a new install or upgrade
if [ "$installed_version" = "0.0.0.0" ] || [ "$FRIENDICA_UPGRADE" = "true" ]; then
clone_develop
image_version="$(cat /usr/src/friendica/VERSION)"
check=true
fi
else
image_version="$(cat /usr/src/friendica/VERSION)"
# check it just in case the version is greater
if version_greater "$image_version" "$installed_version"; then
check=true
fi
# no downgrading possible
if version_greater "$installed_version" "$image_version"; then
echo 'Can'\''t copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ('$image_version')', 0
exit 1;
fi
fi
if [ "$check" = true ]; then
echo "Initializing Friendica $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading Friendica from $installed_version ..."
fi
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:www-data"
else
rsync_options="-rlD"
fi
rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/
# copy every *.ini.php from the config directory except they are already copied (in case of an upgrade)
for dir in config; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then
rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/
fi
done
# In case there is no .htaccess, copy it from the default dist file
if [ ! -f "/var/www/html/.htaccess" ]; then
cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess"
fi
if [ -d /var/www/html/view/smarty3 ]; then
chmod -R 777 /var/www/html/view/smarty3
fi
echo "Initializing finished"
# install
if [ "$installed_version" = "0.0.0.0" ]; then
echo "New Friendica instance"
install=false
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then
echo "Installation with environment variables"
# TODO Bug in PHP Path for automatic installation
#FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php}
FRIENDICA_TZ=${FRIENDICA_TZ:-America/LosAngeles}
FRIENDICA_LANG=${FRIENDICA_LANG:-en}
MYSQL_PORT=${MYSQL_PORT:-3306}
if [ -n "${MYSQL_USER+x}" ]; then
MYSQL_USERNAMEFULL=${MYSQL_USER}
else
MYSQL_USERNAMEFULL=${MYSQL_USERNAME}
fi
# shellcheck disable=SC2016
install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"'
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"'
install=true
elif [ -f "/usr/src/config/local.ini.php" ]; then
echo "Installation with prepared local.ini.php"
install_options="-f /usr/src/local.ini.php"
install=true
fi
if [ "$install" = true ]; then
echo "Starting Friendica installation ..."
# TODO Let the database time to warm up - not winning a beauty contest
sleep 10s
run_as "/var/www/html/bin/console autoinstall $install_options"
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.ini.php) to the config folder (currently only local.ini.php and addon.ini.php supported)
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi
echo "Installation finished"
else
echo "Running web-based installer on first connect!"
fi
# upgrade
else
echo "Upgrading Friendica ..."
run_as '/var/www/html/bin/console dbstructure update'
echo "Upgrading finished"
fi
fi
fi
exec "$@"

View File

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

View File

@ -6,9 +6,7 @@ LABEL maintainer="Philipp Holzer <admin@philipp.info>"
RUN set -ex; \ RUN set -ex; \
apk add --no-cache \ apk add --no-cache \
rsync \ rsync \
git \ git;
# For mail() support
ssmtp;
# install the PHP extensions we need # install the PHP extensions we need
# see https://friendi.ca/resources/requirements/ # see https://friendi.ca/resources/requirements/
@ -21,8 +19,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 +73,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 +102,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-plugins --no-scripts --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,171 @@
#!/bin/sh
set -eu
# run an command with the www-data user
run_as() {
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "cd /var/www/html;$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
directory_empty() {
[ -z "$(ls -A "$1/")" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
if echo "$friendica_git" | grep -Eq '^.*\-dev'; then
friendica_git="develop"
fi
if echo "$addons_git" | grep -Eq '^.*\-dev'; then
addons_git="develop"
fi
echo "Downloading Friendica from GitHub '${friendica_git}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica /usr/src/friendica"
mkdir /usr/src/friendica/addon
sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons /usr/src/friendica/addon"
echo "Download finished"
/usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica
}
# just check if we execute apache or php-fpm
if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
installed_version="0.0.0.0"
if [ -f /var/www/html/VERSION ]; then
installed_version="$(cat /var/www/html/VERSION)"
fi
check=false
# cloning from git is just possible for develop or Release Candidats
if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then
# just clone & check if it's a new install or upgrade
if [ "$installed_version" = "0.0.0.0" ] || [ "$FRIENDICA_UPGRADE" = "true" ]; then
clone_develop
image_version="$(cat /usr/src/friendica/VERSION)"
check=true
fi
else
image_version="$(cat /usr/src/friendica/VERSION)"
# check it just in case the version is greater
if version_greater "$image_version" "$installed_version"; then
check=true
fi
# no downgrading possible
if version_greater "$installed_version" "$image_version"; then
echo 'Can'\''t copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ('$image_version')', 0
exit 1;
fi
fi
if [ "$check" = true ]; then
echo "Initializing Friendica $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading Friendica from $installed_version ..."
fi
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:www-data"
else
rsync_options="-rlD"
fi
rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/
# copy every *.ini.php from the config directory except they are already copied (in case of an upgrade)
for dir in config; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then
rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/
fi
done
# In case there is no .htaccess, copy it from the default dist file
if [ ! -f "/var/www/html/.htaccess" ]; then
cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess"
fi
if [ -d /var/www/html/view/smarty3 ]; then
chmod -R 777 /var/www/html/view/smarty3
fi
echo "Initializing finished"
# install
if [ "$installed_version" = "0.0.0.0" ]; then
echo "New Friendica instance"
install=false
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then
echo "Installation with environment variables"
# TODO Bug in PHP Path for automatic installation
#FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php}
FRIENDICA_TZ=${FRIENDICA_TZ:-America/LosAngeles}
FRIENDICA_LANG=${FRIENDICA_LANG:-en}
MYSQL_PORT=${MYSQL_PORT:-3306}
if [ -n "${MYSQL_USER+x}" ]; then
MYSQL_USERNAMEFULL=${MYSQL_USER}
else
MYSQL_USERNAMEFULL=${MYSQL_USERNAME}
fi
# shellcheck disable=SC2016
install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"'
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"'
install=true
elif [ -f "/usr/src/config/local.ini.php" ]; then
echo "Installation with prepared local.ini.php"
install_options="-f /usr/src/local.ini.php"
install=true
fi
if [ "$install" = true ]; then
echo "Starting Friendica installation ..."
# TODO Let the database time to warm up - not winning a beauty contest
sleep 10s
run_as "/var/www/html/bin/console autoinstall $install_options"
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.ini.php) to the config folder (currently only local.ini.php and addon.ini.php supported)
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi
echo "Installation finished"
else
echo "Running web-based installer on first connect!"
fi
# upgrade
else
echo "Upgrading Friendica ..."
run_as '/var/www/html/bin/console dbstructure update'
echo "Upgrading finished"
fi
fi
fi
exec "$@"

View File

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

View File

@ -10,8 +10,6 @@ RUN set -ex; \
rsync \ rsync \
bzip2 \ bzip2 \
git \ git \
# For mail() support
ssmtp \
; \ ; \
rm -rf /var/lib/apt/lists/*; rm -rf /var/lib/apt/lists/*;
@ -88,24 +86,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 +111,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-plugins --no-scripts --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

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

@ -0,0 +1,171 @@
#!/bin/sh
set -eu
# run an command with the www-data user
run_as() {
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "cd /var/www/html;$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
directory_empty() {
[ -z "$(ls -A "$1/")" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
if echo "$friendica_git" | grep -Eq '^.*\-dev'; then
friendica_git="develop"
fi
if echo "$addons_git" | grep -Eq '^.*\-dev'; then
addons_git="develop"
fi
echo "Downloading Friendica from GitHub '${friendica_git}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica /usr/src/friendica"
mkdir /usr/src/friendica/addon
sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons /usr/src/friendica/addon"
echo "Download finished"
/usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica
}
# just check if we execute apache or php-fpm
if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
installed_version="0.0.0.0"
if [ -f /var/www/html/VERSION ]; then
installed_version="$(cat /var/www/html/VERSION)"
fi
check=false
# cloning from git is just possible for develop or Release Candidats
if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then
# just clone & check if it's a new install or upgrade
if [ "$installed_version" = "0.0.0.0" ] || [ "$FRIENDICA_UPGRADE" = "true" ]; then
clone_develop
image_version="$(cat /usr/src/friendica/VERSION)"
check=true
fi
else
image_version="$(cat /usr/src/friendica/VERSION)"
# check it just in case the version is greater
if version_greater "$image_version" "$installed_version"; then
check=true
fi
# no downgrading possible
if version_greater "$installed_version" "$image_version"; then
echo 'Can'\''t copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ('$image_version')', 0
exit 1;
fi
fi
if [ "$check" = true ]; then
echo "Initializing Friendica $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading Friendica from $installed_version ..."
fi
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:www-data"
else
rsync_options="-rlD"
fi
rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/
# copy every *.ini.php from the config directory except they are already copied (in case of an upgrade)
for dir in config; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then
rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/
fi
done
# In case there is no .htaccess, copy it from the default dist file
if [ ! -f "/var/www/html/.htaccess" ]; then
cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess"
fi
if [ -d /var/www/html/view/smarty3 ]; then
chmod -R 777 /var/www/html/view/smarty3
fi
echo "Initializing finished"
# install
if [ "$installed_version" = "0.0.0.0" ]; then
echo "New Friendica instance"
install=false
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then
echo "Installation with environment variables"
# TODO Bug in PHP Path for automatic installation
#FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php}
FRIENDICA_TZ=${FRIENDICA_TZ:-America/LosAngeles}
FRIENDICA_LANG=${FRIENDICA_LANG:-en}
MYSQL_PORT=${MYSQL_PORT:-3306}
if [ -n "${MYSQL_USER+x}" ]; then
MYSQL_USERNAMEFULL=${MYSQL_USER}
else
MYSQL_USERNAMEFULL=${MYSQL_USERNAME}
fi
# shellcheck disable=SC2016
install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"'
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"'
install=true
elif [ -f "/usr/src/config/local.ini.php" ]; then
echo "Installation with prepared local.ini.php"
install_options="-f /usr/src/local.ini.php"
install=true
fi
if [ "$install" = true ]; then
echo "Starting Friendica installation ..."
# TODO Let the database time to warm up - not winning a beauty contest
sleep 10s
run_as "/var/www/html/bin/console autoinstall $install_options"
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.ini.php) to the config folder (currently only local.ini.php and addon.ini.php supported)
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi
echo "Installation finished"
else
echo "Running web-based installer on first connect!"
fi
# upgrade
else
echo "Upgrading Friendica ..."
run_as '/var/www/html/bin/console dbstructure update'
echo "Upgrading finished"
fi
fi
fi
exec "$@"

View File

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

View File

@ -10,8 +10,6 @@ RUN set -ex; \
rsync \ rsync \
bzip2 \ bzip2 \
git \ git \
# For mail() support
ssmtp \
; \ ; \
rm -rf /var/lib/apt/lists/*; rm -rf /var/lib/apt/lists/*;
@ -88,6 +86,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 +101,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,171 @@
#!/bin/sh
set -eu
# run an command with the www-data user
run_as() {
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "cd /var/www/html;$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
directory_empty() {
[ -z "$(ls -A "$1/")" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
if echo "$friendica_git" | grep -Eq '^.*\-dev'; then
friendica_git="develop"
fi
if echo "$addons_git" | grep -Eq '^.*\-dev'; then
addons_git="develop"
fi
echo "Downloading Friendica from GitHub '${friendica_git}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica /usr/src/friendica"
mkdir /usr/src/friendica/addon
sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons /usr/src/friendica/addon"
echo "Download finished"
/usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica
}
# just check if we execute apache or php-fpm
if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
installed_version="0.0.0.0"
if [ -f /var/www/html/VERSION ]; then
installed_version="$(cat /var/www/html/VERSION)"
fi
check=false
# cloning from git is just possible for develop or Release Candidats
if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then
# just clone & check if it's a new install or upgrade
if [ "$installed_version" = "0.0.0.0" ] || [ "$FRIENDICA_UPGRADE" = "true" ]; then
clone_develop
image_version="$(cat /usr/src/friendica/VERSION)"
check=true
fi
else
image_version="$(cat /usr/src/friendica/VERSION)"
# check it just in case the version is greater
if version_greater "$image_version" "$installed_version"; then
check=true
fi
# no downgrading possible
if version_greater "$installed_version" "$image_version"; then
echo 'Can'\''t copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ('$image_version')', 0
exit 1;
fi
fi
if [ "$check" = true ]; then
echo "Initializing Friendica $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading Friendica from $installed_version ..."
fi
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:www-data"
else
rsync_options="-rlD"
fi
rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/
# copy every *.ini.php from the config directory except they are already copied (in case of an upgrade)
for dir in config; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then
rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/
fi
done
# In case there is no .htaccess, copy it from the default dist file
if [ ! -f "/var/www/html/.htaccess" ]; then
cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess"
fi
if [ -d /var/www/html/view/smarty3 ]; then
chmod -R 777 /var/www/html/view/smarty3
fi
echo "Initializing finished"
# install
if [ "$installed_version" = "0.0.0.0" ]; then
echo "New Friendica instance"
install=false
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then
echo "Installation with environment variables"
# TODO Bug in PHP Path for automatic installation
#FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php}
FRIENDICA_TZ=${FRIENDICA_TZ:-America/LosAngeles}
FRIENDICA_LANG=${FRIENDICA_LANG:-en}
MYSQL_PORT=${MYSQL_PORT:-3306}
if [ -n "${MYSQL_USER+x}" ]; then
MYSQL_USERNAMEFULL=${MYSQL_USER}
else
MYSQL_USERNAMEFULL=${MYSQL_USERNAME}
fi
# shellcheck disable=SC2016
install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"'
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"'
install=true
elif [ -f "/usr/src/config/local.ini.php" ]; then
echo "Installation with prepared local.ini.php"
install_options="-f /usr/src/local.ini.php"
install=true
fi
if [ "$install" = true ]; then
echo "Starting Friendica installation ..."
# TODO Let the database time to warm up - not winning a beauty contest
sleep 10s
run_as "/var/www/html/bin/console autoinstall $install_options"
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.ini.php) to the config folder (currently only local.ini.php and addon.ini.php supported)
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi
echo "Installation finished"
else
echo "Running web-based installer on first connect!"
fi
# upgrade
else
echo "Upgrading Friendica ..."
run_as '/var/www/html/bin/console dbstructure update'
echo "Upgrading finished"
fi
fi
fi
exec "$@"

View File

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

View File

@ -6,9 +6,7 @@ LABEL maintainer="Philipp Holzer <admin@philipp.info>"
RUN set -ex; \ RUN set -ex; \
apk add --no-cache \ apk add --no-cache \
rsync \ rsync \
git \ git;
# For mail() support
ssmtp;
# install the PHP extensions we need # install the PHP extensions we need
# see https://friendi.ca/resources/requirements/ # see https://friendi.ca/resources/requirements/
@ -21,8 +19,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 +73,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,171 @@
#!/bin/sh
set -eu
# run an command with the www-data user
run_as() {
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "cd /var/www/html;$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
directory_empty() {
[ -z "$(ls -A "$1/")" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
if echo "$friendica_git" | grep -Eq '^.*\-dev'; then
friendica_git="develop"
fi
if echo "$addons_git" | grep -Eq '^.*\-dev'; then
addons_git="develop"
fi
echo "Downloading Friendica from GitHub '${friendica_git}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica /usr/src/friendica"
mkdir /usr/src/friendica/addon
sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons /usr/src/friendica/addon"
echo "Download finished"
/usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica
}
# just check if we execute apache or php-fpm
if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
installed_version="0.0.0.0"
if [ -f /var/www/html/VERSION ]; then
installed_version="$(cat /var/www/html/VERSION)"
fi
check=false
# cloning from git is just possible for develop or Release Candidats
if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then
# just clone & check if it's a new install or upgrade
if [ "$installed_version" = "0.0.0.0" ] || [ "$FRIENDICA_UPGRADE" = "true" ]; then
clone_develop
image_version="$(cat /usr/src/friendica/VERSION)"
check=true
fi
else
image_version="$(cat /usr/src/friendica/VERSION)"
# check it just in case the version is greater
if version_greater "$image_version" "$installed_version"; then
check=true
fi
# no downgrading possible
if version_greater "$installed_version" "$image_version"; then
echo 'Can'\''t copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ('$image_version')', 0
exit 1;
fi
fi
if [ "$check" = true ]; then
echo "Initializing Friendica $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading Friendica from $installed_version ..."
fi
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:www-data"
else
rsync_options="-rlD"
fi
rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/
# copy every *.ini.php from the config directory except they are already copied (in case of an upgrade)
for dir in config; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then
rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/
fi
done
# In case there is no .htaccess, copy it from the default dist file
if [ ! -f "/var/www/html/.htaccess" ]; then
cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess"
fi
if [ -d /var/www/html/view/smarty3 ]; then
chmod -R 777 /var/www/html/view/smarty3
fi
echo "Initializing finished"
# install
if [ "$installed_version" = "0.0.0.0" ]; then
echo "New Friendica instance"
install=false
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then
echo "Installation with environment variables"
# TODO Bug in PHP Path for automatic installation
#FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php}
FRIENDICA_TZ=${FRIENDICA_TZ:-America/LosAngeles}
FRIENDICA_LANG=${FRIENDICA_LANG:-en}
MYSQL_PORT=${MYSQL_PORT:-3306}
if [ -n "${MYSQL_USER+x}" ]; then
MYSQL_USERNAMEFULL=${MYSQL_USER}
else
MYSQL_USERNAMEFULL=${MYSQL_USERNAME}
fi
# shellcheck disable=SC2016
install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"'
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"'
install=true
elif [ -f "/usr/src/config/local.ini.php" ]; then
echo "Installation with prepared local.ini.php"
install_options="-f /usr/src/local.ini.php"
install=true
fi
if [ "$install" = true ]; then
echo "Starting Friendica installation ..."
# TODO Let the database time to warm up - not winning a beauty contest
sleep 10s
run_as "/var/www/html/bin/console autoinstall $install_options"
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.ini.php) to the config folder (currently only local.ini.php and addon.ini.php supported)
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi
echo "Installation finished"
else
echo "Running web-based installer on first connect!"
fi
# upgrade
else
echo "Upgrading Friendica ..."
run_as '/var/www/html/bin/console dbstructure update'
echo "Upgrading finished"
fi
fi
fi
exec "$@"

View File

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

View File

@ -10,8 +10,6 @@ RUN set -ex; \
rsync \ rsync \
bzip2 \ bzip2 \
git \ git \
# For mail() support
ssmtp \
; \ ; \
rm -rf /var/lib/apt/lists/*; rm -rf /var/lib/apt/lists/*;
@ -88,24 +86,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,171 @@
#!/bin/sh
set -eu
# run an command with the www-data user
run_as() {
if [ "$(id -u)" -eq 0 ]; then
su - www-data -s /bin/sh -c "cd /var/www/html;$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
directory_empty() {
[ -z "$(ls -A "$1/")" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
if echo "$friendica_git" | grep -Eq '^.*\-dev'; then
friendica_git="develop"
fi
if echo "$addons_git" | grep -Eq '^.*\-dev'; then
addons_git="develop"
fi
echo "Downloading Friendica from GitHub '${friendica_git}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica /usr/src/friendica"
mkdir /usr/src/friendica/addon
sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons /usr/src/friendica/addon"
echo "Download finished"
/usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica
}
# just check if we execute apache or php-fpm
if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
installed_version="0.0.0.0"
if [ -f /var/www/html/VERSION ]; then
installed_version="$(cat /var/www/html/VERSION)"
fi
check=false
# cloning from git is just possible for develop or Release Candidats
if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then
# just clone & check if it's a new install or upgrade
if [ "$installed_version" = "0.0.0.0" ] || [ "$FRIENDICA_UPGRADE" = "true" ]; then
clone_develop
image_version="$(cat /usr/src/friendica/VERSION)"
check=true
fi
else
image_version="$(cat /usr/src/friendica/VERSION)"
# check it just in case the version is greater
if version_greater "$image_version" "$installed_version"; then
check=true
fi
# no downgrading possible
if version_greater "$installed_version" "$image_version"; then
echo 'Can'\''t copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ('$image_version')', 0
exit 1;
fi
fi
if [ "$check" = true ]; then
echo "Initializing Friendica $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading Friendica from $installed_version ..."
fi
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:www-data"
else
rsync_options="-rlD"
fi
rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/
# copy every *.ini.php from the config directory except they are already copied (in case of an upgrade)
for dir in config; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then
rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/
fi
done
# In case there is no .htaccess, copy it from the default dist file
if [ ! -f "/var/www/html/.htaccess" ]; then
cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess"
fi
if [ -d /var/www/html/view/smarty3 ]; then
chmod -R 777 /var/www/html/view/smarty3
fi
echo "Initializing finished"
# install
if [ "$installed_version" = "0.0.0.0" ]; then
echo "New Friendica instance"
install=false
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then
echo "Installation with environment variables"
# TODO Bug in PHP Path for automatic installation
#FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php}
FRIENDICA_TZ=${FRIENDICA_TZ:-America/LosAngeles}
FRIENDICA_LANG=${FRIENDICA_LANG:-en}
MYSQL_PORT=${MYSQL_PORT:-3306}
if [ -n "${MYSQL_USER+x}" ]; then
MYSQL_USERNAMEFULL=${MYSQL_USER}
else
MYSQL_USERNAMEFULL=${MYSQL_USERNAME}
fi
# shellcheck disable=SC2016
install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"'
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"'
install=true
elif [ -f "/usr/src/config/local.ini.php" ]; then
echo "Installation with prepared local.ini.php"
install_options="-f /usr/src/local.ini.php"
install=true
fi
if [ "$install" = true ]; then
echo "Starting Friendica installation ..."
# TODO Let the database time to warm up - not winning a beauty contest
sleep 10s
run_as "/var/www/html/bin/console autoinstall $install_options"
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.ini.php) to the config folder (currently only local.ini.php and addon.ini.php supported)
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi
echo "Installation finished"
else
echo "Running web-based installer on first connect!"
fi
# upgrade
else
echo "Upgrading Friendica ..."
run_as '/var/www/html/bin/console dbstructure update'
echo "Upgrading finished"
fi
fi
fi
exec "$@"

View File

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

View File

@ -5,9 +5,7 @@ LABEL maintainer="Philipp Holzer <admin@philipp.info>"
RUN set -ex; \ RUN set -ex; \
apk add --no-cache \ apk add --no-cache \
rsync \ rsync \
git \ git;
# For mail() support
ssmtp;
# install the PHP extensions we need # install the PHP extensions we need
# see https://friendi.ca/resources/requirements/ # see https://friendi.ca/resources/requirements/
@ -20,8 +18,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 +72,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

@ -9,8 +9,6 @@ RUN set -ex; \
rsync \ rsync \
bzip2 \ bzip2 \
git \ git \
# For mail() support
ssmtp \
; \ ; \
rm -rf /var/lib/apt/lists/*; rm -rf /var/lib/apt/lists/*;
@ -87,24 +85,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 :-)
``` ```

624
README.md
View File

@ -1,329 +1,295 @@
# 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. see the [example](https://github.com/friendica/docker/tree/master/.examples/dockerfiles/README.md#smtpsetting)
**Caching** ## Database settings
- `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 link a running database container, e. g. `--link my-mysql:mysql`, and then use `mysql` as the database host on setup.
- `MEMCACHE_PORT` Port of the memcache cache server. (Default: `11211`)
- `MEMCACHED_HOSTS` Hosts of the memcached cache server. (Default: `[['127.0.0.1', 11211]]`) ## Persistent data
- `REDIS_HOST` Host of the redis cache server. (Default: `127.0.0.1`)
- `REDIS_PORT` Port of the redis cache server. (Default: `6379`) The Friendica installation and all data beyond what lives in the database (file uploads, etc) is stored in the [unnamed docker volume](https://docs.docker.com/engine/tutorials/dockervolumes/#adding-a-data-volume) volume `/var/www/html`.
The docker daemon will store that data within the docker directory `/var/lib/docker/volumes/...`.
That means your data is saved even if the container crashes, is stopped or deleted.
## Administrator account
To make your data persistent to upgrading and get access for backups is using named docker volume or mount a host folder.
Because Friendica links the administrator account to a specific mail address, you **have** to set a valid address for `MAILNAME`. To achieve this you need one volume for your database container and Friendica.
## Mail settings Friendica:
The binary `ssmtp` is used for the `mail()` support of Friendica. - `/var/www/html/` folder where all Friendica data lives
You have to set the `--hostname/-h` parameter correctly to use the right domainname for the `mail()` command. ```console
$ docker run -d \
You have to set a valid SMTP-MTA for the `SMTP` environment variable to enable mail support in Friendica. -v friendica-vol-1:/var/www/html \
A valid SMTP-MTA would be, for example, `mx.example.org`. friendica/server
```
## Database settings
Database:
You have to link a running database container, e. g. `--link my-mysql:mysql`, and then use `mysql` as the database host on setup.
- `/var/lib/mysql` MySQL / MariaDB Data
## Persistent data
```console
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`. $ docker run -d \
The docker daemon will store that data within the docker directory `/var/lib/docker/volumes/...`. -v mysql-vol-1:/var/lib/mysql \
That means your data is saved even if the container crashes, is stopped or deleted. mariadb
```
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. ## Automatic installation
Friendica: The Friendica image supports auto configuration via environment variables.
You can preconfigure everything that is asked on the install page on first run.
- `/var/www/html/` folder where all Friendica data lives To enable the automatic installation, there are two possibilities:
```console ### Environment Variables
$ docker run -d \
-v friendica-vol-1:/var/www/html \ You have to set at least the following environment variables (others are optional).
friendica/server
``` - `FRIENDICA_ADMIN_MAIL` E-Mail address of the administrator.
- `MYSQL_USERNAME` or `MYSQL_USER` Username for the database user using mysql/mariadb.
Database: - `MYSQL_PASSWORD` Password for the database user using mysql / mariadb.
- `MYSQL_DATABASE` Name of the database using mysql / mariadb.
- `/var/lib/mysql` MySQL / MariaDB Data - `MYSQL_HOST` Hostname of the database server using mysql / mariadb.
```console ### Using a predefined config file
$ docker run -d \
-v mysql-vol-1:/var/lib/mysql \ You can create a `local.ini.php` and `COPY` it to `/usr/src/config`.
mariadb If no other environment variable is set, this `local.ini.php` will get copied to the config path.
```
# Maintenance of the image
## Automatic installation
## Updating to a newer version
The Friendica image supports auto configuration via environment variables.
You can preconfigure everything that is asked on the install page on first run. There are differences between the deveop (everything which ends with `-rc` or `-dev`) and the stable (the rest) branches.
To enable the automatic installation, you have to set `AUTOINSTALL` to `true`.
### Updating stable
# Maintenance of the image
You have to pull the latest image from the hub (`docker pull friendica`).
## Updating to a newer version The stable branch gets checked at every startup and will get updated if no installation was found or a new image is used.
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. ### Updating develop
They have both in common that normally we do not automatically overwrite your working directory with the new version. You don't need to pull the image for each commit in [friendica](https://github.com/friendica/friendica/).
Instead you need to explicit run `friendica update` for the node for updating files&database. Instead, the develop branch will get updated if no installation was found or the environment variable `FRIENDICA_UPGRADE` is set to `true`.
### Updating stable It will clone the latest Friendica version and copy it to your working directory.
You have to pull the latest image from the hub (`docker pull friendica`). # Running this image with docker-compose
### Updating develop The easiest way to get a fully featured and functional setup is using a `docker-compose` file.
There are too many different possibilities to setup your system, so here are only some examples what you have to look for.
You don't need to pull the image for each commit in [friendica](https://github.com/friendica/friendica/).
Instead you can just update your node with executing `friendica update` on the node. At first make sure you have chosen the right base image (fpm or apache) and added the features you wanted (see below).
Example: 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!
```console See below for more information.
$ docker exec -ti friendica_running_node friendica update
``` ## Base version - apache
It will clone the latest Friendica version and copy it to your working directory. This version will use the apache image and add a mariaDB container.
The volumes are set to keep your data persistent.
## The `friendica` CLI This setup provides **no ssl encryption** and is intended to run behind a proxy.
To make the usage of the Docker images smooth, we created a little CLI. Make sure to set the variable `MYSQL_PASSWORD` before run this setup.
It wraps the common commands for Friendica and adds new commands.
```yaml
You can call it with version: '2'
```console services:
$ docker exec -ti friendica_running_node friendica <command> db:
``` image: mariadb
restart: always
Commands: volumes:
- db:/var/lib/mysql
- `console` Executes an command in the Friendica console (`bin/console.php` wrapper) environment:
- `composer` Executes the composer.phar executable for Friendica (`bin/composer.phar` wrapper) - MYSQL_USER=friendica
- `install` Installs Friendica on a empty environment (gets called automatically during first start) - MYSQL_PASSWORD=
- `update` Updates Friendica on a **existing** environment - MYSQL_DATABASE=friendica
- MYSQL_RANDOM_ROOT_PASSWORD=yes
# Running this image with docker-compose
app:
The easiest way to get a fully featured and functional setup is using a `docker-compose` file. image: friendica/server
There are too many different possibilities to setup your system, so here are only some examples what you have to look for. restart: always
volumes:
At first make sure you have chosen the right base image (fpm or apache) and added the features you wanted (see below). - friendica:/var/www/html
In every case you want to add a database container and docker volumes to get easy access to your persistent data. ports:
When you want your server reachable from the internet adding HTTPS-encryption is mandatory! - "8080:80"
See below for more information. environment:
- MYSQL_HOST=db
## Base version - apache - MYSQL_USER=friendica
- MYSQL_PASSWORD=
This version will use the apache image and add a mariaDB container. - MYSQL_DATABASE=friendica
The volumes are set to keep your data persistent. - FRIENDICA_ADMIN_MAIL=root@friendica.local
This setup provides **no ssl encryption** and is intended to run behind a proxy. hostname: friendica.local
depends_on:
Make sure to set the variable `MYSQL_PASSWORD` before run this setup. - db
```yaml volumes:
version: '2' db:
friendica:
services: ```
db:
image: mariadb Then run `docker-compose up -d`, now you can access Friendica at http://localhost:8080/ from your system.
restart: always
volumes: ## Base version - FPM
- db:/var/lib/mysql
environment: 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_USER=friendica In this example a simple nginx container is combined with the Friendica-fpm image and a MariaDB database container.
- MYSQL_PASSWORD= The data is stored in docker volumes.
- MYSQL_DATABASE=friendica The nginx container also need access to static files from your Friendica installation.
- MYSQL_RANDOM_ROOT_PASSWORD=yes It gets access to all the volumes mounted to Friendica via the `volumes_from` option.
The configuration for nginx is stored in the configuration file `nginx.conf` that is mounted into the container.
app:
image: friendica/server An example can be found in the [examples section](https://github.com/friendica/docker/tree/master/.examples).
restart: always
volumes: As this setup does **not include encryption** it should to be run behind a proxy.
- friendica:/var/www/html
ports: Prerequisites for this example:
- "8080:80" - Make sure to set the variable `MYSQL_PASSWORD` before you run the setup.
environment: - 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))
- MYSQL_HOST=db
- MYSQL_PORT=3306 ```yaml
- MYSQL_USER=friendica version: '2'
- MYSQL_PASSWORD=
- MYSQL_DATABASE=friendica services:
- MAILNAME=root@friendica.local db:
hostname: friendica.local image: mariadb
depends_on: restart: always
- db volumes:
- db:/var/lib/mysql
volumes: environment:
db: - MYSQL_USER=friendica
friendica: - MYSQL_PASSWORD=
``` - MYSQL_DATABASE=friendica
- MYSQL_RANDOM_ROOT_PASSWORD=yes
Then run `docker-compose up -d`, now you can access Friendica at http://localhost:8080/ from your system.
app:
## Base version - FPM image: friendica/server:fpm
restart: always
When using the FPM image you need another container that acts as web server on port 80 and proxies requests to the Friendica container. volumes:
In this example a simple nginx container is combined with the Friendica-fpm image and a MariaDB database container. - friendica:/var/www/html
The data is stored in docker volumes. environment:
The nginx container also need access to static files from your Friendica installation. - MYSQL_HOST=db
It gets access to all the volumes mounted to Friendica via the `volumes_from` option. - MYSQL_USER=friendica
The configuration for nginx is stored in the configuration file `nginx.conf` that is mounted into the container. - MYSQL_PASSWORD=
- MYSQL_DATABASE=friendica
An example can be found in the [examples section](https://github.com/friendica/docker/tree/master/.examples). - FRIENDICA_ADMIN_MAIL=root@friendica.local
hostname: friendica.local
As this setup does **not include encryption** it should to be run behind a proxy. networks:
- proxy-tier
Prerequisites for this example: - default
- 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)) web:
image: nginx
```yaml ports:
version: '2' - 8080:80
links:
services: - app
db: volumes:
image: mariadb - ./nginx.conf:/etc/nginx/nginx.conf:ro
restart: always restart: always
volumes: networks:
- db:/var/lib/mysql - proxy-tier
environment:
- MYSQL_USER=friendica volumes:
- MYSQL_PASSWORD= db:
- MYSQL_DATABASE=friendica friendica:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
networks:
app: proxy-tier:
image: friendica/server:fpm ```
restart: always
volumes: Then run `docker-compose up -d`, now you can access Friendica at http://localhost:8080/ from your system.
- friendica:/var/www/html
environment: # Questions / Issues
- MYSQL_HOST=db
- MYSQL_PORT=3306 If you got any questions or problems using the image, please visit our [Github Repository](https://github.com/friendica/docker) and write an issue.
- MYSQL_USER=friendica
- MYSQL_PASSWORD=
- MYSQL_DATABASE=friendica
- MAILNAME=root@friendica.local
hostname: friendica.local
networks:
- proxy-tier
- default
web:
image: nginx
ports:
- 8080:80
links:
- app
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
restart: always
networks:
- proxy-tier
volumes:
db:
friendica:
networks:
proxy-tier:
```
Then run `docker-compose up -d`, now you can access Friendica at http://localhost:8080/ from your system.
# Questions / Issues
If you got any questions or problems using the image, please visit our [Github Repository](https://github.com/friendica/docker) and write an issue.

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,171 @@
#!/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" ]
}
directory_empty() {
[ -z "$(ls -A "$1/")" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
if echo "$friendica_git" | grep -Eq '^.*\-dev'; then
friendica_git="develop"
fi
if echo "$addons_git" | grep -Eq '^.*\-dev'; then
addons_git="develop"
fi
echo "Downloading Friendica from GitHub '${friendica_git}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
sh -c "git clone -q -b ${friendica_git} https://github.com/friendica/friendica /usr/src/friendica"
mkdir /usr/src/friendica/addon
sh -c "git clone -q -b ${addons_git} https://github.com/friendica/friendica-addons /usr/src/friendica/addon"
echo "Download finished"
/usr/src/friendica/bin/composer.phar install --no-dev --no-plugins --no-scripts -d /usr/src/friendica
}
# just check if we execute apache or php-fpm
if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
installed_version="0.0.0.0"
if [ -f /var/www/html/VERSION ]; then
installed_version="$(cat /var/www/html/VERSION)"
fi
check=false
# cloning from git is just possible for develop or Release Candidats
if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then
# just clone & check if it's a new install or upgrade
if [ "$installed_version" = "0.0.0.0" ] || [ "$FRIENDICA_UPGRADE" = "true" ]; then
clone_develop
image_version="$(cat /usr/src/friendica/VERSION)"
check=true
fi
else
image_version="$(cat /usr/src/friendica/VERSION)"
# check it just in case the version is greater
if version_greater "$image_version" "$installed_version"; then
check=true
fi
# no downgrading possible
if version_greater "$installed_version" "$image_version"; then
echo 'Can'\''t copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ('$image_version')', 0
exit 1;
fi
fi
if [ "$check" = true ]; then
echo "Initializing Friendica $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading Friendica from $installed_version ..."
fi
if [ "$(id -u)" -eq 0 ]; then
rsync_options="-rlDog --chown=www-data:www-data"
else
rsync_options="-rlD"
fi
rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/friendica/ /var/www/html/
# copy every *.ini.php from the config directory except they are already copied (in case of an upgrade)
for dir in config; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then
rsync $rsync_options --include="/$dir/" --exclude="/*" /usr/src/friendica/ /var/www/html/
fi
done
# In case there is no .htaccess, copy it from the default dist file
if [ ! -f "/var/www/html/.htaccess" ]; then
cp "/var/www/html/.htaccess-dist" "/var/www/html/.htaccess"
fi
if [ -d /var/www/html/view/smarty3 ]; then
chmod -R 777 /var/www/html/view/smarty3
fi
echo "Initializing finished"
# install
if [ "$installed_version" = "0.0.0.0" ]; then
echo "New Friendica instance"
install=false
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then
echo "Installation with environment variables"
# TODO Bug in PHP Path for automatic installation
#FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php}
FRIENDICA_TZ=${FRIENDICA_TZ:-America/LosAngeles}
FRIENDICA_LANG=${FRIENDICA_LANG:-en}
MYSQL_PORT=${MYSQL_PORT:-3306}
if [ -n "${MYSQL_USER+x}" ]; then
MYSQL_USERNAMEFULL=${MYSQL_USER}
else
MYSQL_USERNAMEFULL=${MYSQL_USERNAME}
fi
# shellcheck disable=SC2016
install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"'
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"'
install=true
elif [ -f "/usr/src/config/local.ini.php" ]; then
echo "Installation with prepared local.ini.php"
install_options="-f /usr/src/local.ini.php"
install=true
fi
if [ "$install" = true ]; then
echo "Starting Friendica installation ..."
# TODO Let the database time to warm up - not winning a beauty contest
sleep 10s
run_as "/var/www/html/bin/console autoinstall $install_options"
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.ini.php) to the config folder (currently only local.ini.php and addon.ini.php supported)
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi
echo "Installation finished"
else
echo "Running web-based installer on first connect!"
fi
# upgrade
else
echo "Upgrading Friendica ..."
run_as '/var/www/html/bin/console dbstructure update'
echo "Upgrading finished"
fi
fi
fi
exec "$@"

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-plugins --no-scripts --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

7
upgrade.exclude Normal file
View File

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