2
0
Fork 0
mirror of https://github.com/friendica/docker synced 2026-01-02 17:13:32 +01:00

Init the Friendica Docker Repository

- Added develop images (apache, fpm, fpm-alpine)
- Added stable images 3.6 (apache, fpm, fpm-alpine)
- Added .travis.yml for testing
This commit is contained in:
Philipp Holzer 2018-05-18 21:20:22 +02:00
commit 6ea2875ebf
No known key found for this signature in database
GPG key ID: 58160D7D6AF942B6
36 changed files with 2598 additions and 3 deletions

106
develop/apache/Dockerfile Normal file
View file

@ -0,0 +1,106 @@
FROM php:7.1-apache
LABEL maintainer="Philipp Holzer <admin@philipp.info>"
ENV IMAGICK_PECL 3.4.3
ENV AUTOINSTALL false
# entrypoint.sh and cron.sh dependencies
RUN set -ex; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
rsync \
bzip2 \
busybox-static \
git \
; \
rm -rf /var/lib/apt/lists/*; \
\
mkdir -p /var/spool/cron/crontabs; \
echo '*/10 * * * * cd /var/www/html && php -f bin/worker.php' > /var/spool/cron/crontabs/www-data
# install the PHP extensions we need
# see https://friendi.ca/resources/requirements/
RUN set -ex; \
\
savedAptMark="$(apt-mark showmanual)"; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
libxml2-dev \
mysql-client \
bash \
autoconf \
g++ \
make \
openssl \
libssl-dev \
libpng12-0 \
libpng12-dev \
libjpeg62-turbo-dev \
libtool \
libmcrypt4 \
libmcrypt-dev \
imagemagick \
libmagick++-dev \
libgraphicsmagick1-dev \
libfreetype6 \
libfreetype6-dev \
librsvg2-2 \
libcurl4-openssl-dev \
curl \
; \
\
debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \
pecl install imagick-${IMAGICK_PECL}; \
docker-php-ext-enable imagick; \
pecl clear-cache \
; \
docker-php-ext-configure gd \
--with-gd \
--enable-gd-native-ttf \
--with-freetype-dir=/usr/include/ \
--with-png-dir=/usr/include/ \
--with-jpeg-dir=/usr/include/ \
; \
docker-php-ext-install -j 4 curl pdo pdo_mysql xml gd zip opcache mbstring posix ctype json iconv mcrypt \
; \
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
apt-mark auto '.*' > /dev/null; \
apt-mark manual $savedAptMark; \
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
| awk '/=>/ { print $3 }' \
| sort -u \
| xargs -r dpkg-query -S \
| cut -d: -f1 \
| sort -u \
| xargs -rt apt-mark manual; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/*
RUN chown -R www-data:root /var/www; \
chmod -R g=u /var/www
VOLUME /var/www/html
RUN a2enmod rewrite remoteip ;\
{\
echo RemoteIPHeader X-Real-IP ;\
echo RemoteIPTrustedProxy 10.0.0.0/8 ;\
echo RemoteIPTrustedProxy 172.16.0.0/12 ;\
echo RemoteIPTrustedProxy 192.168.0.0/16 ;\
} > /etc/apache2/conf-available/remoteip.conf;\
a2enconf remoteip
ENV FRIENDICA_VERSION develop
ENV ADDONS_VERSION develop
COPY bin/* /usr/local/bin/
COPY config/* /usr/src/config/
COPY *.sh /
RUN chmod +x /*.sh
RUN chmod +x /usr/local/bin/*
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]

View file

@ -0,0 +1,152 @@
#!/bin/sh
set -eu
FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop}
FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop}
AUTOINSTALL=${AUTOINSTALL:-false}
SOURCEDIR=/usr/src
WORKDIR=/var/www/html
# run an command with the www-data user
run_as() {
if [ "$(id -u)" = 0 ]; then
su - www-data -s /bin/sh -c "$1"
else
sh -c "$1"
fi
}
# checks if the the first parameter is greater than the second parameter
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 | head -n 1)" != "$1" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
dir="${1:-$SOURCEDIR}"
friendica="${2:-$FRIENDICA_VERSION}"
addons="${3:-$FRIENDICA_ADDONS}"
echo "Cloning Friendica '${friendica}' with Addons '${addons}' into '${dir}'"
git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica
chmod 777 ${dir}/friendica/view/smarty3
mkdir ${dir}/friendica/addon
git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon
}
# help of this shell script
friendica_help() {
echo "Usage: friendica <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 1
}
# executes the Friendica console
console() {
cd ${WORKDIR}
php "${WORKDIR}/bin/console.php" "$@"
}
# executes the composer.phar binary of Friendica
composer() {
if [ -f ${WORKDIR}/bin/composer.phar ]; then
run_as "cd ${WORKDIR};${WORKDIR}/bin/composer.phar "$@" -d ${WORKDIR}"
fi
}
copy_sources() {
installed_version="0.0.0.0"
if [ -f ${WORKDIR}/VERSION ]; then
installed_version="$(cat ${WORKDIR}/VERSION)"
fi
image_version="0.0.0.0"
if [ -f ${SOURCEDIR}/friendica/VERSION ]; then
image_version="$(cat ${SOURCEDIR}/friendica/VERSION)"
elif [ "$FRIENDICA_VERSION" = "develop" ]; then
clone_develop
image_version="$(cat ${SOURCEDIR}/friendica/VERSION)"
else
# no given installation and not using the developer branch => nothing to do
echo "Friendica command '$1' failed, because of no valid combination of source and version"
return;
fi
if version_greater "$installed_version" "$image_version"; then
echo "Can't copy Friendica sources because the version of the data ($installed_version) is higher than the docker image ($image_version)"
exit 1;
fi
if version_greater "$image_version" "$installed_version"; then
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root"
else
rsync_options="-rlD"
fi
echo "Copying Friendica sources ($image_version) from '${SOURCEDIR}/friendica' to '${WORKDIR}'"
rsync $rsync_options --delete --exclude='.git/' ${SOURCEDIR}/friendica/ ${WORKDIR}/
fi
}
# install Friendica
install() {
if [ -f ${WORKDIR}/VERSION ]; then
# If there is a given installation of Friendica and we should not update it => exit
# We have to explicit update Friendica to avoid breaking something
return
fi
copy_sources
echo "Installing Friendica"
if [ "$FRIENDICA_VERSION" = "develop" ]; then
composer "install"
fi
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
"$AUTOINSTALL" == "true"; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/html/.htconfig.php"
# TODO Pull Request for dba Change
run_as "sed -i 's/\s+\sDNS_CNAME//g' ${WORKDIR}/include/dba.php"
console "autoinstall -f .htconfig.php"
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
}
update() {
if [ ! -f ${WORKDIR}/VERSION ]; then
# We want to update a given installation
# if there is no installation, exit
return
fi
copy_sources
echo "Upgrading Friendica"
if [ "$FRIENDICA_VERSION" = "develop" ]; then
composer "update"
fi
console "dbstructure update"
}
if [ $# -eq 0 ]; then
friendica_help
fi
case "$1" in
install) shift; install "$@";;
update) shift; update "$@" ;;
console) shift; console "$@" ;;
composer) shift; composer "$@" ;;
*) friendica_help ;;
esac

View file

@ -0,0 +1,104 @@
<?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_PASSWORD'))
&& !empty(getenv('MYSQL_DATABASE'))) {
$db_host = getenv('MYSQL_HOST') . ':' . getenv('MYSQL_PORT');
$db_user = getenv('MYSQL_USERNAME');
$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;

4
develop/apache/cron.sh Normal file
View file

@ -0,0 +1,4 @@
#!/bin/sh
set -eu
exec busybox crond -f -l 0 -L /dev/stdout

View file

@ -0,0 +1,7 @@
#!/bin/sh
set -eu
# Check if Friendica needs to get installed
friendica install
exec "$@"