From 8c2cf1b4dd3a6c79d77f9dc1a256e9d4a8db6a68 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 7 Jul 2019 20:07:01 +0200 Subject: Docker healthcheck+ labels (#2438) * Add Docker labels And try to fix the platform metadata for ARM, and add health check * Execution rights * Remove experimental features not supported by Docker Hub "--squash" is only supported on a Docker daemon with experimental features enabled. build hook failed! (1) * Fix paths --- Docker/hooks/build | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 Docker/hooks/build (limited to 'Docker/hooks/build') diff --git a/Docker/hooks/build b/Docker/hooks/build new file mode 100755 index 000000000..73bc90e74 --- /dev/null +++ b/Docker/hooks/build @@ -0,0 +1,22 @@ +#!/bin/bash + +cd .. +FRESHRSS_VERSION=`grep "'FRESHRSS_VERSION'" constants.php | cut -d "'" -f4` +echo "$FRESHRSS_VERSION" + +if [[ "$DOCKERFILE_PATH" == *-ARM ]] +then + #TODO: Add --squash --platform arm options when Docker Hub deamon supports them + docker build \ + --build-arg FRESHRSS_VERSION="$FRESHRSS_VERSION" \ + --build-arg SOURCE_BRANCH="$SOURCE_BRANCH" \ + --build-arg SOURCE_COMMIT="$SOURCE_COMMIT" \ + -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" . +else + #TODO: Add --squash option when Docker Hub deamon supports it + docker build \ + --build-arg FRESHRSS_VERSION="$FRESHRSS_VERSION" \ + --build-arg SOURCE_BRANCH="$SOURCE_BRANCH" \ + --build-arg SOURCE_COMMIT="$SOURCE_COMMIT" \ + -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" . +fi -- cgit v1.2.3 From ad92518fe44279b69308aaf0a757469f5bf42910 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Mon, 22 Jul 2019 16:07:40 +0200 Subject: [CI] Run shellcheck and shfmt (#2454) * [CI] Run shellcheck and shfmt Cf. https://github.com/FreshRSS/FreshRSS/pull/2436#discussion_r305640019 * rename * no need for disable anymore * also remove leftover indentation flags even if it makes no difference to syntax checking * define colors and reset before exit for local use --- .travis.yml | 1 + Docker/entrypoint.sh | 11 +++++++---- Docker/hooks/build | 5 ++--- Docker/hooks/pre_build | 3 +-- p/themes/Ansum/sass.sh | 1 + p/themes/Mapco/sass.sh | 1 + tests/shellchecks.sh | 29 +++++++++++++++++++++++++++++ 7 files changed, 42 insertions(+), 9 deletions(-) create mode 100755 tests/shellchecks.sh (limited to 'Docker/hooks/build') diff --git a/.travis.yml b/.travis.yml index 078a91109..ee510ee84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ script: - phpenv rehash - find . -not -path "./lib/JSON.php" -name \*.php -print0 | xargs -0 -n1 -P4 php -l 1>/dev/null 2>php-l-results - if [ -s php-l-results ]; then cat php-l-results; exit 1; fi + - bash tests/shellchecks.sh - | if [[ $VALIDATE_STANDARD == yes ]]; then COMPOSER_BIN=$(composer global config --absolute bin-dir) diff --git a/Docker/entrypoint.sh b/Docker/entrypoint.sh index b7a961569..bb0e1bde0 100755 --- a/Docker/entrypoint.sh +++ b/Docker/entrypoint.sh @@ -1,15 +1,18 @@ #!/bin/sh -php -f ./cli/prepare.php > /dev/null +php -f ./cli/prepare.php >/dev/null chown -R :www-data . chmod -R g+r . && chmod -R g+w ./data/ -find /etc/php*/ -name php.ini -exec sed -r -i "\#^;?date.timezone#s#^.*#date.timezone = $TZ#" {} \; +find /etc/php*/ -name php.ini -exec sed -r -i "\\#^;?date.timezone#s#^.*#date.timezone = $TZ#" {} \; if [ -n "$CRON_MIN" ]; then - (echo "export TZ=$TZ" ; echo "export COPY_SYSLOG_TO_STDERR=$COPY_SYSLOG_TO_STDERR") > /var/www/FreshRSS/Docker/env.txt - crontab -l | sed -r "\#FreshRSS#s#^[^ ]+ #$CRON_MIN #" | crontab - + ( + echo "export TZ=$TZ" + echo "export COPY_SYSLOG_TO_STDERR=$COPY_SYSLOG_TO_STDERR" + ) >/var/www/FreshRSS/Docker/env.txt + crontab -l | sed -r "\\#FreshRSS#s#^[^ ]+ #$CRON_MIN #" | crontab - fi exec "$@" diff --git a/Docker/hooks/build b/Docker/hooks/build index 73bc90e74..84e759a80 100755 --- a/Docker/hooks/build +++ b/Docker/hooks/build @@ -1,11 +1,10 @@ #!/bin/bash cd .. -FRESHRSS_VERSION=`grep "'FRESHRSS_VERSION'" constants.php | cut -d "'" -f4` +FRESHRSS_VERSION=$(grep "'FRESHRSS_VERSION'" constants.php | cut -d "'" -f4) echo "$FRESHRSS_VERSION" -if [[ "$DOCKERFILE_PATH" == *-ARM ]] -then +if [[ $DOCKERFILE_PATH == *-ARM ]]; then #TODO: Add --squash --platform arm options when Docker Hub deamon supports them docker build \ --build-arg FRESHRSS_VERSION="$FRESHRSS_VERSION" \ diff --git a/Docker/hooks/pre_build b/Docker/hooks/pre_build index 5946b045b..b2cda0e48 100755 --- a/Docker/hooks/pre_build +++ b/Docker/hooks/pre_build @@ -1,7 +1,6 @@ #!/bin/bash -if [[ "$DOCKERFILE_PATH" == *-ARM ]] -then +if [[ $DOCKERFILE_PATH == *-ARM ]]; then # https://github.com/balena-io/qemu # Download a local copy of QEMU on Docker Hub build machine curl -LSs 'https://github.com/balena-io/qemu/releases/download/v3.0.0%2Bresin/qemu-3.0.0+resin-arm.tar.gz' | tar -xzv --strip-components=1 --wildcards '*/qemu-*' diff --git a/p/themes/Ansum/sass.sh b/p/themes/Ansum/sass.sh index a653acace..6c65128ea 100644 --- a/p/themes/Ansum/sass.sh +++ b/p/themes/Ansum/sass.sh @@ -1 +1,2 @@ +#!/bin/sh sass --watch ansum.scss:ansum.css diff --git a/p/themes/Mapco/sass.sh b/p/themes/Mapco/sass.sh index 316d04cf2..c0b3d47df 100644 --- a/p/themes/Mapco/sass.sh +++ b/p/themes/Mapco/sass.sh @@ -1 +1,2 @@ +#!/bin/sh sass --watch mapco.scss:mapco.css diff --git a/tests/shellchecks.sh b/tests/shellchecks.sh new file mode 100755 index 000000000..648f2766e --- /dev/null +++ b/tests/shellchecks.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Based on https://github.com/koreader/koreader/blob/master/.ci/helper_shellchecks.sh + +ANSI_RED="\\033[31;1m" +ANSI_GREEN="\\033[32;1m" +ANSI_RESET="\\033[0m" + +mapfile -t shellscript_locations < <({ git grep -lE '^#!(/usr)?/bin/(env )?(bash|sh)' && git ls-files ./*.sh; } | sort | uniq) + +SHELLSCRIPT_ERROR=0 + +for shellscript in "${shellscript_locations[@]}"; do + echo -e "${ANSI_GREEN}Running shellcheck on ${shellscript}" + shellcheck "${shellscript}" || SHELLSCRIPT_ERROR=1 + echo -e "${ANSI_GREEN}Running shfmt on ${shellscript}" + if ! shfmt "${shellscript}" >/dev/null 2>&1; then + echo -e "${ANSI_RED}Warning: ${shellscript} contains the following problem:" + shfmt "${shellscript}" || SHELLSCRIPT_ERROR=1 + continue + fi + if [ "$(cat "${shellscript}")" != "$(shfmt "${shellscript}")" ]; then + echo -e "${ANSI_RED}Warning: ${shellscript} does not abide by coding style, diff for expected style:" + shfmt "${shellscript}" | diff "${shellscript}" - || SHELLSCRIPT_ERROR=1 + fi +done + +echo -ne "${ANSI_RESET}" + +exit "${SHELLSCRIPT_ERROR}" -- cgit v1.2.3