From e319f769235f3ea6734ba10438d71319d2f290b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 4 Jan 2021 20:05:15 +0100 Subject: [PATCH] feat: add .editorconfig and fix indent of some files (#98) --- .editorconfig | 76 +++++++++++++++++++++++++++++++++ Dockerfile | 46 ++++++++++---------- docker/php/docker-entrypoint.sh | 62 +++++++++++++-------------- 3 files changed, 130 insertions(+), 54 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..77ae3c2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,76 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] +# Change these settings to your own preference +indent_style = space +indent_size = 4 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{js,html}] +indent_style = space +indent_size = 2 + +[*.json] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false + +[*.php] +indent_style = space +indent_size = 4 + +[*.sh] +indent_style = tab +indent_size = 4 + +[*.{,.dist}] +indent_style = space +indent_size = 4 + +[*.{yaml,yml}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = false + +[api/helm/api/**.yaml] +indent_style = space +indent_size = 2 + +[.github/workflows/*.yml] +indent_style = space +indent_size = 2 + +[.gitmodules] +indent_style = tab +indent_size = 4 + +[.php_cs{,.dist}] +indent_style = space +indent_size = 4 + +[.travis.yml] +indent_style = space +indent_size = 2 + +[composer.json] +indent_style = space +indent_size = 4 + +[docker-compose{,.*}.{yaml,yml}] +indent_style = space +indent_size = 2 + +[Dockerfile] +indent_style = tab +indent_size = 4 diff --git a/Dockerfile b/Dockerfile index 9d6f80e..ace1f14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,42 +12,42 @@ FROM php:${PHP_VERSION}-fpm-alpine AS symfony_php # persistent / runtime deps RUN apk add --no-cache \ - acl \ - fcgi \ - file \ - gettext \ - git \ - jq \ - ; + acl \ + fcgi \ + file \ + gettext \ + git \ + jq \ + ; ARG APCU_VERSION=5.1.19 RUN set -eux; \ apk add --no-cache --virtual .build-deps \ - $PHPIZE_DEPS \ - icu-dev \ - libzip-dev \ - zlib-dev \ + $PHPIZE_DEPS \ + icu-dev \ + libzip-dev \ + zlib-dev \ ; \ \ docker-php-ext-configure zip; \ docker-php-ext-install -j$(nproc) \ - intl \ - zip \ + intl \ + zip \ ; \ pecl install \ - apcu-${APCU_VERSION} \ + apcu-${APCU_VERSION} \ ; \ pecl clear-cache; \ docker-php-ext-enable \ - apcu \ - opcache \ + apcu \ + opcache \ ; \ \ runDeps="$( \ - scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ - | tr ',' '\n' \ - | sort -u \ - | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ )"; \ apk add --no-cache --virtual .phpexts-rundeps $runDeps; \ \ @@ -109,9 +109,9 @@ CMD ["php-fpm"] FROM caddy:${CADDY_VERSION}-builder-alpine AS symfony_caddy_builder RUN xcaddy build \ - --with github.com/dunglas/mercure@main \ - --with github.com/dunglas/mercure/caddy@main \ - --with github.com/dunglas/vulcain/caddy + --with github.com/dunglas/mercure@main \ + --with github.com/dunglas/mercure/caddy@main \ + --with github.com/dunglas/vulcain/caddy FROM caddy:${CADDY_VERSION} AS symfony_caddy diff --git a/docker/php/docker-entrypoint.sh b/docker/php/docker-entrypoint.sh index e34c0f3..71e9358 100755 --- a/docker/php/docker-entrypoint.sh +++ b/docker/php/docker-entrypoint.sh @@ -13,42 +13,42 @@ if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then fi ln -sf "$PHP_INI_RECOMMENDED" "$PHP_INI_DIR/php.ini" - mkdir -p var/cache var/log + mkdir -p var/cache var/log - # The first time volumes are mounted, the project needs to be recreated - if [ ! -f composer.json ]; then - composer create-project "symfony/skeleton $SYMFONY_VERSION" tmp --stability=$STABILITY --prefer-dist --no-progress --no-interaction - jq '.extra.symfony.docker=true' tmp/composer.json > tmp/composer.tmp.json - rm tmp/composer.json - mv tmp/composer.tmp.json tmp/composer.json + # The first time volumes are mounted, the project needs to be recreated + if [ ! -f composer.json ]; then + composer create-project "symfony/skeleton $SYMFONY_VERSION" tmp --stability=$STABILITY --prefer-dist --no-progress --no-interaction + jq '.extra.symfony.docker=true' tmp/composer.json >tmp/composer.tmp.json + rm tmp/composer.json + mv tmp/composer.tmp.json tmp/composer.json - cp -Rp tmp/. . - rm -Rf tmp/ - elif [ "$APP_ENV" != 'prod' ]; then - rm -f .env.local.php - composer install --prefer-dist --no-progress --no-interaction - fi + cp -Rp tmp/. . + rm -Rf tmp/ + elif [ "$APP_ENV" != 'prod' ]; then + rm -f .env.local.php + composer install --prefer-dist --no-progress --no-interaction + fi - if grep -q DATABASE_URL= .env; then - echo "Waiting for db to be ready..." - ATTEMPTS_LEFT_TO_REACH_DATABASE=60 - until [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ] || bin/console doctrine:query:sql "SELECT 1" > /dev/null 2>&1; do - sleep 1 - ATTEMPTS_LEFT_TO_REACH_DATABASE=$((ATTEMPTS_LEFT_TO_REACH_DATABASE-1)) - echo "Still waiting for db to be ready... Or maybe the db is not reachable. $ATTEMPTS_LEFT_TO_REACH_DATABASE attempts left" - done + if grep -q DATABASE_URL= .env; then + echo "Waiting for db to be ready..." + ATTEMPTS_LEFT_TO_REACH_DATABASE=60 + until [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ] || bin/console doctrine:query:sql "SELECT 1" >/dev/null 2>&1; do + sleep 1 + ATTEMPTS_LEFT_TO_REACH_DATABASE=$((ATTEMPTS_LEFT_TO_REACH_DATABASE - 1)) + echo "Still waiting for db to be ready... Or maybe the db is not reachable. $ATTEMPTS_LEFT_TO_REACH_DATABASE attempts left" + done - if [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ]; then - echo "The db is not up or not reachable" - exit 1 - else - echo "The db is now ready and reachable" - fi + if [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ]; then + echo "The db is not up or not reachable" + exit 1 + else + echo "The db is now ready and reachable" + fi - if ls -A migrations/*.php > /dev/null 2>&1; then - bin/console doctrine:migrations:migrate --no-interaction - fi - fi + if ls -A migrations/*.php >/dev/null 2>&1; then + bin/console doctrine:migrations:migrate --no-interaction + fi + fi setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX var setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX var