Merge pull request #87 from nupplaphil/task/extract_dev_rc

Splitting dev/rc business logic from "stable" images
This commit is contained in:
Hypolite Petovan 2019-11-26 16:21:22 -05:00 committed by GitHub
commit dafddd4e22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 368 additions and 576 deletions

View File

@ -16,62 +16,6 @@ version_greater() {
[ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ]
}
# checks if the branch and repository exists
check_branch() {
repo=${1:-}
branch=${2:-}
git ls-remote --heads --tags "https://github.com/$repo" | grep -E "refs/(heads|tags)/${branch}$" >/dev/null
[ "$?" -eq "0" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
friendica_repo="${FRIENDICA_REPOSITORY:-friendica/friendica}"
friendica_addons_repo="${FRIENDICA_ADDONS_REPO:-friendica/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
# Check if the branches exist before wiping the
if check_branch "$friendica_repo" "$friendica_git" && check_branch "$friendica_addons_repo" "$addons_git" ; then
echo "Downloading Friendica from GitHub '${friendica_repo}/${friendica_git}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica
mkdir /usr/src/friendica/addon
git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon
echo "Download finished"
if [ ! -f /usr/src/friendica/VERSION ]; then
echo "Couldn't clone repository"
exit 1
fi
/usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica
return 0
else
if check_branch "$friendica_repo" "$friendica_git"; then
echo "$friendica_repo/$friendica_git is not valid."
else
echo "$friendica_addons_repo/$addons_git is not valid."
fi
echo "Using old version."
return 1
fi
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
@ -112,33 +56,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; 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|-RC)' || [ "${FRIENDICA_UPGRADE:-false}" = "true" ] || [ ! -f /usr/src/friendica/VERSION ]; then
# just clone & check if it's a new install or upgrade
clone_develop
if [ "$?" -eq "0" ]; then
image_version="$(cat /usr/src/friendica/VERSION)"
check=true
fi
else
image_version="$(cat /usr/src/friendica/VERSION)"
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
# 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
setup_ssmtp
if [ "$check" = true ]; then
# check it just in case the version is greater
if version_greater "$image_version" "$installed_version"; then
echo "Initializing Friendica $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then
@ -206,7 +135,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.config.php) to the config folder (currently only local.config.php and addon.config.php supported)
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi

View File

@ -16,62 +16,6 @@ version_greater() {
[ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ]
}
# checks if the branch and repository exists
check_branch() {
repo=${1:-}
branch=${2:-}
git ls-remote --heads --tags "https://github.com/$repo" | grep -E "refs/(heads|tags)/${branch}$" >/dev/null
[ "$?" -eq "0" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
friendica_repo="${FRIENDICA_REPOSITORY:-friendica/friendica}"
friendica_addons_repo="${FRIENDICA_ADDONS_REPO:-friendica/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
# Check if the branches exist before wiping the
if check_branch "$friendica_repo" "$friendica_git" && check_branch "$friendica_addons_repo" "$addons_git" ; then
echo "Downloading Friendica from GitHub '${friendica_repo}/${friendica_git}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica
mkdir /usr/src/friendica/addon
git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon
echo "Download finished"
if [ ! -f /usr/src/friendica/VERSION ]; then
echo "Couldn't clone repository"
exit 1
fi
/usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica
return 0
else
if check_branch "$friendica_repo" "$friendica_git"; then
echo "$friendica_repo/$friendica_git is not valid."
else
echo "$friendica_addons_repo/$addons_git is not valid."
fi
echo "Using old version."
return 1
fi
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
@ -112,33 +56,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; 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|-RC)' || [ "${FRIENDICA_UPGRADE:-false}" = "true" ] || [ ! -f /usr/src/friendica/VERSION ]; then
# just clone & check if it's a new install or upgrade
clone_develop
if [ "$?" -eq "0" ]; then
image_version="$(cat /usr/src/friendica/VERSION)"
check=true
fi
else
image_version="$(cat /usr/src/friendica/VERSION)"
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
# 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
setup_ssmtp
if [ "$check" = true ]; then
# check it just in case the version is greater
if version_greater "$image_version" "$installed_version"; then
echo "Initializing Friendica $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then
@ -206,7 +135,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.config.php) to the config folder (currently only local.config.php and addon.config.php supported)
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi

View File

