From ce9beb499b73b59f2dfa95a47ae430849b67b538 Mon Sep 17 00:00:00 2001 From: armiejean Date: Thu, 1 May 2025 20:21:14 +0800 Subject: [PATCH] integration --- .env | 7 +- app/User.php | 2 +- composer.json | 4 +- composer.lock | 157 +++++++++++++++++- config/cors.php | 11 ++ config/database.php | 4 +- ...025_05_01_001624_create_sessions_table.php | 31 ++++ docker-compose.yml | 25 ++- docker/nginx/default.conf | 3 +- 9 files changed, 228 insertions(+), 16 deletions(-) create mode 100644 database/migrations/2025_05_01_001624_create_sessions_table.php diff --git a/.env b/.env index be8f317..bfa228c 100755 --- a/.env +++ b/.env @@ -3,7 +3,8 @@ APP_ENV=local APP_KEY=base64:0gU9IIArwNb9IW4nkiuN72zGhw0YrtIVZnM7WJxxD88= APP_DEBUG=true -APP_URL=http://localhost +APP_URL=http://localhost:8080 +CACHE_DRIVER=file LOG_CHANNEL=stack @@ -11,8 +12,8 @@ DB_CONNECTION=mysql DB_HOST=db_mysql DB_PORT=3306 DB_DATABASE=unioil-app -DB_USERNAME=rootuser -DB_PASSWORD=password +DB_USERNAME=root +DB_PASSWORD=secret BROADCAST_DRIVER=log CACHE_DRIVER=file diff --git a/app/User.php b/app/User.php index 6ea77b3..ec20f60 100755 --- a/app/User.php +++ b/app/User.php @@ -17,7 +17,7 @@ class User extends Authenticatable * @var array */ protected $fillable = [ - 'name', 'username', 'password', + 'username', 'password', ]; /** diff --git a/composer.json b/composer.json index e04ce44..7c7d7f0 100755 --- a/composer.json +++ b/composer.json @@ -18,10 +18,10 @@ "ramsey/uuid": "^4.0" }, "require-dev": { + "barryvdh/laravel-debugbar": "*", "filp/whoops": "^2.0", "mockery/mockery": "^1.0", - - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^9.5" }, "autoload": { "classmap": [ diff --git a/composer.lock b/composer.lock index c1f3faa..f0e4a29 100755 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bc71384c96b6ef778329bba877dc6286", + "content-hash": "164eb521f6532569af3ca75079ec4478", "packages": [ { "name": "aws/aws-crt-php", @@ -7715,6 +7715,91 @@ } ], "packages-dev": [ + { + "name": "barryvdh/laravel-debugbar", + "version": "v3.15.4", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "c0667ea91f7185f1e074402c5788195e96bf8106" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/c0667ea91f7185f1e074402c5788195e96bf8106", + "reference": "c0667ea91f7185f1e074402c5788195e96bf8106", + "shasum": "" + }, + "require": { + "illuminate/routing": "^9|^10|^11|^12", + "illuminate/session": "^9|^10|^11|^12", + "illuminate/support": "^9|^10|^11|^12", + "php": "^8.1", + "php-debugbar/php-debugbar": "~2.1.1", + "symfony/finder": "^6|^7" + }, + "require-dev": { + "mockery/mockery": "^1.3.3", + "orchestra/testbench-dusk": "^7|^8|^9|^10", + "phpunit/phpunit": "^9.5.10|^10|^11", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar" + }, + "providers": [ + "Barryvdh\\Debugbar\\ServiceProvider" + ] + }, + "branch-alias": { + "dev-master": "3.15-dev" + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "dev", + "laravel", + "profiler", + "webprofiler" + ], + "support": { + "issues": "https://github.com/barryvdh/laravel-debugbar/issues", + "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.15.4" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2025-04-16T06:32:06+00:00" + }, { "name": "doctrine/instantiator", "version": "2.0.0", @@ -8168,6 +8253,76 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "php-debugbar/php-debugbar", + "version": "v2.1.6", + "source": { + "type": "git", + "url": "https://github.com/php-debugbar/php-debugbar.git", + "reference": "16fa68da5617220594aa5e33fa9de415f94784a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-debugbar/php-debugbar/zipball/16fa68da5617220594aa5e33fa9de415f94784a0", + "reference": "16fa68da5617220594aa5e33fa9de415f94784a0", + "shasum": "" + }, + "require": { + "php": "^8", + "psr/log": "^1|^2|^3", + "symfony/var-dumper": "^4|^5|^6|^7" + }, + "require-dev": { + "dbrekelmans/bdi": "^1", + "phpunit/phpunit": "^8|^9", + "symfony/panther": "^1|^2.1", + "twig/twig": "^1.38|^2.7|^3.0" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "DebugBar\\": "src/DebugBar/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/php-debugbar/php-debugbar", + "keywords": [ + "debug", + "debug bar", + "debugbar", + "dev" + ], + "support": { + "issues": "https://github.com/php-debugbar/php-debugbar/issues", + "source": "https://github.com/php-debugbar/php-debugbar/tree/v2.1.6" + }, + "time": "2025-02-21T17:47:03+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.32", diff --git a/config/cors.php b/config/cors.php index 8aecc78..5c34a18 100755 --- a/config/cors.php +++ b/config/cors.php @@ -20,4 +20,15 @@ return [ 'exposedHeaders' => ['Content-Disposition'], 'maxAge' => 0, + + 'paths' => ['api/*'], + 'allowed_methods' => ['*'], + 'allowed_origins' => ['http://localhost:8000', '*'], // Add '*' for Postman testing + 'allowed_origins_patterns' => [], + 'allowed_headers' => ['*'], + 'exposed_headers' => [], + 'max_age' => 0, + 'supports_credentials' => false, + + ]; diff --git a/config/database.php b/config/database.php index 89869f1..2ce5251 100755 --- a/config/database.php +++ b/config/database.php @@ -44,8 +44,8 @@ return [ 'host' => env('DB_HOST', 'db_mysql'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'unioil-app'), - 'username' => env('DB_USERNAME', 'rootuser'), - 'password' => env('DB_PASSWORD', 'password'), + 'username' => env('DB_USERNAME', 'root'), + 'password' => env('DB_PASSWORD', 'secret'), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', diff --git a/database/migrations/2025_05_01_001624_create_sessions_table.php b/database/migrations/2025_05_01_001624_create_sessions_table.php new file mode 100644 index 0000000..f60625b --- /dev/null +++ b/database/migrations/2025_05_01_001624_create_sessions_table.php @@ -0,0 +1,31 @@ +string('id')->primary(); + $table->foreignId('user_id')->nullable()->index(); + $table->string('ip_address', 45)->nullable(); + $table->text('user_agent')->nullable(); + $table->longText('payload'); + $table->integer('last_activity')->index(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('sessions'); + } +}; diff --git a/docker-compose.yml b/docker-compose.yml index 15c1855..192a1e9 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,12 @@ services: db_mysql: condition: service_healthy command: > - /bin/sh -c ' mkdir -p /var/www/storage /var/www/bootstrap/cache && chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache && chmod -R 775 /var/www/storage /var/www/bootstrap/cache && composer install --no-dev --optimize-autoloader && php artisan migrate --force && php-fpm ' + /bin/sh -c 'mkdir -p /var/www/storage /var/www/bootstrap/cache && + chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache && + chmod -R 775 /var/www/storage /var/www/bootstrap/cache && + composer install --no-dev --optimize-autoloader && + php artisan migrate --force && + php-fpm' healthcheck: test: [ "CMD", "sh", "-c", "pgrep php-fpm" ] interval: 30s @@ -23,18 +28,23 @@ services: retries: 10 networks: - app_network + environment: + - DB_HOST=db_mysql + - DB_PORT=3306 + - DB_DATABASE=unioil-app + - DB_USERNAME=root + - DB_PASSWORD=secret # MySQL db_mysql: image: mysql:8.0 - container_name: db + container_name: db_mysql restart: always environment: MYSQL_ROOT_PASSWORD: newpassword MYSQL_DATABASE: unioil-app - MYSQL_USER: rootuser - MYSQL_PASSWORD: password - MYSQL_ALLOW_EMPTY_PASSWORD: "no" + MYSQL_USER: root + MYSQL_PASSWORD: secret volumes: - mysql-data:/var/lib/mysql healthcheck: @@ -48,10 +58,12 @@ services: # Nginx web: image: nginx:1.26.3-alpine - container_name: web-unioil + container_name: web restart: always ports: - "8080:80" + expose: + - "80" volumes: - .:/var/www - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:rw @@ -72,4 +84,5 @@ volumes: networks: app_network: + external: true driver: bridge diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf index 843df3b..e6308c1 100755 --- a/docker/nginx/default.conf +++ b/docker/nginx/default.conf @@ -1,3 +1,4 @@ +# backend/docker/nginx/default.conf server { listen 80; server_name localhost; @@ -12,7 +13,7 @@ server { location ~ \.php$ { try_files $uri =404; include fastcgi.conf; - fastcgi_pass app:9000; + fastcgi_pass laravel:9000; # Matches backend's 'app' service renamed to 'laravel' fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root;