From d2b7f28db689df6c9de039bc4b8aebc7382641b8 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Thu, 21 Sep 2017 16:23:05 +0300 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=B0=D0=B7=D0=BE=D0=B2=D1=8B=D0=B9=20im?= =?UTF-8?q?age=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D1=91=D0=BD=20=D0=B4?= =?UTF-8?q?=D0=BE=20accounts-php:1.5.0=20=D0=9B=D0=BE=D0=B3=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0=20bootstrap.sh=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B2=20=D1=8D=D1=82=D0=BE=D1=82=20=D1=80=D0=B5=D0=BF=D0=BE?= =?UTF-8?q?=D0=B7=D0=B8=D1=82=D0=BE=D1=80=D0=B8=D0=B9=20=D0=94=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=B2=D1=8B=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D1=8B=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D0=B8?= =?UTF-8?q?=20=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82=D1=83=D1=80=D1=8B=20RBA?= =?UTF-8?q?C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 6 ++++-- Dockerfile-dev | 6 ++++-- docker/php/bootstrap.sh | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100755 docker/php/bootstrap.sh diff --git a/Dockerfile b/Dockerfile index 6aefae6..0304861 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ -FROM registry.ely.by/elyby/accounts-php:1.4.0 +FROM registry.ely.by/elyby/accounts-php:1.5.0 +# bootstrap скрипт для проекта +COPY docker/php/bootstrap.sh /bootstrap.sh # Вносим конфигурации для крона и воркеров COPY docker/cron/* /etc/cron.d/ COPY docker/supervisor/* /etc/supervisor/conf.d/ @@ -11,7 +13,7 @@ RUN chmod 400 ~/.ssh/id_rsa \ && eval $(ssh-agent -s) \ && ssh-add /root/.ssh/id_rsa \ && touch /root/.ssh/known_hosts \ - && ssh-keyscan gitlab.com gitlab.ely.by >> /root/.ssh/known_hosts + && ssh-keyscan github.com gitlab.ely.by >> /root/.ssh/known_hosts # Копируем composer.json в родительскую директорию, которая не будет синкаться с хостом через # volume на dev окружении. В entrypoint эта папка будет скопирована обратно. diff --git a/Dockerfile-dev b/Dockerfile-dev index 3000374..1d3e4b1 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -1,5 +1,7 @@ -FROM registry.ely.by/elyby/accounts-php:1.4.0-dev +FROM registry.ely.by/elyby/accounts-php:1.5.0-dev +# bootstrap скрипт для проекта +COPY docker/php/bootstrap.sh /bootstrap.sh # Вносим конфигурации для крона и воркеров COPY docker/cron/* /etc/cron.d/ COPY docker/supervisor/* /etc/supervisor/conf.d/ @@ -11,7 +13,7 @@ RUN chmod 400 ~/.ssh/id_rsa \ && eval $(ssh-agent -s) \ && ssh-add /root/.ssh/id_rsa \ && touch /root/.ssh/known_hosts \ - && ssh-keyscan gitlab.com gitlab.ely.by >> /root/.ssh/known_hosts + && ssh-keyscan github.com gitlab.ely.by >> /root/.ssh/known_hosts # Копируем composer.json в родительскую директорию, которая не будет синкаться с хостом через # volume на dev окружении. В entrypoint эта папка будет скопирована обратно. diff --git a/docker/php/bootstrap.sh b/docker/php/bootstrap.sh new file mode 100755 index 0000000..81be543 --- /dev/null +++ b/docker/php/bootstrap.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +if [ "$YII_ENV" = "test" ] +then + YII_EXEC="/var/www/html/tests/codeception/bin/yii" +else + YII_EXEC="/var/www/html/yii" +fi + +if ! cmp -s ./../vendor/autoload.php ./vendor/autoload.php +then + echo "Vendor have diffs" + echo "Removing not bundled vendor..." + rm -rf ./vendor + echo "Copying new one..." + cp -r ./../vendor ./vendor +fi + +# Переносим dist, если его нету или он изменился (или затёрся силами volume) +if ! cmp -s ./../dist/index.html ./frontend/dist/index.html +then + echo "Frontend dist have diffs" + echo "Removing not bundled dist..." + rm -rf ./frontend/dist + echo "Copying new one..." + cp -r ./../dist ./frontend/dist +fi + +# Генерируем правила RBAC +echo "Generating RBAC rules" +php $YII_EXEC rbac/generate + +if [ "$YII_ENV" != "test" ] +then + wait-for-it "${DB_HOST:-db}:3306" -s -t 0 -- "php $YII_EXEC migrate/up --interactive=0" +else + wait-for-it "${DB_HOST:-testdb}:3306" -s -t 0 -- "php $YII_EXEC migrate/up --interactive=0" +fi