@ -16,62 +16,6 @@ version_greater() {
[ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ]
}
# checks if the branch and repository exists
check_branch() {
repo=${1:-}
branch=${2:-}
git ls-remote --heads --tags "https://github.com/$repo" | grep -E "refs/(heads|tags)/${branch}$" >/dev/null
[ "$?" -eq "0" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
friendica_repo="${FRIENDICA_REPOSITORY:-friendica/friendica}"
friendica_addons_repo="${FRIENDICA_ADDONS_REPO:-friendica/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
# Check if the branches exist before wiping the
if check_branch "$friendica_repo" "$friendica_git" && check_branch "$friendica_addons_repo" "$addons_git" ; then
echo "Downloading Friendica from GitHub '${friendica_repo}/${friendica_git}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica
mkdir /usr/src/friendica/addon
git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon
echo "Download finished"
if [ ! -f /usr/src/friendica/VERSION ]; then
echo "Couldn't clone repository"
exit 1
fi
/usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica
return 0
else
if check_branch "$friendica_repo" "$friendica_git"; then
echo "$friendica_repo/$friendica_git is not valid."
else
echo "$friendica_addons_repo/$addons_git is not valid."
fi
echo "Using old version."
return 1
fi
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
@ -112,33 +56,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; 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|-RC)' || [ "${FRIENDICA_UPGRADE:-false}" = "true" ] || [ ! -f /usr/src/friendica/VERSION ]; then
# just clone & check if it's a new install or upgrade
clone_develop
if [ "$?" -eq "0" ]; then
image_version="$(cat /usr/src/friendica/VERSION)"
check=true
fi
else
image_version="$(cat /usr/src/friendica/VERSION)"
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
# 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
setup_ssmtp
if [ "$check" = true ]; then
# check it just in case the version is greater
if version_greater "$image_version" "$installed_version"; then
echo "Initializing Friendica $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then
@ -206,7 +135,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.config.php) to the config folder (currently only local.config.php and addon.config.php supported)
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi

View File

@ -127,5 +127,5 @@ ENV FRIENDICA_ADDONS 2019.12-dev
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/friendica/config/
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint-dev.sh"]
CMD ["apache2-foreground"]

View File

