integration

This commit is contained in:
armiejean 2025-05-01 20:21:14 +08:00
parent 1a89d73886
commit ce9beb499b
9 changed files with 228 additions and 16 deletions

7
.env
View File

@ -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

View File

@ -17,7 +17,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name', 'username', 'password',
'username', 'password',
];
/**

View File

@ -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": [

157
composer.lock generated
View File

@ -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",

View File

@ -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,
];

View File

@ -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',

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('sessions', function (Blueprint $table) {
$table->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');
}
};

View File

@ -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

View File

@ -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;