From c3e7e99baa5f8200604836f70faab73ad6002a69 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Tue, 31 May 2016 21:05:18 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=92=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8?= =?UTF-8?q?=D0=B3=D0=B5=20=D0=B4=D0=BE=D0=BA=D0=B5=D1=80=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=87=D0=B8=D0=BD=D0=B5=D0=BD=D0=B0=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=20xdebug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 6 +++--- .env | 2 ++ Dockerfile | 17 +++++++++++------ docker-compose.yml | 17 ++++++----------- docker/nginx/nginx.conf | 23 ++++++++--------------- environments/docker/.env | 2 ++ 6 files changed, 32 insertions(+), 35 deletions(-) create mode 100644 .env create mode 100644 environments/docker/.env diff --git a/.dockerignore b/.dockerignore index d5427a2..f22d37a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -10,7 +10,7 @@ node_modules */config/*-local.php # Все временные файлы -runtime +*/runtime -# Их по идее и не должно образовываться, но мало ли -api/web/assets +# Их по идее их не должно образовываться, но мало ли +*/web/assets diff --git a/.env b/.env new file mode 100644 index 0000000..3a6845c --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +XDEBUG_CONFIG=remote_host=192.168.99.1 +PHP_IDE_CONFIG=serverName=docker diff --git a/Dockerfile b/Dockerfile index 5ba392e..74f35e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,14 +33,20 @@ RUN apt-get update \ # Поставим xdebug отдельно, т.к. потом его потенциально придётся отсюда убирать RUN yes | pecl install xdebug \ && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \ - && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \ - && echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini + && echo "xdebug.default_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini \ + && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini \ + && echo "xdebug.remote_handler=dbgp" >> /usr/local/etc/php/conf.d/xdebug.ini \ + && echo "xdebug.remote_mode=req" >> /usr/local/etc/php/conf.d/xdebug.ini \ + && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/xdebug.ini \ + && echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/xdebug.ini \ + && echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/xdebug.ini \ + && echo "xdebug.cli_color=1" >> /usr/local/etc/php/conf.d/xdebug.ini \ + && echo "xdebug.var_display_max_depth=10" >> /usr/local/etc/php/conf.d/xdebug.ini # Next composer and global composer package, as their versions may change from time to time RUN curl -sS https://getcomposer.org/installer | php \ && mv composer.phar /usr/local/bin/composer.phar \ - && composer.phar global require --no-progress "fxp/composer-asset-plugin:~1.1.4" \ - && composer.phar global require --no-progress "hirak/prestissimo:~0.2.2" + && composer.phar global require --no-progress "fxp/composer-asset-plugin:~1.1.4" "hirak/prestissimo:~0.2.2" COPY ./docker/php/composer.sh /usr/local/bin/composer RUN chmod a+x /usr/local/bin/composer @@ -53,9 +59,8 @@ COPY . /var/www/html # The following directories are .dockerignored to not pollute the docker images # with local logs and published assets from development. So we need to create # empty dirs and set right permissions inside the container. -RUN mkdir api/runtime api/web/assets console/runtime \ +RUN mkdir -p api/runtime api/web/assets console/runtime \ && chown www-data:www-data api/runtime api/web/assets console/runtime # Expose everything under /var/www (vendor + html) -# This is only required for the nginx setup VOLUME ["/var/www"] diff --git a/docker-compose.yml b/docker-compose.yml index 3792cb2..3c4a249 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,18 @@ version: '2' services: app: + build: . + expose: + - "9000" links: - db - redis - rabbitmq depends_on: - app-console-account-queue - + volumes: + - ./:/var/www/html/ + env_file: .env environment: ENABLE_ENV_FILE: 1 ENABLE_LOCALCONF: 1 @@ -21,16 +26,6 @@ services: volumes_from: - app - app: - build: . - expose: - - "9000" - volumes: - - ./:/var/www/html/ - environment: - ENABLE_ENV_FILE: 1 - ENABLE_LOCALCONF: 1 - node-dev-server: build: ./frontend ports: diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf index 83e92db..9e27807 100644 --- a/docker/nginx/nginx.conf +++ b/docker/nginx/nginx.conf @@ -16,14 +16,10 @@ http { '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; - access_log /var/log/nginx/access.log main; + access_log /var/log/nginx/access.log main; - sendfile on; - #tcp_nopush on; - - keepalive_timeout 65; - - #gzip on; + sendfile on; + keepalive_timeout 10; server { listen 80; @@ -43,13 +39,14 @@ http { } location /api { - try_files $uri /api/web/index.php?$args; + try_files $uri /api/web/index.php?$args; } location ~* \.php$ { - fastcgi_pass app:9000; - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_pass app:9000; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SERVER_NAME $host; } # Раздача статики для frontend @@ -58,10 +55,6 @@ http { expires max; access_log off; } - - location ~* \.(htaccess|htpasswd|svn|git) { - deny all; - } } } diff --git a/environments/docker/.env b/environments/docker/.env new file mode 100644 index 0000000..3a6845c --- /dev/null +++ b/environments/docker/.env @@ -0,0 +1,2 @@ +XDEBUG_CONFIG=remote_host=192.168.99.1 +PHP_IDE_CONFIG=serverName=docker From 67fa28aaa1c8feec12e62a655e7581845e6d5453 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Tue, 31 May 2016 21:11:11 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D1=91=D0=BD=20?= =?UTF-8?q?=D0=BD=D0=B8=D0=BA=D0=BE=D0=BC=D1=83=20=D0=BD=D0=B5=D0=BD=D1=83?= =?UTF-8?q?=D0=B6=D0=BD=D1=8B=D0=B9=20SiteController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/config/main.php | 7 +- api/controllers/SiteController.php | 190 ----------------------------- 2 files changed, 2 insertions(+), 195 deletions(-) delete mode 100644 api/controllers/SiteController.php diff --git a/api/config/main.php b/api/config/main.php index ff3af4c..a588dc8 100644 --- a/api/config/main.php +++ b/api/config/main.php @@ -11,6 +11,7 @@ return [ 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'api\controllers', + 'params' => $params, 'components' => [ 'user' => [ 'identityClass' => \api\models\AccountIdentity::class, @@ -26,9 +27,6 @@ return [ ], ], ], - 'errorHandler' => [ - 'errorAction' => 'site/error', - ], 'request' => [ 'baseUrl' => '/api', ], @@ -38,7 +36,7 @@ return [ 'rules' => require __DIR__ . '/routes.php', ], 'reCaptcha' => [ - 'class' => 'api\components\ReCaptcha\Component', + 'class' => \api\components\ReCaptcha\Component::class, ], 'response' => [ 'format' => \yii\web\Response::FORMAT_JSON, @@ -48,5 +46,4 @@ return [ 'grantTypes' => ['authorization_code'], ], ], - 'params' => $params, ]; diff --git a/api/controllers/SiteController.php b/api/controllers/SiteController.php deleted file mode 100644 index 716f003..0000000 --- a/api/controllers/SiteController.php +++ /dev/null @@ -1,190 +0,0 @@ - [ - 'class' => AccessControl::className(), - 'only' => ['logout', 'signup'], - 'rules' => [ - [ - 'actions' => ['signup'], - 'allow' => true, - 'roles' => ['?'], - ], - [ - 'actions' => ['logout'], - 'allow' => true, - 'roles' => ['@'], - ], - ], - ], - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'logout' => ['post'], - ], - ], - ]; - } - - /** - * @inheritdoc - */ - public function actions() - { - return [ - 'error' => [ - 'class' => 'yii\web\ErrorAction', - ], - 'captcha' => [ - 'class' => 'yii\captcha\CaptchaAction', - 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, - ], - ]; - } - - /** - * Displays homepage. - * - * @return mixed - */ - public function actionIndex() - { - return $this->render('index'); - } - - /** - * Logs out the current user. - * - * @return mixed - */ - public function actionLogout() - { - Yii::$app->user->logout(); - - return $this->goHome(); - } - - /** - * Displays contact page. - * - * @return mixed - */ - public function actionContact() - { - $model = new ContactForm(); - if ($model->load(Yii::$app->request->post()) && $model->validate()) { - if ($model->sendEmail(Yii::$app->params['adminEmail'])) { - Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.'); - } else { - Yii::$app->session->setFlash('error', 'There was an error sending email.'); - } - - return $this->refresh(); - } else { - return $this->render('contact', [ - 'model' => $model, - ]); - } - } - - /** - * Displays about page. - * - * @return mixed - */ - public function actionAbout() - { - return $this->render('about'); - } - - /** - * Signs user up. - * - * @return mixed - */ - public function actionSignup() - { - $model = new SignupForm(); - if ($model->load(Yii::$app->request->post())) { - if ($user = $model->signup()) { - if (Yii::$app->getUser()->login($user)) { - return $this->goHome(); - } - } - } - - return $this->render('signup', [ - 'model' => $model, - ]); - } - - /** - * Requests password reset. - * - * @return mixed - */ - public function actionRequestPasswordReset() - { - $model = new PasswordResetRequestForm(); - if ($model->load(Yii::$app->request->post()) && $model->validate()) { - if ($model->sendEmail()) { - Yii::$app->session->setFlash('success', 'Check your email for further instructions.'); - - return $this->goHome(); - } else { - Yii::$app->session->setFlash('error', 'Sorry, we are unable to reset password for email provided.'); - } - } - - return $this->render('requestPasswordResetToken', [ - 'model' => $model, - ]); - } - - /** - * Resets password. - * - * @param string $token - * @return mixed - * @throws BadRequestHttpException - */ - public function actionResetPassword($token) - { - try { - $model = new ResetPasswordForm($token); - } catch (InvalidParamException $e) { - throw new BadRequestHttpException($e->getMessage()); - } - - if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) { - Yii::$app->session->setFlash('success', 'New password was saved.'); - - return $this->goHome(); - } - - return $this->render('resetPassword', [ - 'model' => $model, - ]); - } -}