diff --git a/stable/apache/bin/friendica b/.bin/friendica similarity index 88% rename from stable/apache/bin/friendica rename to .bin/friendica index 175ed05..0dd718c 100644 --- a/stable/apache/bin/friendica +++ b/.bin/friendica @@ -64,14 +64,24 @@ clone_develop() { friendica="${2:-$FRIENDICA_VERSION}" addons="${3:-$FRIENDICA_ADDONS}" - log 'Cloning Friendica '\'$friendica\'' with Addons '\'$addons\'' into '\'$dir\' + 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 -b ${friendica} https://github.com/friendica/friendica ${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 -b ${addons} https://github.com/friendica/friendica-addons ${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 @@ -106,7 +116,7 @@ copy_sources() { installed_version="$(cat ${WORKDIR}/VERSION)" fi - if [ "$FRIENDICA_VERSION" = "develop" ]; then + if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then clone_develop fi @@ -132,7 +142,7 @@ copy_sources() { fi log 'Copying Friendica sources ('$image_version') from '\'$SOURCEDIR'/friendica'\'' to '\'$WORKDIR\' - rsync $rsync_options --delete --exclude='.git' $SOURCEDIR/friendica/ $WORKDIR/ + rsync $rsync_options --delete --exclude=.git --exclude=photo --exclude=proxy $SOURCEDIR/friendica/ $WORKDIR/ if [ -f $WORKDIR/view/smarty3 ]; then chmod 777 $WORKDIR/view/smarty3 diff --git a/develop/apache/config/htconfig.php b/.config/htconfig.php similarity index 100% rename from develop/apache/config/htconfig.php rename to .config/htconfig.php diff --git a/.examples/dockerfiles/cron/apache/Dockerfile b/.examples/dockerfiles/cron/apache/Dockerfile index bf73178..b4f1898 100644 --- a/.examples/dockerfiles/cron/apache/Dockerfile +++ b/.examples/dockerfiles/cron/apache/Dockerfile @@ -1,10 +1,7 @@ FROM friendica/server:apache -ENV AUTOINSTALL true -ENV MARIADB_VERSION 10.3 - RUN set -ex; \ - ; \ + \ apt-get update; \ apt-get install -y --no-install-recommends \ supervisor \ diff --git a/.examples/dockerfiles/cron/fpm/Dockerfile b/.examples/dockerfiles/cron/fpm/Dockerfile index 86502ed..0113fda 100644 --- a/.examples/dockerfiles/cron/fpm/Dockerfile +++ b/.examples/dockerfiles/cron/fpm/Dockerfile @@ -1,10 +1,7 @@ FROM friendica/server:fpm -ENV AUTOINSTALL true -ENV MARIADB_VERSION 10.3 - RUN set -ex; \ - ; \ + \ apt-get update; \ apt-get install -y --no-install-recommends \ supervisor \ diff --git a/.travis.yml b/.travis.yml index 7098d72..13db9b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,67 @@ -language: bash +dist: trusty +sudo: required + services: docker -env: - - VARIANT=stable/apache - - VARIANT=stable/fpm - - VARIANT=stable/fpm-alpine - - VARIANT=develop/apache - - VARIANT=develop/fpm - - VARIANT=develop/fpm-alpine +language: bash + +stages: + - test scripts +# small tests for PRs + - name: test images (amd64) + if: branch != master +# full test for master + - name: test images (full) + if: branch = master install: - git clone https://github.com/docker-library/official-images.git ~/official-images before_script: - env | sort - - cd "$VARIANT" - - slash='/'; image="friendica/server:${VARIANT//$slash/-}" + - image="friendica/server:${VERSION}${VARIANT:+-$VARIANT}" + - if [[ "$ARCH" == 'i386' ]]; then sed -i -e 's/FROM php/FROM i386\/php/g' "${VERSION}/${VARIANT}/Dockerfile"; fi script: - - docker build -t "$image" . + - travis_retry docker build -t "$image" "${VERSION}/${VARIANT}" - ~/official-images/test/run.sh "$image" + - .travis/test-example-dockerfiles.sh "$image" after_script: - - docker images \ No newline at end of file + - docker images + +jobs: + include: + - &test-scripts + stage: test scripts + env: SCRIPT=update.sh + sudo: false + services: [] + install: skip + before_script: skip + script: + - hash_before=$(git write-tree) + - ./update.sh + - bash -c "[[ $hash_before = $(git add -A && git write-tree) ]]" + after_script: skip + + - <<: *test-scripts + env: SCRIPT=generate-stackbrew-library.sh + install: + - wget -O "$HOME/bin/bashbrew" https://doi-janky.infosiftr.net/job/bashbrew/lastSuccessfulBuild/artifact/bin/bashbrew-amd64 + - chmod +x "$HOME/bin/bashbrew" + script: + - ./generate-stackbrew-library.sh + + - stage: test images (amd64) + env: VERSION=2018.05-rc VARIANT=fpm-alpine ARCH=amd64 + - env: VERSION=2018.05-rc VARIANT=fpm ARCH=amd64 + - env: VERSION=2018.05-rc VARIANT=apache ARCH=amd64 + + - stage: test images (full) + env: VERSION=2018.05-rc VARIANT=fpm-alpine ARCH=amd64 + - env: VERSION=2018.05-rc VARIANT=fpm-alpine ARCH=i386 + - env: VERSION=2018.05-rc VARIANT=fpm ARCH=amd64 + - env: VERSION=2018.05-rc VARIANT=fpm ARCH=i386 + - env: VERSION=2018.05-rc VARIANT=apache ARCH=amd64 + - env: VERSION=2018.05-rc VARIANT=apache ARCH=i386 diff --git a/.travis/test-example-dockerfiles.sh b/.travis/test-example-dockerfiles.sh new file mode 100755 index 0000000..eb11eca --- /dev/null +++ b/.travis/test-example-dockerfiles.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -e + +image="$1" + +cd .examples/dockerfiles + +dirs=( */ ) +dirs=( "${dirs[@]%/}" ) +for dir in "${dirs[@]}"; do + if [ -d "$dir/$VARIANT" ]; then + ( + cd "$dir/$VARIANT" + sed -ri -e 's|^FROM .*|FROM '"$image"'|g' 'Dockerfile' + docker build -t "$image-$dir" . + ~/official-images/test/run.sh "$image-$dir" + ) + fi +done \ No newline at end of file diff --git a/develop/apache/Dockerfile b/2018.05-rc/apache/Dockerfile similarity index 86% rename from develop/apache/Dockerfile rename to 2018.05-rc/apache/Dockerfile index e76f2db..a3bb6ee 100644 --- a/develop/apache/Dockerfile +++ b/2018.05-rc/apache/Dockerfile @@ -1,9 +1,7 @@ +# DO NOT EDIT: created by update.sh from Dockerfile-debian.template FROM php:7.1-apache LABEL maintainer="Philipp Holzer " -ENV IMAGICK_PECL 3.4.3 -ENV AUTOINSTALL false - # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ @@ -33,8 +31,7 @@ RUN set -ex; \ make \ openssl \ libssl-dev \ - libpng12-0 \ - libpng12-dev \ + libpng-dev \ libjpeg62-turbo-dev \ libtool \ libmcrypt4 \ @@ -50,7 +47,7 @@ RUN set -ex; \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ - pecl install imagick-${IMAGICK_PECL}; \ + pecl install imagick-3.4.3; \ docker-php-ext-enable imagick; \ pecl clear-cache \ ; \ @@ -84,10 +81,10 @@ 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 ;\ + 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 @@ -95,8 +92,11 @@ RUN {\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ } > /usr/local/etc/php/conf.d/sendmail.ini; -ENV FRIENDICA_VERSION develop -ENV ADDONS_VERSION develop +ENV AUTOINSTALL false + +ENV FRIENDICA_VERSION 2018.05-rc +ENV ADDONS_VERSION 2018.05-rc + COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ @@ -105,4 +105,4 @@ RUN chmod +x /*.sh RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] -CMD ["apache2-foreground"] \ No newline at end of file +CMD ["apache2-foreground"] diff --git a/develop/apache/bin/friendica b/2018.05-rc/apache/bin/friendica similarity index 88% rename from develop/apache/bin/friendica rename to 2018.05-rc/apache/bin/friendica index 175ed05..0dd718c 100644 --- a/develop/apache/bin/friendica +++ b/2018.05-rc/apache/bin/friendica @@ -64,14 +64,24 @@ clone_develop() { friendica="${2:-$FRIENDICA_VERSION}" addons="${3:-$FRIENDICA_ADDONS}" - log 'Cloning Friendica '\'$friendica\'' with Addons '\'$addons\'' into '\'$dir\' + 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 -b ${friendica} https://github.com/friendica/friendica ${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 -b ${addons} https://github.com/friendica/friendica-addons ${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 @@ -106,7 +116,7 @@ copy_sources() { installed_version="$(cat ${WORKDIR}/VERSION)" fi - if [ "$FRIENDICA_VERSION" = "develop" ]; then + if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then clone_develop fi @@ -132,7 +142,7 @@ copy_sources() { fi log 'Copying Friendica sources ('$image_version') from '\'$SOURCEDIR'/friendica'\'' to '\'$WORKDIR\' - rsync $rsync_options --delete --exclude='.git' $SOURCEDIR/friendica/ $WORKDIR/ + rsync $rsync_options --delete --exclude=.git --exclude=photo --exclude=proxy $SOURCEDIR/friendica/ $WORKDIR/ if [ -f $WORKDIR/view/smarty3 ]; then chmod 777 $WORKDIR/view/smarty3 diff --git a/develop/fpm-alpine/config/htconfig.php b/2018.05-rc/apache/config/htconfig.php similarity index 100% rename from develop/fpm-alpine/config/htconfig.php rename to 2018.05-rc/apache/config/htconfig.php diff --git a/develop/apache/cron.sh b/2018.05-rc/apache/cron.sh similarity index 100% rename from develop/apache/cron.sh rename to 2018.05-rc/apache/cron.sh diff --git a/develop/apache/entrypoint.sh b/2018.05-rc/apache/entrypoint.sh similarity index 100% rename from develop/apache/entrypoint.sh rename to 2018.05-rc/apache/entrypoint.sh diff --git a/develop/fpm-alpine/Dockerfile b/2018.05-rc/fpm-alpine/Dockerfile similarity index 90% rename from develop/fpm-alpine/Dockerfile rename to 2018.05-rc/fpm-alpine/Dockerfile index 663a77a..c474a8f 100644 --- a/develop/fpm-alpine/Dockerfile +++ b/2018.05-rc/fpm-alpine/Dockerfile @@ -1,9 +1,7 @@ +# DO NOT EDIT: created by update.sh from Dockerfile-alpine.template FROM php:7.1-fpm-alpine LABEL maintainer="Philipp Holzer " -ENV IMAGICK_PECL 3.4.3 -ENV AUTOINSTALL false - # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ @@ -42,8 +40,9 @@ RUN set -ex; \ curl-dev \ rsync \ bzip2 \ + pcre-dev \ ; \ - pecl install imagick-${IMAGICK_PECL}; \ + pecl install imagick-3.4.3; \ docker-php-ext-enable imagick; \ pecl clear-cache; \ docker-php-ext-configure gd \ @@ -69,12 +68,16 @@ RUN chown -R www-data:root /var/www; \ VOLUME /var/www/html + RUN {\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ } > /usr/local/etc/php/conf.d/sendmail.ini; -ENV FRIENDICA_VERSION develop -ENV ADDONS_VERSION develop +ENV AUTOINSTALL false + +ENV FRIENDICA_VERSION 2018.05-rc +ENV ADDONS_VERSION 2018.05-rc + COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ diff --git a/develop/fpm/bin/friendica b/2018.05-rc/fpm-alpine/bin/friendica similarity index 88% rename from develop/fpm/bin/friendica rename to 2018.05-rc/fpm-alpine/bin/friendica index 175ed05..0dd718c 100644 --- a/develop/fpm/bin/friendica +++ b/2018.05-rc/fpm-alpine/bin/friendica @@ -64,14 +64,24 @@ clone_develop() { friendica="${2:-$FRIENDICA_VERSION}" addons="${3:-$FRIENDICA_ADDONS}" - log 'Cloning Friendica '\'$friendica\'' with Addons '\'$addons\'' into '\'$dir\' + 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 -b ${friendica} https://github.com/friendica/friendica ${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 -b ${addons} https://github.com/friendica/friendica-addons ${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 @@ -106,7 +116,7 @@ copy_sources() { installed_version="$(cat ${WORKDIR}/VERSION)" fi - if [ "$FRIENDICA_VERSION" = "develop" ]; then + if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then clone_develop fi @@ -132,7 +142,7 @@ copy_sources() { fi log 'Copying Friendica sources ('$image_version') from '\'$SOURCEDIR'/friendica'\'' to '\'$WORKDIR\' - rsync $rsync_options --delete --exclude='.git' $SOURCEDIR/friendica/ $WORKDIR/ + rsync $rsync_options --delete --exclude=.git --exclude=photo --exclude=proxy $SOURCEDIR/friendica/ $WORKDIR/ if [ -f $WORKDIR/view/smarty3 ]; then chmod 777 $WORKDIR/view/smarty3 diff --git a/develop/fpm/config/htconfig.php b/2018.05-rc/fpm-alpine/config/htconfig.php similarity index 100% rename from develop/fpm/config/htconfig.php rename to 2018.05-rc/fpm-alpine/config/htconfig.php diff --git a/develop/fpm-alpine/cron.sh b/2018.05-rc/fpm-alpine/cron.sh similarity index 100% rename from develop/fpm-alpine/cron.sh rename to 2018.05-rc/fpm-alpine/cron.sh diff --git a/develop/fpm-alpine/entrypoint.sh b/2018.05-rc/fpm-alpine/entrypoint.sh similarity index 100% rename from develop/fpm-alpine/entrypoint.sh rename to 2018.05-rc/fpm-alpine/entrypoint.sh diff --git a/develop/fpm/Dockerfile b/2018.05-rc/fpm/Dockerfile similarity index 92% rename from develop/fpm/Dockerfile rename to 2018.05-rc/fpm/Dockerfile index a87031e..69b38d2 100644 --- a/develop/fpm/Dockerfile +++ b/2018.05-rc/fpm/Dockerfile @@ -1,9 +1,7 @@ +# DO NOT EDIT: created by update.sh from Dockerfile-debian.template FROM php:7.1-fpm LABEL maintainer="Philipp Holzer " -ENV IMAGICK_PECL 3.4.3 -ENV AUTOINSTALL false - # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ @@ -33,8 +31,7 @@ RUN set -ex; \ make \ openssl \ libssl-dev \ - libpng12-0 \ - libpng12-dev \ + libpng-dev \ libjpeg62-turbo-dev \ libtool \ libmcrypt4 \ @@ -50,7 +47,7 @@ RUN set -ex; \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ - pecl install imagick-${IMAGICK_PECL}; \ + pecl install imagick-3.4.3; \ docker-php-ext-enable imagick; \ pecl clear-cache \ ; \ @@ -82,12 +79,16 @@ RUN chown -R www-data:root /var/www; \ VOLUME /var/www/html + RUN {\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ } > /usr/local/etc/php/conf.d/sendmail.ini; -ENV FRIENDICA_VERSION develop -ENV ADDONS_VERSION develop +ENV AUTOINSTALL false + +ENV FRIENDICA_VERSION 2018.05-rc +ENV ADDONS_VERSION 2018.05-rc + COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ @@ -96,4 +97,4 @@ RUN chmod +x /*.sh RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] -CMD ["php-fpm"] \ No newline at end of file +CMD ["php-fpm"] diff --git a/develop/fpm-alpine/bin/friendica b/2018.05-rc/fpm/bin/friendica similarity index 88% rename from develop/fpm-alpine/bin/friendica rename to 2018.05-rc/fpm/bin/friendica index 175ed05..0dd718c 100644 --- a/develop/fpm-alpine/bin/friendica +++ b/2018.05-rc/fpm/bin/friendica @@ -64,14 +64,24 @@ clone_develop() { friendica="${2:-$FRIENDICA_VERSION}" addons="${3:-$FRIENDICA_ADDONS}" - log 'Cloning Friendica '\'$friendica\'' with Addons '\'$addons\'' into '\'$dir\' + 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 -b ${friendica} https://github.com/friendica/friendica ${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 -b ${addons} https://github.com/friendica/friendica-addons ${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 @@ -106,7 +116,7 @@ copy_sources() { installed_version="$(cat ${WORKDIR}/VERSION)" fi - if [ "$FRIENDICA_VERSION" = "develop" ]; then + if echo "$FRIENDICA_VERSION" | grep -Eq '^.*(\-dev|-rc)'; then clone_develop fi @@ -132,7 +142,7 @@ copy_sources() { fi log 'Copying Friendica sources ('$image_version') from '\'$SOURCEDIR'/friendica'\'' to '\'$WORKDIR\' - rsync $rsync_options --delete --exclude='.git' $SOURCEDIR/friendica/ $WORKDIR/ + rsync $rsync_options --delete --exclude=.git --exclude=photo --exclude=proxy $SOURCEDIR/friendica/ $WORKDIR/ if [ -f $WORKDIR/view/smarty3 ]; then chmod 777 $WORKDIR/view/smarty3 diff --git a/stable/apache/config/htconfig.php b/2018.05-rc/fpm/config/htconfig.php similarity index 100% rename from stable/apache/config/htconfig.php rename to 2018.05-rc/fpm/config/htconfig.php diff --git a/develop/fpm/cron.sh b/2018.05-rc/fpm/cron.sh similarity index 100% rename from develop/fpm/cron.sh rename to 2018.05-rc/fpm/cron.sh diff --git a/develop/fpm/entrypoint.sh b/2018.05-rc/fpm/entrypoint.sh similarity index 100% rename from develop/fpm/entrypoint.sh rename to 2018.05-rc/fpm/entrypoint.sh diff --git a/stable/fpm-alpine/Dockerfile b/Dockerfile-alpine.template similarity index 70% rename from stable/fpm-alpine/Dockerfile rename to Dockerfile-alpine.template index b1dea2c..dce71b5 100644 --- a/stable/fpm-alpine/Dockerfile +++ b/Dockerfile-alpine.template @@ -1,9 +1,6 @@ -FROM php:7.1-fpm-alpine +FROM php:%%PHP_VERSION%%-%%VARIANT%% LABEL maintainer="Philipp Holzer " -ENV IMAGICK_PECL 3.4.3 -ENV AUTOINSTALL false - # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ @@ -42,8 +39,9 @@ RUN set -ex; \ curl-dev \ rsync \ bzip2 \ + pcre-dev \ ; \ - pecl install imagick-${IMAGICK_PECL}; \ + pecl install imagick-%%IMAGICK_VERSION%%; \ docker-php-ext-enable imagick; \ pecl clear-cache; \ docker-php-ext-configure gd \ @@ -68,26 +66,17 @@ RUN chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html +%%VARIANT_EXTRAS%% RUN {\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ } > /usr/local/etc/php/conf.d/sendmail.ini; -ENV FRIENDICA_VERSION 3.6 -ENV ADDONS_VERSION 3.6 +ENV AUTOINSTALL false -RUN set -ex; \ - curl -fsSL -o friendica.tar.gz \ - "https://github.com/friendica/friendica/releases/download/${FRIENDICA_VERSION}/friendica-full-${FRIENDICA_VERSION}.tar.gz"; \ - tar -xzf friendica.tar.gz -C /usr/src/; \ - rm friendica.tar.gz; \ - mv -f /usr/src/friendica-${FRIENDICA_VERSION}/ /usr/src/friendica; \ - chmod 777 /usr/src/friendica/view/smarty3; \ - curl -fsSL -o friendica_addons.tar.gz \ - "https://github.com/friendica/friendica-addons/archive/${ADDONS_VERSION}.tar.gz"; \ - mkdir /usr/src/friendica/addon; \ - tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ - rm friendica_addons.tar.gz; +ENV FRIENDICA_VERSION %%VERSION%% +ENV ADDONS_VERSION %%VERSION%% +%%INSTALL_EXTRAS%% COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ @@ -96,4 +85,4 @@ RUN chmod +x /*.sh RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] -CMD ["php-fpm"] \ No newline at end of file +CMD ["%%CMD%%"] \ No newline at end of file diff --git a/stable/fpm/Dockerfile b/Dockerfile-debian.template similarity index 73% rename from stable/fpm/Dockerfile rename to Dockerfile-debian.template index 1926273..5532def 100644 --- a/stable/fpm/Dockerfile +++ b/Dockerfile-debian.template @@ -1,9 +1,6 @@ -FROM php:7.1-fpm +FROM php:%%PHP_VERSION%%-%%VARIANT%% LABEL maintainer="Philipp Holzer " -ENV IMAGICK_PECL 3.4.3 -ENV AUTOINSTALL false - # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ @@ -33,8 +30,7 @@ RUN set -ex; \ make \ openssl \ libssl-dev \ - libpng12-0 \ - libpng12-dev \ + libpng-dev \ libjpeg62-turbo-dev \ libtool \ libmcrypt4 \ @@ -50,7 +46,7 @@ RUN set -ex; \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ - pecl install imagick-${IMAGICK_PECL}; \ + pecl install imagick-%%IMAGICK_VERSION%%; \ docker-php-ext-enable imagick; \ pecl clear-cache \ ; \ @@ -81,26 +77,17 @@ RUN chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html +%%VARIANT_EXTRAS%% RUN {\ echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ } > /usr/local/etc/php/conf.d/sendmail.ini; -ENV FRIENDICA_VERSION 3.6 -ENV ADDONS_VERSION 3.6 +ENV AUTOINSTALL false -RUN set -ex; \ - curl -fsSL -o friendica.tar.gz \ - "https://github.com/friendica/friendica/releases/download/${FRIENDICA_VERSION}/friendica-full-${FRIENDICA_VERSION}.tar.gz"; \ - tar -xzf friendica.tar.gz -C /usr/src/; \ - rm friendica.tar.gz; \ - mv -f /usr/src/friendica-${FRIENDICA_VERSION}/ /usr/src/friendica; \ - chmod 777 /usr/src/friendica/view/smarty3; \ - curl -fsSL -o friendica_addons.tar.gz \ - "https://github.com/friendica/friendica-addons/archive/${ADDONS_VERSION}.tar.gz"; \ - mkdir /usr/src/friendica/addon; \ - tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ - rm friendica_addons.tar.gz; +ENV FRIENDICA_VERSION %%VERSION%% +ENV ADDONS_VERSION %%VERSION%% +%%INSTALL_EXTRAS%% COPY bin/* /usr/local/bin/ COPY config/* /usr/src/config/ @@ -109,4 +96,4 @@ RUN chmod +x /*.sh RUN chmod +x /usr/local/bin/* ENTRYPOINT ["/entrypoint.sh"] -CMD ["php-fpm"] +CMD ["%%CMD%%"] diff --git a/stable/apache/cron.sh b/docker-cron.sh similarity index 73% rename from stable/apache/cron.sh rename to docker-cron.sh index 432692c..6711175 100644 --- a/stable/apache/cron.sh +++ b/docker-cron.sh @@ -6,6 +6,6 @@ while [ ! -f /var/www/html/.htconfig.php ]; do done while true; do - php -f /var/www/html/scripts/worker.php + php -f /var/www/html/%%DIR%%/worker.php sleep 10m done \ No newline at end of file diff --git a/stable/apache/entrypoint.sh b/docker-entrypoint.sh similarity index 100% rename from stable/apache/entrypoint.sh rename to docker-entrypoint.sh diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh new file mode 100755 index 0000000..ca24b2a --- /dev/null +++ b/generate-stackbrew-library.sh @@ -0,0 +1,110 @@ +#!/bin/bash +set -Eeuo pipefail + +declare -A release_channel=( + [production]='2018.05-rc' + [stable]='2018.05-rc' + [latest]='2018.05-rc' +) + +self="$(basename "$BASH_SOURCE")" +cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" + +# Get the most recent commit which modified any of "$@". +fileCommit() { + git log -1 --format='format:%H' HEAD -- "$@" +} + +# Get the most recent commit which modified "$1/Dockerfile" or any file that +# the Dockerfile copies into the rootfs (with COPY). +dockerfileCommit() { + local dir="$1"; shift + ( + cd "$dir"; + fileCommit Dockerfile \ + $(awk ' + toupper($1) == "COPY" { + for (i = 2; i < NF; i++) + print $i; + } + ' Dockerfile) + ) +} + +getArches() { + local repo="$1"; shift + local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/' + + eval "declare -g -A parentRepoToArches=( $( + find -maxdepth 3 -name 'Dockerfile' -exec awk ' + toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ { + print "'"$officialImagesUrl"'" $2 + } + ' '{}' + \ + | sort -u \ + | xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"' + ) )" +} +getArches 'friendica' + +# Header. +cat <<-EOH +# This file is generated via https://github.com/friendica/docker/blob/$(fileCommit "$self")/$self +Maintainers: Friendica (@friendica), Philipp Holzer (@nupplaphil) +GitRepo: https://github.com/friendica/docker.git +EOH + +# prints "$2$1$3$1...$N" +join() { + local sep="$1"; shift + local out; printf -v out "${sep//%/%%}%s" "$@" + echo "${out#$sep}" +} + +# Generate each of the tags. +versions=( */ ) +versions=( "${versions[@]%/}" ) +for version in "${versions[@]}"; do + variants=( $version/*/ ) + variants=( $(for variant in "${variants[@]%/}"; do + echo "$(basename "$variant")" + done) ) + for variant in "${variants[@]}"; do + commit="$(dockerfileCommit "$version/$variant")" + + versionAliases=( ) + versionPostfix="" + + versionAliases+=( "$version$versionPostfix" ) + if [ "$version" == *-rc ]; then + versionAliases+=( "rc" ) + fi + if [ "$version" == *-dev ]; then + versionAliases+=( "dev" ) + fi + + for channel in "${!release_channel[@]}"; do + if [ "$version" = "${release_channel[$channel]}" ]; then + versionAliases+=( "$channel" ) + fi + done + + variantAliases=( "${versionAliases[@]/%/-$variant}" ) + variantAliases=( "${variantAliases[@]//latest-}" ) + + if [ "$variant" = "apache" ]; then + variantAliases+=( "${versionAliases[@]}" ) + fi + + variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/$variant/Dockerfile")" + variantArches="${parentRepoToArches[$variantParent]}" + + cat <<-EOE + + Tags: $(join ', ' "${variantAliases[@]}") + Architectures: $(join ', ' $variantArches) + GitCommit: $commit + Directory: $version/$variant + EOE + done +done \ No newline at end of file diff --git a/stable/apache/Dockerfile b/stable/apache/Dockerfile deleted file mode 100644 index fef62fb..0000000 --- a/stable/apache/Dockerfile +++ /dev/null @@ -1,121 +0,0 @@ -FROM php:7.1-apache -LABEL maintainer="Philipp Holzer " - -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 \ - git \ -# For mail() support - sendmail \ - ; \ - rm -rf /var/lib/apt/lists/*; - -# 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 - -RUN {\ - echo sendmail_path = "/usr/sbin/sendmail -t -i" ;\ - } > /usr/local/etc/php/conf.d/sendmail.ini; - -ENV FRIENDICA_VERSION 3.6 -ENV ADDONS_VERSION 3.6 - -RUN set -ex; \ - curl -fsSL -o friendica.tar.gz \ - "https://github.com/friendica/friendica/releases/download/${FRIENDICA_VERSION}/friendica-full-${FRIENDICA_VERSION}.tar.gz"; \ - tar -xzf friendica.tar.gz -C /usr/src/; \ - rm friendica.tar.gz; \ - mv -f /usr/src/friendica-${FRIENDICA_VERSION}/ /usr/src/friendica; \ - chmod 777 /usr/src/friendica/view/smarty3; \ - curl -fsSL -o friendica_addons.tar.gz \ - "https://github.com/friendica/friendica-addons/archive/${ADDONS_VERSION}.tar.gz"; \ - mkdir /usr/src/friendica/addon; \ - tar -xzf friendica_addons.tar.gz -C /usr/src/friendica/addon --strip-components=1; \ - rm friendica_addons.tar.gz; - -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"] diff --git a/stable/fpm-alpine/bin/friendica b/stable/fpm-alpine/bin/friendica deleted file mode 100644 index 175ed05..0000000 --- a/stable/fpm-alpine/bin/friendica +++ /dev/null @@ -1,212 +0,0 @@ -#!/bin/sh -set -eu - -FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} -FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} -AUTOINSTALL=${AUTOINSTALL:-false} - -SOURCEDIR=/usr/src -WORKDIR=/var/www/html - -# change delimiter for arrays from whitespaces to newlines (so we can pass strings with whitespaces) -#IFS=\r\n - -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)" = 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}" - - log 'Cloning Friendica '\'$friendica\'' with Addons '\'$addons\'' into '\'$dir\' - - # Removing the whole directory first - rm -fr $dir/friendica - - sh -c "git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica" - mkdir $dir/friendica/addon - sh -c "git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon" -} - -# help of this shell script -friendica_help() { - echo "Usage: friendica []" - echo "" - echo "Commands:" - echo " console Executes an command in the Friendica console" - echo " composer Executes the composer.phar executable for Friendica" - echo " install Installs Friendica" - echo " update Updates Friendica" - exit 0 -} - -# executes the Friendica console -console() { - cd $WORKDIR - # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - sh -c "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 - - if [ "$FRIENDICA_VERSION" = "develop" ]; 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"; then - if [ "$(id -u)" = 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' $SOURCEDIR/friendica/ $WORKDIR/ - - if [ -f $WORKDIR/view/smarty3 ]; then - chmod 777 $WORKDIR/view/smarty3 - 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 - - copy_sources - - log '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 - - log 'Upgrading Friendica' - if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "install" - fi - console "dbstructure update" -} - -sendmail() { - if [ ! -f /etc/init.d/sendmail ]; then - # If sendmail isn't installed, exit this method - return - fi - - line=$(head -n 1 /etc/hosts) - line2=$(echo $line | awk '{print $2}') - echo "$line $line2.localdomain" >> /etc/hosts - - log 'Starting sendmail for Mail-Support' - nohup /etc/init.d/sendmail start > /dev/null 2>&1 & -} - -if [ $# -eq 0 ]; then - friendica_help - exit 0 -fi - -case "$1" in - install) shift; install "$@";; - update) shift; update "$@" ;; - console) shift; console "$@" ;; - composer) shift; composer "$@" ;; - sendmail) shift; sendmail "$@" ;; - *) friendica_help ;; -esac diff --git a/stable/fpm-alpine/config/htconfig.php b/stable/fpm-alpine/config/htconfig.php deleted file mode 100644 index fb8180f..0000000 --- a/stable/fpm-alpine/config/htconfig.php +++ /dev/null @@ -1,104 +0,0 @@ -config['system']['db_charset'] = "utf8mb4"; - -// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". -// It can be changed later and only applies to timestamps for anonymous viewers. - -if (!empty(getenv('TZ'))) { - $default_timezone = getenv('TZ'); -} else { - $default_timezone = 'America/Los_Angeles'; -} - -// Default system language -if (!empty(getenv('LANGUAGE'))) { - $a->config['system']['language'] = getenv('LANGUAGE'); -} else { - $a->config['system']['language'] = 'en'; -} - -// What is your site name? -if (!empty(getenv('SITENAME'))) { - $a->config['sitename'] = getenv('SITENAME'); -} else { - $a->config['sitename'] = "Friendica Social Network"; -} - -// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED. -// Be certain to create your own personal account before setting -// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on -// the registration page. REGISTER_APPROVE requires you set 'admin_email' -// to the email address of an already registered person who can authorise -// and/or approve/deny the request. - -// In order to perform system administration via the admin panel, admin_email -// must precisely match the email address of the person logged in. - -$a->config['register_policy'] = REGISTER_OPEN; -$a->config['register_text'] = ''; -if (!empty(getenv('MAILNAME'))) { - $a->config['admin_email'] = getenv('MAILNAME'); -} else { - $a->config['admin_email'] = ''; -} - -// Maximum size of an imported message, 0 is unlimited - -$a->config['max_import_size'] = 200000; - -// maximum size of uploaded photos - -$a->config['system']['maximagesize'] = 800000; - -// Location of PHP command line processor - -$a->config['php_path'] = 'php'; - -// Server-to-server private message encryption (RINO) is allowed by default. -// set to 0 to disable, 1 to enable - -$a->config['system']['rino_encrypt'] = 1; - -// allowed themes (change this from admin panel after installation) - -$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero,smoothly'; - -// default system theme - -$a->config['system']['theme'] = 'vier'; - - -// By default allow pseudonyms - -$a->config['system']['no_regfullname'] = true; - -//Deny public access to the local directory -//$a->config['system']['block_local_dir'] = false; - -// Location of the global directory -$a->config['system']['directory'] = 'https://dir.friendica.social'; - -// Allowed protocols in link URLs; HTTP protocols always are accepted -$a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid', 'gopher']; - -// Authentication cookie lifetime, in days -$a->config['system']['auth_cookie_lifetime'] = 7; diff --git a/stable/fpm-alpine/cron.sh b/stable/fpm-alpine/cron.sh deleted file mode 100644 index 432692c..0000000 --- a/stable/fpm-alpine/cron.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -trap "break;exit" HUP INT TERM - -while [ ! -f /var/www/html/.htconfig.php ]; do - sleep 1 -done - -while true; do - php -f /var/www/html/scripts/worker.php - sleep 10m -done \ No newline at end of file diff --git a/stable/fpm-alpine/entrypoint.sh b/stable/fpm-alpine/entrypoint.sh deleted file mode 100644 index 4a0608c..0000000 --- a/stable/fpm-alpine/entrypoint.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -eu - -friendica install -q -friendica sendmail -q - -exec "$@" \ No newline at end of file diff --git a/stable/fpm/bin/friendica b/stable/fpm/bin/friendica deleted file mode 100644 index 175ed05..0000000 --- a/stable/fpm/bin/friendica +++ /dev/null @@ -1,212 +0,0 @@ -#!/bin/sh -set -eu - -FRIENDICA_VERSION=${FRIENDICA_VERSION:-develop} -FRIENDICA_ADDONS=${FRIENDICA_ADDONS:-develop} -AUTOINSTALL=${AUTOINSTALL:-false} - -SOURCEDIR=/usr/src -WORKDIR=/var/www/html - -# change delimiter for arrays from whitespaces to newlines (so we can pass strings with whitespaces) -#IFS=\r\n - -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)" = 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}" - - log 'Cloning Friendica '\'$friendica\'' with Addons '\'$addons\'' into '\'$dir\' - - # Removing the whole directory first - rm -fr $dir/friendica - - sh -c "git clone -b ${friendica} https://github.com/friendica/friendica ${dir}/friendica" - mkdir $dir/friendica/addon - sh -c "git clone -b ${addons} https://github.com/friendica/friendica-addons ${dir}/friendica/addon" -} - -# help of this shell script -friendica_help() { - echo "Usage: friendica []" - echo "" - echo "Commands:" - echo " console Executes an command in the Friendica console" - echo " composer Executes the composer.phar executable for Friendica" - echo " install Installs Friendica" - echo " update Updates Friendica" - exit 0 -} - -# executes the Friendica console -console() { - cd $WORKDIR - # Todo starting a php-executable without quoting the arguments seems not secure (but is the only way it works) - sh -c "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 - - if [ "$FRIENDICA_VERSION" = "develop" ]; 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"; then - if [ "$(id -u)" = 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' $SOURCEDIR/friendica/ $WORKDIR/ - - if [ -f $WORKDIR/view/smarty3 ]; then - chmod 777 $WORKDIR/view/smarty3 - 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 - - copy_sources - - log '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 - - log 'Upgrading Friendica' - if [ "$FRIENDICA_VERSION" = "develop" ]; then - composer "install" - fi - console "dbstructure update" -} - -sendmail() { - if [ ! -f /etc/init.d/sendmail ]; then - # If sendmail isn't installed, exit this method - return - fi - - line=$(head -n 1 /etc/hosts) - line2=$(echo $line | awk '{print $2}') - echo "$line $line2.localdomain" >> /etc/hosts - - log 'Starting sendmail for Mail-Support' - nohup /etc/init.d/sendmail start > /dev/null 2>&1 & -} - -if [ $# -eq 0 ]; then - friendica_help - exit 0 -fi - -case "$1" in - install) shift; install "$@";; - update) shift; update "$@" ;; - console) shift; console "$@" ;; - composer) shift; composer "$@" ;; - sendmail) shift; sendmail "$@" ;; - *) friendica_help ;; -esac diff --git a/stable/fpm/config/htconfig.php b/stable/fpm/config/htconfig.php deleted file mode 100644 index fb8180f..0000000 --- a/stable/fpm/config/htconfig.php +++ /dev/null @@ -1,104 +0,0 @@ -config['system']['db_charset'] = "utf8mb4"; - -// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". -// It can be changed later and only applies to timestamps for anonymous viewers. - -if (!empty(getenv('TZ'))) { - $default_timezone = getenv('TZ'); -} else { - $default_timezone = 'America/Los_Angeles'; -} - -// Default system language -if (!empty(getenv('LANGUAGE'))) { - $a->config['system']['language'] = getenv('LANGUAGE'); -} else { - $a->config['system']['language'] = 'en'; -} - -// What is your site name? -if (!empty(getenv('SITENAME'))) { - $a->config['sitename'] = getenv('SITENAME'); -} else { - $a->config['sitename'] = "Friendica Social Network"; -} - -// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED. -// Be certain to create your own personal account before setting -// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on -// the registration page. REGISTER_APPROVE requires you set 'admin_email' -// to the email address of an already registered person who can authorise -// and/or approve/deny the request. - -// In order to perform system administration via the admin panel, admin_email -// must precisely match the email address of the person logged in. - -$a->config['register_policy'] = REGISTER_OPEN; -$a->config['register_text'] = ''; -if (!empty(getenv('MAILNAME'))) { - $a->config['admin_email'] = getenv('MAILNAME'); -} else { - $a->config['admin_email'] = ''; -} - -// Maximum size of an imported message, 0 is unlimited - -$a->config['max_import_size'] = 200000; - -// maximum size of uploaded photos - -$a->config['system']['maximagesize'] = 800000; - -// Location of PHP command line processor - -$a->config['php_path'] = 'php'; - -// Server-to-server private message encryption (RINO) is allowed by default. -// set to 0 to disable, 1 to enable - -$a->config['system']['rino_encrypt'] = 1; - -// allowed themes (change this from admin panel after installation) - -$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero,smoothly'; - -// default system theme - -$a->config['system']['theme'] = 'vier'; - - -// By default allow pseudonyms - -$a->config['system']['no_regfullname'] = true; - -//Deny public access to the local directory -//$a->config['system']['block_local_dir'] = false; - -// Location of the global directory -$a->config['system']['directory'] = 'https://dir.friendica.social'; - -// Allowed protocols in link URLs; HTTP protocols always are accepted -$a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid', 'gopher']; - -// Authentication cookie lifetime, in days -$a->config['system']['auth_cookie_lifetime'] = 7; diff --git a/stable/fpm/cron.sh b/stable/fpm/cron.sh deleted file mode 100644 index 432692c..0000000 --- a/stable/fpm/cron.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -trap "break;exit" HUP INT TERM - -while [ ! -f /var/www/html/.htconfig.php ]; do - sleep 1 -done - -while true; do - php -f /var/www/html/scripts/worker.php - sleep 10m -done \ No newline at end of file diff --git a/stable/fpm/entrypoint.sh b/stable/fpm/entrypoint.sh deleted file mode 100644 index 4a0608c..0000000 --- a/stable/fpm/entrypoint.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -eu - -friendica install -q -friendica sendmail -q - -exec "$@" \ No newline at end of file diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..0910884 --- /dev/null +++ b/update.sh @@ -0,0 +1,123 @@ +#!/bin/bash +set -eo pipefail + +declare -A php_version=( + [default]='7.1' +) + +declare -A cmd=( + [apache]='apache2-foreground' + [fpm]='php-fpm' + [fpm-alpine]='php-fpm' +) + +declare -A base=( + [apache]='debian' + [fpm]='debian' + [fpm-alpine]='alpine' +) + +declare -A extras=( + [apache]='\nRUN a2enmod rewrite remoteip ;\\\n {\\\n echo RemoteIPHeader X-Real-IP ;\\\n echo RemoteIPTrustedProxy 10.0.0.0/8 ;\\\n echo RemoteIPTrustedProxy 172.16.0.0/12 ;\\\n echo RemoteIPTrustedProxy 192.168.0.0/16 ;\\\n } > /etc/apache2/conf-available/remoteip.conf;\\\n a2enconf remoteip' + [fpm]='' + [fpm-alpine]='' +) + +declare -A pecl_versions=( + [Imagick]='3.4.3' +) + +declare -A install_extras=( + ['stable']='\nRUN set -ex; \\\n curl -fsSL -o friendica.tar.gz \\\n "https://github.com/friendica/friendica/releases/download/${FRIENDICA_VERSION}/friendica-full-${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/${ADDONS_VERSION}.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;' + ['develop']='' +) + +declare -A bin_dir=( + ['stable']='scripts' + ['develop']='bin' +) + +variants=( + apache + fpm + fpm-alpine +) + +versions=( + 2018.05-rc +) + +travisEnv= +travisEnvAmd64= + +function create_variant() { + dir="$1/$variant" + + # Create the version+variant directory with a Dockerfile. + mkdir -p "$dir" + + template="Dockerfile-${base[$variant]}.template" + echo "# DO NOT EDIT: created by update.sh from $template" > "$dir/Dockerfile" + cat "$template" >> "$dir/Dockerfile" + + # Check which installation typ we need. If develop, the source will get downloaded by git. + install_type='stable' + if [[ "$1" == *-dev ]] || [[ "$1" == *-rc ]]; then + install_type='develop' + fi + + echo "updating $1 [$install_type] $variant" + + # Replace the variables. + sed -ri -e ' + s/%%PHP_VERSION%%/'"${php_version[$version]-${php_version[default]}}"'/g; + s/%%VARIANT%%/'"$variant"'/g; + s/%%VERSION%%/'"$1"'/g; + s/%%CMD%%/'"${cmd[$variant]}"'/g; + s|%%VARIANT_EXTRAS%%|'"${extras[$variant]}"'|g; + s|%%INSTALL_EXTRAS%%|'"${install_extras[$install_type]}"'|g; + s/%%IMAGICK_VERSION%%/'"${pecl_versions[Imagick]}"'/g; + ' "$dir/Dockerfile" + + # Copy the shell scripts + for name in entrypoint cron; do + cp "docker-$name.sh" "$dir/$name.sh" + done + + # Copy the config directory + cp -rT .config "$dir/config" + + # Copy the bin directory + cp -rT .bin "$dir/bin" + + sed -ri -e ' + s/%%DIR%%/'"${bin_dir[$install_type]}"'/g; + ' "$dir/cron.sh" + + travisEnvAmd64='\n - env: VERSION='"$1"' VARIANT='"$variant"' ARCH=amd64'"$travisEnvAmd64" + for arch in i386 amd64; do + travisEnv='\n - env: VERSION='"$1"' VARIANT='"$variant"' ARCH='"$arch$travisEnv" + done +} + +find . -maxdepth 1 -type d -regextype sed -regex '\./[[:digit:]]\+\(\.\|\-\)[[:digit:]]\+\(-rc\|-dev\)\?' -exec rm -r '{}' \; + +for version in "${versions[@]}"; do + + for variant in "${variants[@]}"; do + + create_variant "$version" + done +done + +# replace the fist '-' with ' ' +travisEnv="$(echo "$travisEnv" | sed '0,/-/{s/-/ /}')" +travisEnvAmd64="$(echo "$travisEnvAmd64" | sed '0,/-/{s/-/ /}')" + +# update .travis.yml +travisAmd64="$(awk -v 'RS=\n\n' '$1 == "-" && $2 == "stage:" && $3 == "test" && $4 == "images" && $5 == "(amd64)" { $0 = " - stage: test images (amd64)'"$travisEnvAmd64"'" } { printf "%s%s", $0, RS }' .travis.yml)" +echo "$travisAmd64" > .travis.yml + +travisFull="$(awk -v 'RS=\n\n' '$1 == "-" && $2 == "stage:" && $3 == "test" && $4 == "images" && $5 == "(full)" { $0 = " - stage: test images (full)'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)" + +echo "$travisFull" > .travis.yml \ No newline at end of file