diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..ae145ac7 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [{ + "name": "Listen for XDebug on Docker", + "type": "php", + "request": "launch", + "port": 9002, + "pathMappings": { + "/var/www/html": "${workspaceFolder}", + }, + "log": true + }] +} diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..c436b9fe --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,49 @@ +// Webhook + Gitlab git pull + Vapor + +def payload = readJSON text: "${payload}" +String userName = payload.user_name +String userEmail = payload.user_email +String httpUrl = payload.project.http_url + + +pipeline { + agent { + docker { + image 'dillonngo/docker-based-image:poc' + args "--group-add 992 -v /var/run/docker.sock:/var/run/docker.sock" + } + } + environment { + HOME = '.' + } + stages { + stage('Download source code from Git') { + steps { + git( + url: httpUrl, + credentialsId: 'gitlab-jenkins-localhost', + branch: 'dillon/jenkins-aws-s3-34' + ) + } + } + + stage('Install') { + steps { + sh 'composer update' + } + } + + stage('Tests') { + steps { + sh 'vendor/bin/phpunit tests/Unit' + } + } + + stage('Deploy') { + steps { + sh 'vendor/bin/vapor deploy production --message="Test Jenkins"' + } + } + + } +} diff --git a/app/Classes/Modules/Accounts/ControllersLogic/CreateCustomerLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/CreateCustomerLogic.php index 0e920fe9..541fa51c 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/CreateCustomerLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/CreateCustomerLogic.php @@ -123,7 +123,7 @@ class CreateCustomerLogic extends AbstractControllerLogic CreatePerfexCRMCustomer::dispatch($createLeadPerfexCRMObject); } - $this->generateEmailVerificationAttemptProcessor->execute($user); + // $this->generateEmailVerificationAttemptProcessor->execute($user); //cief todo return $this->response($this->authenticationProcessor->execute($request)); diff --git a/app/Classes/Modules/Documents/ControllersLogic/RenderDocumentLogic.php b/app/Classes/Modules/Documents/ControllersLogic/RenderDocumentLogic.php index 2d095750..8b314dbc 100644 --- a/app/Classes/Modules/Documents/ControllersLogic/RenderDocumentLogic.php +++ b/app/Classes/Modules/Documents/ControllersLogic/RenderDocumentLogic.php @@ -54,11 +54,17 @@ class RenderDocumentLogic extends AbstractControllerLogic $this->canRenderDocument->passes(); - if(!Storage::disk('documents')->exists($file)) + // if(!Storage::disk('documents')->exists($file)) + // { + // throw new ResourceNotFoundException(); + // } + + // return $this->response(['src' => explode('.', $file)[1] == 'pdf' ? chunk_split(base64_encode(Storage::disk('documents')->get($file))) : Storage::disk('documents')->get($file) ]); + if(!Storage::disk('s3')->exists($file)) { throw new ResourceNotFoundException(); } return $this->response(['src' => explode('.', $file)[1] == 'pdf' ? chunk_split(base64_encode(Storage::disk('documents')->get($file))) : Storage::disk('documents')->get($file) ]); } -} \ No newline at end of file +} diff --git a/app/Classes/Modules/Documents/Services/ConvertsBase64ToFile.php b/app/Classes/Modules/Documents/Services/ConvertsBase64ToFile.php index 8741b823..17ae0d31 100644 --- a/app/Classes/Modules/Documents/Services/ConvertsBase64ToFile.php +++ b/app/Classes/Modules/Documents/Services/ConvertsBase64ToFile.php @@ -99,12 +99,15 @@ class ConvertsBase64ToFile */ private function generateFile(FileObject $file, string $suffix = '') { - $filePath = $this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension(); + // $filePath = $this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension(); - Storage::disk('documents')->put($filePath, $file->getDecodedData()); + // Storage::disk('documents')->put($filePath, $file->getDecodedData()); + // return $filePath; + + $filePath = 'localhost/'.$file->getFileName().$suffix.'.'.$file->getExtension(); + Storage::put($filePath, $file->getDecodedData(), 's3'); return $filePath; - } /** @@ -122,4 +125,4 @@ class ConvertsBase64ToFile ]); } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/AWS/AWSImageUploadController.php b/app/Http/Controllers/AWS/AWSImageUploadController.php new file mode 100644 index 00000000..f034b3a1 --- /dev/null +++ b/app/Http/Controllers/AWS/AWSImageUploadController.php @@ -0,0 +1,102 @@ +validate([ + 'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', + ]); + + $imageName = time().'.'.$request->image->extension(); + + $request->image->storeAs('images', $imageName); + + //cief todo: checking if storage disk exist + if (Storage::disk('documents')) { + $check1 = "The disk documents exists."; + } else { + $check1 = "The disk documents does not exist."; + } + + // $diskNames = Storage::diskNames(); + + // if (count($diskNames) > 0) { + // $check2 = "The following disks are configured: " . implode(', ', $diskNames); + // } else { + // $check2 = "No storage disks are configured."; + // } + + + if (Storage::disk('public')) { + $check2 = "The disk public exists."; + } else { + $check2 = "The disk public does not exist."; + } + + if (Storage::disk('local')) { + $check3 = "The disk local exists."; + } else { + $check3 = "The disk local does not exist."; + } + + + return redirect()->back() + ->with('success','You have successfully upload image.') + ->with('image',$imageName) + ->with('check1', $check1) + ->with('check2', $check2) + ->with('check3', $check3); + } + + + public function displayImage($fileName) + { + // dd($fileName); + + //1. + // $path = 'images/'.$fileName; + // $url = Storage::url($path); + // $url = Storage::temporaryUrl('file.jpg', now()->addMinutes(5)); + // return $url; + + + //2 + // $path = 'images/'.$fileName; + // // if(Storage::disk('s3')->exists($path)){ + // return Storage::disk('s3')->get($path); + // // } + // return null; + + + //original + $path = 'images/'.$fileName; + $file = Storage::get($path); + $type = Storage::mimeType($path); + + $response = Response::make($file, 200); + $response->header("Content-Type", $type); + return $response; + + // $path = 'images/'.$fileName; + // return Storage::temporaryUrl($path, now()->addMinutes(5)); + } + +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 8802ed7a..4aeff6bd 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -24,6 +24,8 @@ class AppServiceProvider extends ServiceProvider */ public function boot() { - // + if (!file_exists(storage_path('framework/sessions'))) { + mkdir(storage_path('framework/sessions'), 0777, true); + } } } diff --git a/docker-setup/Dockerfile b/docker-setup/Dockerfile index 13ce0249..71255f30 100644 --- a/docker-setup/Dockerfile +++ b/docker-setup/Dockerfile @@ -2,6 +2,8 @@ FROM php:7.4-fpm WORKDIR /var/www/html +RUN pecl install xdebug-2.9.8 && docker-php-ext-enable xdebug + RUN docker-php-ext-install pdo pdo_mysql RUN apt-get update && apt-get install -y \ @@ -25,4 +27,15 @@ RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - RUN apt-get -y install nodejs RUN chown -R www-data:www-data /var/www -RUN chmod 755 /var/www \ No newline at end of file +RUN chmod 755 /var/www + +# Configure xdebug +RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +RUN echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +RUN echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +RUN echo "xdebug.remote_port=9002" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +RUN echo "xdebug.idekey=VSCODE" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + +# Moved to docker-setup folder +# RUN echo 'pm.max_children = 15' >> /usr/local/etc/php-fpm.d/zz-docker.conf && \ +# echo 'pm.max_requests = 500' >> /usr/local/etc/php-fpm.d/zz-docker.conf diff --git a/docker-setup/docker-compose.yml b/docker-setup/docker-compose.yml index deb02207..9e33f109 100644 --- a/docker-setup/docker-compose.yml +++ b/docker-setup/docker-compose.yml @@ -44,6 +44,7 @@ services: container_name: exchange-php volumes: - ../:/var/www/html + - ./php/default.conf:/usr/local/etc/php-fpm.d/zz-docker.conf ports: - "9002:9000" networks: diff --git a/docker-setup/nginx/default.conf b/docker-setup/nginx/default.conf index b594e701..c1811261 100644 --- a/docker-setup/nginx/default.conf +++ b/docker-setup/nginx/default.conf @@ -23,6 +23,13 @@ server { fastcgi_intercept_errors on; fastcgi_keep_conn on; fastcgi_param PHP_VALUE "auto_prepend_file= \n allow_url_include=Off"; + + # Xdebug configuration + # fastcgi_param XDEBUG_MODE debug; + # fastcgi_param XDEBUG_CLIENT_HOST host.docker.internal; + # fastcgi_param XDEBUG_CLIENT_PORT 9002; + # fastcgi_param XDEBUG_IDE_KEY VSCODE; + proxy_send_timeout 3600; proxy_read_timeout 3600; fastcgi_send_timeout 3600; diff --git a/docker-setup/php/default.conf b/docker-setup/php/default.conf new file mode 100644 index 00000000..dced3233 --- /dev/null +++ b/docker-setup/php/default.conf @@ -0,0 +1,8 @@ +[global] +daemonize = no + +[www] +listen = 9000 + +pm.max_children = 15 +pm.max_requests = 500 diff --git a/package.json b/package.json index 5d4b92bf..68b4b646 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "jquery": "^3.2", "jquery.scrollbar": "^0.2.11", "jwt-decode": "^3.1.2", + "laravel-vapor": "^0.6.0", "noty": "^3.2.0-beta", "perfect-scrollbar": "^1.5.0", "popper.js": "^1.12", diff --git a/resources/assets/vue/app.js b/resources/assets/vue/app.js index abb7a17e..f2aba812 100644 --- a/resources/assets/vue/app.js +++ b/resources/assets/vue/app.js @@ -28,6 +28,10 @@ import { debounce } from 'vue-debounce' import Avatar from 'vue-avatar'; +import Vapor from 'laravel-vapor'; +// Vapor.withBaseAssetUrl(import.meta.env.VITE_VAPOR_ASSET_URL); +window.Vapor = Vapor; + /** Application Injections */ Vue.use(vuelidate); Vue.use(VueTheMask); @@ -36,7 +40,8 @@ Vue.use(filters); Vue.directive('closable', closable); Vue.mixin({ methods: { - route: route + route: route, + asset: window.Vapor.asset }, mixins: [request, crudHandler] }); diff --git a/resources/assets/vue/components/accounts/sections/OnboardingSectionComponent.vue b/resources/assets/vue/components/accounts/sections/OnboardingSectionComponent.vue index 5f2fb8e9..f41485f7 100644 --- a/resources/assets/vue/components/accounts/sections/OnboardingSectionComponent.vue +++ b/resources/assets/vue/components/accounts/sections/OnboardingSectionComponent.vue @@ -13,7 +13,7 @@
+
+ Session: {{ session('image') }}
+check1: {{ session('check1') }}
+check2: {{ session('check2') }}
+check3: {{ session('check3') }}
+ @if ($message = session('success')) +