@ -0,0 +1,69 @@
#!/bin/sh
set -eu
# checks if the branch and repository exists
check_branch() {
repo=${1:-}
branch=${2:-}
git ls-remote --heads --tags "https://github.com/$repo" | grep -E "refs/(heads|tags)/${branch}$" >/dev/null
[ "$?" -eq "0" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
friendica_repo="${FRIENDICA_REPOSITORY:-friendica/friendica}"
friendica_addons_repo="${FRIENDICA_ADDONS_REPO:-friendica/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
# Check if the branches exist before wiping the
if check_branch "$friendica_repo" "$friendica_git" && check_branch "$friendica_addons_repo" "$addons_git" ; then
echo "Cloning '${friendica_git}' from GitHub repository '${friendica_repo}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica
mkdir /usr/src/friendica/addon
git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon
echo "Download finished"
if [ ! -f /usr/src/friendica/VERSION ]; then
echo "Couldn't clone repository"
exit 1
fi
/usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica
return 0
else
if check_branch "$friendica_repo" "$friendica_git"; then
echo "$friendica_repo/$friendica_git is not valid."
else
echo "$friendica_addons_repo/$addons_git is not valid."
fi
echo "Using old version."
return 1
fi
}
# just check if we execute apache or php-fpm
if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
# cloning from git is just possible for develop or Release Candidats
if echo "${FRIENDICA_VERSION}" | grep -Eq '^.*(\-dev|-rc|-RC)' || [ "${FRIENDICA_UPGRADE:-false}" = "true" ] || [ ! -f /usr/src/friendica/VERSION ]; then
# just clone & check if it's a new install or upgrade
clone_develop
fi
fi
/entrypoint.sh "$@"

View File

@ -16,62 +16,6 @@ version_greater() {
[ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ]
}
# checks if the branch and repository exists
check_branch() {
repo=${1:-}
branch=${2:-}
git ls-remote --heads --tags "https://github.com/$repo" | grep -E "refs/(heads|tags)/${branch}$" >/dev/null
[ "$?" -eq "0" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
friendica_repo="${FRIENDICA_REPOSITORY:-friendica/friendica}"
friendica_addons_repo="${FRIENDICA_ADDONS_REPO:-friendica/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
# Check if the branches exist before wiping the
if check_branch "$friendica_repo" "$friendica_git" && check_branch "$friendica_addons_repo" "$addons_git" ; then
echo "Downloading Friendica from GitHub '${friendica_repo}/${friendica_git}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica
mkdir /usr/src/friendica/addon
git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon
echo "Download finished"
if [ ! -f /usr/src/friendica/VERSION ]; then
echo "Couldn't clone repository"
exit 1
fi
/usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica
return 0
else
if check_branch "$friendica_repo" "$friendica_git"; then
echo "$friendica_repo/$friendica_git is not valid."
else
echo "$friendica_addons_repo/$addons_git is not valid."
fi
echo "Using old version."
return 1
fi
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
@ -112,33 +56,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; 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|-RC)' || [ "${FRIENDICA_UPGRADE:-false}" = "true" ] || [ ! -f /usr/src/friendica/VERSION ]; then
# just clone & check if it's a new install or upgrade
clone_develop
if [ "$?" -eq "0" ]; then
image_version="$(cat /usr/src/friendica/VERSION)"
check=true
fi
else
image_version="$(cat /usr/src/friendica/VERSION)"
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
# 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
setup_ssmtp
if [ "$check" = true ]; then
# check it just in case the version is greater
if version_greater "$image_version" "$installed_version"; then
echo "Initializing Friendica $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then
@ -206,7 +135,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.config.php) to the config folder (currently only local.config.php and addon.config.php supported)
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi

View File

@ -103,5 +103,5 @@ ENV FRIENDICA_ADDONS 2019.12-dev
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/friendica/config/
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint-dev.sh"]
CMD ["php-fpm"]

View File

@ -0,0 +1,69 @@
#!/bin/sh
set -eu
# checks if the branch and repository exists
check_branch() {
repo=${1:-}
branch=${2:-}
git ls-remote --heads --tags "https://github.com/$repo" | grep -E "refs/(heads|tags)/${branch}$" >/dev/null
[ "$?" -eq "0" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
friendica_repo="${FRIENDICA_REPOSITORY:-friendica/friendica}"
friendica_addons_repo="${FRIENDICA_ADDONS_REPO:-friendica/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
# Check if the branches exist before wiping the
if check_branch "$friendica_repo" "$friendica_git" && check_branch "$friendica_addons_repo" "$addons_git" ; then
echo "Cloning '${friendica_git}' from GitHub repository '${friendica_repo}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica
mkdir /usr/src/friendica/addon
git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon
echo "Download finished"
if [ ! -f /usr/src/friendica/VERSION ]; then
echo "Couldn't clone repository"
exit 1
fi
/usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica
return 0
else
if check_branch "$friendica_repo" "$friendica_git"; then
echo "$friendica_repo/$friendica_git is not valid."
else
echo "$friendica_addons_repo/$addons_git is not valid."
fi
echo "Using old version."
return 1
fi
}
# just check if we execute apache or php-fpm
if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
# cloning from git is just possible for develop or Release Candidats
if echo "${FRIENDICA_VERSION}" | grep -Eq '^.*(\-dev|-rc|-RC)' || [ "${FRIENDICA_UPGRADE:-false}" = "true" ] || [ ! -f /usr/src/friendica/VERSION ]; then
# just clone & check if it's a new install or upgrade
clone_develop
fi
fi
/entrypoint.sh "$@"

View File

@ -16,62 +16,6 @@ version_greater() {
[ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ]
}
# checks if the branch and repository exists
check_branch() {
repo=${1:-}
branch=${2:-}
git ls-remote --heads --tags "https://github.com/$repo" | grep -E "refs/(heads|tags)/${branch}$" >/dev/null
[ "$?" -eq "0" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
friendica_repo="${FRIENDICA_REPOSITORY:-friendica/friendica}"
friendica_addons_repo="${FRIENDICA_ADDONS_REPO:-friendica/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
# Check if the branches exist before wiping the
if check_branch "$friendica_repo" "$friendica_git" && check_branch "$friendica_addons_repo" "$addons_git" ; then
echo "Downloading Friendica from GitHub '${friendica_repo}/${friendica_git}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica
mkdir /usr/src/friendica/addon
git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon
echo "Download finished"
if [ ! -f /usr/src/friendica/VERSION ]; then
echo "Couldn't clone repository"
exit 1
fi
/usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica
return 0
else
if check_branch "$friendica_repo" "$friendica_git"; then
echo "$friendica_repo/$friendica_git is not valid."
else
echo "$friendica_addons_repo/$addons_git is not valid."
fi
echo "Using old version."
return 1
fi
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
@ -112,33 +56,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; 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|-RC)' || [ "${FRIENDICA_UPGRADE:-false}" = "true" ] || [ ! -f /usr/src/friendica/VERSION ]; then
# just clone & check if it's a new install or upgrade
clone_develop
if [ "$?" -eq "0" ]; then
image_version="$(cat /usr/src/friendica/VERSION)"
check=true
fi
else
image_version="$(cat /usr/src/friendica/VERSION)"
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
# 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
setup_ssmtp
if [ "$check" = true ]; then
# check it just in case the version is greater
if version_greater "$image_version" "$installed_version"; then
echo "Initializing Friendica $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then
@ -206,7 +135,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.config.php) to the config folder (currently only local.config.php and addon.config.php supported)
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi

View File

@ -118,5 +118,5 @@ ENV FRIENDICA_ADDONS 2019.12-dev
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/friendica/config/
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint-dev.sh"]
CMD ["php-fpm"]

View File

@ -0,0 +1,69 @@
#!/bin/sh
set -eu
# checks if the branch and repository exists
check_branch() {
repo=${1:-}
branch=${2:-}
git ls-remote --heads --tags "https://github.com/$repo" | grep -E "refs/(heads|tags)/${branch}$" >/dev/null
[ "$?" -eq "0" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
friendica_repo="${FRIENDICA_REPOSITORY:-friendica/friendica}"
friendica_addons_repo="${FRIENDICA_ADDONS_REPO:-friendica/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
# Check if the branches exist before wiping the
if check_branch "$friendica_repo" "$friendica_git" && check_branch "$friendica_addons_repo" "$addons_git" ; then
echo "Cloning '${friendica_git}' from GitHub repository '${friendica_repo}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica
mkdir /usr/src/friendica/addon
git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon
echo "Download finished"
if [ ! -f /usr/src/friendica/VERSION ]; then
echo "Couldn't clone repository"
exit 1
fi
/usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica
return 0
else
if check_branch "$friendica_repo" "$friendica_git"; then
echo "$friendica_repo/$friendica_git is not valid."
else
echo "$friendica_addons_repo/$addons_git is not valid."
fi
echo "Using old version."
return 1
fi
}
# just check if we execute apache or php-fpm
if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
# cloning from git is just possible for develop or Release Candidats
if echo "${FRIENDICA_VERSION}" | grep -Eq '^.*(\-dev|-rc|-RC)' || [ "${FRIENDICA_UPGRADE:-false}" = "true" ] || [ ! -f /usr/src/friendica/VERSION ]; then
# just clone & check if it's a new install or upgrade
clone_develop
fi
fi
/entrypoint.sh "$@"

View File

@ -16,62 +16,6 @@ version_greater() {
[ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ]
}
# checks if the branch and repository exists
check_branch() {
repo=${1:-}
branch=${2:-}
git ls-remote --heads --tags "https://github.com/$repo" | grep -E "refs/(heads|tags)/${branch}$" >/dev/null
[ "$?" -eq "0" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
friendica_repo="${FRIENDICA_REPOSITORY:-friendica/friendica}"
friendica_addons_repo="${FRIENDICA_ADDONS_REPO:-friendica/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
# Check if the branches exist before wiping the
if check_branch "$friendica_repo" "$friendica_git" && check_branch "$friendica_addons_repo" "$addons_git" ; then
echo "Downloading Friendica from GitHub '${friendica_repo}/${friendica_git}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica
mkdir /usr/src/friendica/addon
git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon
echo "Download finished"
if [ ! -f /usr/src/friendica/VERSION ]; then
echo "Couldn't clone repository"
exit 1
fi
/usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica
return 0
else
if check_branch "$friendica_repo" "$friendica_git"; then
echo "$friendica_repo/$friendica_git is not valid."
else
echo "$friendica_addons_repo/$addons_git is not valid."
fi
echo "Using old version."
return 1
fi
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
@ -112,33 +56,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; 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|-RC)' || [ "${FRIENDICA_UPGRADE:-false}" = "true" ] || [ ! -f /usr/src/friendica/VERSION ]; then
# just clone & check if it's a new install or upgrade
clone_develop
if [ "$?" -eq "0" ]; then
image_version="$(cat /usr/src/friendica/VERSION)"
check=true
fi
else
image_version="$(cat /usr/src/friendica/VERSION)"
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
# 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
setup_ssmtp
if [ "$check" = true ]; then
# check it just in case the version is greater
if version_greater "$image_version" "$installed_version"; then
echo "Initializing Friendica $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then
@ -206,7 +135,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.config.php) to the config folder (currently only local.config.php and addon.config.php supported)
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi

View File

@ -102,5 +102,5 @@ ENV FRIENDICA_ADDONS %%VERSION%%
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/friendica/config/
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/%%ENTRYPOINT%%"]
CMD ["%%CMD%%"]

View File

@ -117,5 +117,5 @@ ENV FRIENDICA_ADDONS %%VERSION%%
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/friendica/config/
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/%%ENTRYPOINT%%"]
CMD ["%%CMD%%"]

21
README-DEV.md Normal file
View File

@ -0,0 +1,21 @@
# Special settings for DEV/RC images
The `*-dev` and `*-rc` branches are having additional possibilities to get the latest sources of Friendica.
## Possible Environment Variables
The following environment variables are possible for these kind of images too:
**Develop/Release Candidat Settings**
- `FRIENDICA_UPGRADE` If set to `true`, a develop or release candidat node will get updated at startup.
- `FRIENDICA_REPOSITORY` If set, a custom repository will be chosen (Default: `friendica`)
- `FRIENDICA_ADDONS_REPO` If set, a custom repository for the addons will be chosen (Default: `friendica`)
- `FRIENDICA_VERSION` If set, a custom branch will be chosen (Default is based on the chosen image version)
- `FRIENDICA_ADDONS` If set, a custom branch for the addons will be chosen (Default is based on the chosen image version)
## Updating to a newer version
You don't need to pull the image for each commit in [friendica](https://github.com/friendica/friendica/).
Instead, the release candidate or develop branch will get updated if no installation was found or the environment variable `FRIENDICA_UPGRADE` is set to `true`.
It will clone the latest Friendica version and copy it to your working directory.

View File

@ -95,13 +95,6 @@ There are three options to enable the cron-job for Friendica:
- `REDIS_PW` (optional) The password for the redis instance (in case of locking).
- `REDIS_DB` (optional) The database instance of the redis instance (in case of locking).
**Develop/Release Candidat Settings**
- `FRIENDICA_UPGRADE` If set to `true`, a develop or release candidat node will get updated at startup.
- `FRIENDICA_REPOSITORY` If set, a custom repository will be chosen (Default: `friendica`)
- `FRIENDICA_ADDONS_REPO` If set, a custom repository for the addons will be chosen (Default: `friendica`)
- `FRIENDICA_VERSION` If set, a custom branch will be chosen (Default is based on the chosen image version)
- `FRIENDICA_ADDONS` If set, a custom branch for the addons will be chosen (Default is based on the chosen image version)
## Administrator account
Because Friendica links the administrator account to a specific mail address, you **have** to set a valid address for `MAILNAME`.
@ -184,20 +177,9 @@ If no other environment variable is set, this `local.config.php` will get copied
## Updating to a newer version
There are differences between the deveop (everything which ends with `-rc` or `-dev`) and the stable (the rest) branches.
### Updating stable
You have to pull the latest image from the hub (`docker pull friendica`).
The stable branch gets checked at every startup and will get updated if no installation was found or a new image is used.
### Updating develop
You don't need to pull the image for each commit in [friendica](https://github.com/friendica/friendica/).
Instead, the develop branch will get updated if no installation was found or the environment variable `FRIENDICA_UPGRADE` is set to `true`.
It will clone the latest Friendica version and copy it to your working directory.
# Running this image with docker-compose
The easiest way to get a fully featured and functional setup is using a `docker-compose` file.

69
docker-entrypoint-dev.sh Executable file
View File

@ -0,0 +1,69 @@
#!/bin/sh
set -eu
# checks if the branch and repository exists
check_branch() {
repo=${1:-}
branch=${2:-}
git ls-remote --heads --tags "https://github.com/$repo" | grep -E "refs/(heads|tags)/${branch}$" >/dev/null
[ "$?" -eq "0" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
friendica_repo="${FRIENDICA_REPOSITORY:-friendica/friendica}"
friendica_addons_repo="${FRIENDICA_ADDONS_REPO:-friendica/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
# Check if the branches exist before wiping the
if check_branch "$friendica_repo" "$friendica_git" && check_branch "$friendica_addons_repo" "$addons_git" ; then
echo "Cloning '${friendica_git}' from GitHub repository '${friendica_repo}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica
mkdir /usr/src/friendica/addon
git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon
echo "Download finished"
if [ ! -f /usr/src/friendica/VERSION ]; then
echo "Couldn't clone repository"
exit 1
fi
/usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica
return 0
else
if check_branch "$friendica_repo" "$friendica_git"; then
echo "$friendica_repo/$friendica_git is not valid."
else
echo "$friendica_addons_repo/$addons_git is not valid."
fi
echo "Using old version."
return 1
fi
}
# just check if we execute apache or php-fpm
if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
# cloning from git is just possible for develop or Release Candidats
if echo "${FRIENDICA_VERSION}" | grep -Eq '^.*(\-dev|-rc|-RC)' || [ "${FRIENDICA_UPGRADE:-false}" = "true" ] || [ ! -f /usr/src/friendica/VERSION ]; then
# just clone & check if it's a new install or upgrade
clone_develop
fi
fi
/entrypoint.sh "$@"

View File

@ -16,62 +16,6 @@ version_greater() {
[ "$(printf '%s\n' "$@" | sort -r -t '-' -k2,2 | sort -t '.' -n -k1,1 -k2,2 -s | head -n 1)" != "$1" ]
}
# checks if the branch and repository exists
check_branch() {
repo=${1:-}
branch=${2:-}
git ls-remote --heads --tags "https://github.com/$repo" | grep -E "refs/(heads|tags)/${branch}$" >/dev/null
[ "$?" -eq "0" ]
}
# clones the whole develop branch (Friendica and Addons)
clone_develop() {
friendica_git="${FRIENDICA_VERSION}"
addons_git="${FRIENDICA_ADDONS}"
friendica_repo="${FRIENDICA_REPOSITORY:-friendica/friendica}"
friendica_addons_repo="${FRIENDICA_ADDONS_REPO:-friendica/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
# Check if the branches exist before wiping the
if check_branch "$friendica_repo" "$friendica_git" && check_branch "$friendica_addons_repo" "$addons_git" ; then
echo "Downloading Friendica from GitHub '${friendica_repo}/${friendica_git}' ..."
# Removing the whole directory first
rm -fr /usr/src/friendica
git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica
mkdir /usr/src/friendica/addon
git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon
echo "Download finished"
if [ ! -f /usr/src/friendica/VERSION ]; then
echo "Couldn't clone repository"
exit 1
fi
/usr/src/friendica/bin/composer.phar install --no-dev -d /usr/src/friendica
return 0
else
if check_branch "$friendica_repo" "$friendica_git"; then
echo "$friendica_repo/$friendica_git is not valid."
else
echo "$friendica_addons_repo/$addons_git is not valid."
fi
echo "Using old version."
return 1
fi
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
@ -112,33 +56,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; 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|-RC)' || [ "${FRIENDICA_UPGRADE:-false}" = "true" ] || [ ! -f /usr/src/friendica/VERSION ]; then
# just clone & check if it's a new install or upgrade
clone_develop
if [ "$?" -eq "0" ]; then
image_version="$(cat /usr/src/friendica/VERSION)"
check=true
fi
else
image_version="$(cat /usr/src/friendica/VERSION)"
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
# 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
setup_ssmtp
if [ "$check" = true ]; then
# check it just in case the version is greater
if version_greater "$image_version" "$installed_version"; then
echo "Initializing Friendica $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then
@ -206,7 +135,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.config.php) to the config folder (currently only local.config.php and addon.config.php supported)
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi

View File

@ -23,6 +23,11 @@ declare -A extras=(
[fpm-alpine]=''
)
declare -A entrypoints=(
[stable]='entrypoint.sh'
[develop]='entrypoint-dev.sh'
)
apcu_version="$(
git ls-remote --tags https://github.com/krakjoe/apcu.git \
| cut -d/ -f3 \
@ -116,12 +121,17 @@ function create_variant() {
s/%%IMAGICK_VERSION%%/'"${pecl_versions[imagick]}"'/g;
s/%%MEMCACHED_VERSION%%/'"${pecl_versions[memcached]}"'/g;
s/%%REDIS_VERSION%%/'"${pecl_versions[redis]}"'/g;
s/%%ENTRYPOINT%%/'"${entrypoints[$install_type]}"'/g;
' "$dir/Dockerfile"
for name in entrypoint cron; do
cp "docker-$name.sh" "$dir/$name.sh"
done
if [[ $install_type == "develop" ]]; then
cp "docker-entrypoint-dev.sh" "$dir/entrypoint-dev.sh"
fi
cp upgrade.exclude "$dir/"
cp -rT .config "$dir/config"