From 9a65d109e799a5a830f6a804a77c267ca0fd4a08 Mon Sep 17 00:00:00 2001 From: ISMAIL MASSERAN Date: Wed, 22 Apr 2026 12:44:16 +0800 Subject: [PATCH] DO NOT PR THIS BRANCHgit add .!; DONE: add docker config for development --- .dockerignore | 11 ++++ .env.docker | 66 ++++++++++++++++++++++++ .gitignore | 2 +- README.md | 16 ++++++ bootstrap/app.php | 28 +++++++++++ config/app_parameter.php | 2 +- config/logging.php | 103 ++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 39 +++++++++++++++ docker/nginx/default.conf | 26 ++++++++++ docker/php/Dockerfile | 30 +++++++++++ docker/php/php.ini | 4 ++ 11 files changed, 325 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 .env.docker create mode 100644 config/logging.php create mode 100644 docker-compose.yml create mode 100644 docker/nginx/default.conf create mode 100644 docker/php/Dockerfile create mode 100644 docker/php/php.ini diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f9530f2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.git +node_modules +vendor +storage/logs +storage/framework/cache +storage/framework/sessions +storage/framework/views +storage/debugbar +npm-debug.log +Dockerfile +docker-compose.yml diff --git a/.env.docker b/.env.docker new file mode 100644 index 0000000..fedbeed --- /dev/null +++ b/.env.docker @@ -0,0 +1,66 @@ +APP_NAME=Lumen +APP_ENV=local +APP_KEY=WbPGkYNmXZ6ZQplGlvl0iZ7zyW1b09xa +APP_DEBUG=true +APP_URL=http://localhost +APP_TIMEZONE=Asia/Kuala_Lumpur + +LOG_CHANNEL=stack +LOG_LEVEL=debug +LOG_SLACK_WEBHOOK_URL= + +DB_CONNECTION=mysql +DB_HOST=mysql +DB_PORT=3306 +DB_DATABASE=erahn_xtra +DB_USERNAME=root +DB_PASSWORD=root + +DB_CONNECTION_7=mysql +DB_HOST_7=mysql +DB_PORT_7=3306 +DB_DATABASE_7=master_erahn +DB_USERNAME_7=root +DB_PASSWORD_7=root + +# DB_CONNECTION_3=mysql +# DB_HOST_3=127.0.0.1 +# DB_PORT_3=3306 +# DB_DATABASE_3=erahn_baling +# DB_USERNAME_3=root +# DB_PASSWORD_3=root + +# DB_CONNECTION_4=mysql +# DB_HOST_4=127.0.0.1 +# DB_PORT_4=3306 +# DB_DATABASE_4=arrahn_ld +# DB_USERNAME_4=root +# DB_PASSWORD_4=root + +# DB_CONNECTION_5=mysql +# DB_HOST_5=127.0.0.1 +# DB_PORT_5=3306 +# DB_DATABASE_5=erahn_segamat +# DB_USERNAME_5=root +# DB_PASSWORD_5=root + +# DB_CONNECTION_6=mysql +# DB_HOST_6=127.0.0.1 +# DB_PORT_6=3306 +# DB_DATABASE_6=arrahn_kb2 +# DB_USERNAME_6=spider +# DB_PASSWORD_6=G0dz!ll42020 + + +# DB_CONNECTION_8=mysql +# DB_HOST_8=127.0.0.1 +# DB_PORT_8=3306 +# DB_DATABASE_8=arrahn_klanas +# DB_USERNAME_8=spider +# DB_PASSWORD_8=G0dz!ll42020 + +TENNANT_MASTER_DB=master_erahn +TENNANT_KAUNTER_DB=kaunter_erahn + +CACHE_DRIVER=file +QUEUE_CONNECTION=sync \ No newline at end of file diff --git a/.gitignore b/.gitignore index 39329cd..89ac166 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,6 @@ Homestead.yaml .env .phpunit.result.cache ray.php -docker-compose.yml /docker_src /.vscode +**/.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index ac83c8d..3b1ebc0 100644 --- a/README.md +++ b/README.md @@ -1 +1,17 @@ You know what is this when you in this project + +If you does't know what is this you probably in wrong project + +```sql +--- for all ip +CREATE USER 'master_erahn'@'%' IDENTIFIED BY 'password'; + +--- for specific ip +CREATE USER 'kaunter_erahn'@'localhost' IDENTIFIED BY 'password'; + +GRANT ALL PRIVILEGES ON kaunter_erahn.* TO 'kaunter_erahn'@'%'; +FLUSH PRIVILEGES; +``` + +Gadai=Pembiayaan +Tebus=penyelesaian penuh/ansuran \ No newline at end of file diff --git a/bootstrap/app.php b/bootstrap/app.php index d358544..e5febcc 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -23,6 +23,33 @@ $app = new Laravel\Lumen\Application( dirname(__DIR__) ); +/* +| Laravel's storage_path() helper resolves app('path.storage'). Lumen does not +| register that binding by default; config files that call storage_path() at +| load time (e.g. config/logging.php) would fail without this. +*/ +$app->instance('path.storage', $app->storagePath()); + +/* +| Laravel's Foundation helpers are loaded before Lumen's and win for names like +| response() and url(). Those helpers resolve Illuminate\Contracts\* from the +| container; Lumen only registers the "url" service, not the contracts. Map the +| contracts to Lumen's implementations so helpers work across the app. +*/ +$app->singleton( + \Illuminate\Contracts\Routing\ResponseFactory::class, + function () { + return new \Laravel\Lumen\Http\ResponseFactory(); + } +); + +$app->singleton( + \Illuminate\Contracts\Routing\UrlGenerator::class, + function ($app) { + return $app->make('url'); + } +); + $app->withFacades(); $app->withEloquent(); @@ -60,6 +87,7 @@ $app->singleton( */ $app->configure('app'); +$app->configure('logging'); $app->configure('tinker'); $app->configure('tennant_database'); $app->configure('report'); diff --git a/config/app_parameter.php b/config/app_parameter.php index c46f175..b9b4014 100644 --- a/config/app_parameter.php +++ b/config/app_parameter.php @@ -1,7 +1,7 @@ env('APP_URL', url('/')), + 'url' => env('APP_URL', 'http://localhost'), 'api_arrahnbid' => env('API_ARRAHNBID', 'http://lelong.test/api/'), 'api_v3' => env('API_V3', 'http://apiv3.localhost/api/') ]; diff --git a/config/logging.php b/config/logging.php new file mode 100644 index 0000000..985406d --- /dev/null +++ b/config/logging.php @@ -0,0 +1,103 @@ + env('LOG_CHANNEL', 'stack'), + + /* + |-------------------------------------------------------------------------- + | Log Channels + |-------------------------------------------------------------------------- + | + | Here you may configure the log channels for your application. Out of + | the box, Laravel uses the Monolog PHP logging library. This gives + | you a variety of powerful log handlers / formatters to utilize. + | + | Available Drivers: "single", "daily", "slack", "syslog", + | "errorlog", "monolog", "custom", "stack" + | + */ + + 'channels' => [ + 'stack' => [ + 'driver' => 'stack', + 'channels' => ['single'], + 'ignore_exceptions' => false, + ], + + 'single' => [ + 'driver' => 'single', + 'path' => storage_path('logs/laravel.log'), + 'level' => env('LOG_LEVEL', 'debug'), + ], + + 'daily' => [ + 'driver' => 'daily', + 'path' => storage_path('logs/laravel.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'days' => 14, + ], + + 'slack' => [ + 'driver' => 'slack', + 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'username' => 'Laravel Log', + 'emoji' => ':boom:', + 'level' => env('LOG_LEVEL', 'critical'), + ], + + 'papertrail' => [ + 'driver' => 'monolog', + 'level' => env('LOG_LEVEL', 'debug'), + 'handler' => SyslogUdpHandler::class, + 'handler_with' => [ + 'host' => env('PAPERTRAIL_URL'), + 'port' => env('PAPERTRAIL_PORT'), + ], + ], + + 'stderr' => [ + 'driver' => 'monolog', + 'handler' => StreamHandler::class, + 'formatter' => env('LOG_STDERR_FORMATTER'), + 'with' => [ + 'stream' => 'php://stderr', + ], + ], + + 'syslog' => [ + 'driver' => 'syslog', + 'level' => env('LOG_LEVEL', 'debug'), + ], + + 'errorlog' => [ + 'driver' => 'errorlog', + 'level' => env('LOG_LEVEL', 'debug'), + ], + + 'null' => [ + 'driver' => 'monolog', + 'handler' => NullHandler::class, + ], + + 'emergency' => [ + 'path' => storage_path('logs/laravel.log'), + ], + ], + +]; diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d675b42 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,39 @@ +services: + app: + build: + context: . + dockerfile: docker/php/Dockerfile + working_dir: /var/www/html + volumes: + - ./:/var/www/html:cached + environment: + APP_ENV: local + APP_DEBUG: "true" + depends_on: + - mysql + + web: + image: nginx:1.25-alpine + ports: + - "8080:80" + volumes: + - ./:/var/www/html:cached + - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro + depends_on: + - app + + mysql: + image: mysql:8.0 + command: --default-authentication-plugin=mysql_native_password + ports: + - "3306:3306" + environment: + MYSQL_DATABASE: erahn_xtra + MYSQL_USER: xtrauser + MYSQL_PASSWORD: password + MYSQL_ROOT_PASSWORD: root + volumes: + - mysql_data:/var/lib/mysql + +volumes: + mysql_data: diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf new file mode 100644 index 0000000..8ad50f3 --- /dev/null +++ b/docker/nginx/default.conf @@ -0,0 +1,26 @@ +server { + listen 80; + server_name _; + + root /var/www/html/public; + index index.php index.html; + + charset utf-8; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_pass app:9000; + fastcgi_index index.php; + } + + location ~ /\.(?!well-known).* { + deny all; + } +} + diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile new file mode 100644 index 0000000..56727cf --- /dev/null +++ b/docker/php/Dockerfile @@ -0,0 +1,30 @@ +FROM php:7.4-fpm + +WORKDIR /var/www/html + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + git \ + pkg-config \ + unzip \ + libonig-dev \ + libzip-dev \ + libpng-dev \ + libjpeg62-turbo-dev \ + libfreetype6-dev \ + && docker-php-ext-configure gd --with-freetype --with-jpeg \ + && docker-php-ext-install -j"$(nproc)" \ + pdo_mysql \ + mbstring \ + bcmath \ + zip \ + exif \ + gd \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer + +COPY docker/php/php.ini /usr/local/etc/php/conf.d/app.ini + +RUN usermod -u 1000 www-data && groupmod -g 1000 www-data + diff --git a/docker/php/php.ini b/docker/php/php.ini new file mode 100644 index 0000000..ea34e43 --- /dev/null +++ b/docker/php/php.ini @@ -0,0 +1,4 @@ +memory_limit=512M +upload_max_filesize=50M +post_max_size=50M +max_execution_time=120 \ No newline at end of file