Compare commits

..

1 Commits

Author SHA1 Message Date
ccd2de26df Merge pull request 'install fresh laravel 13' (#1) from develop into main
Reviewed-on: #1
2026-04-26 11:55:45 +00:00
35 changed files with 99 additions and 1713 deletions

View File

@@ -1,36 +1,28 @@
FROM php:8.5.3-fpm-alpine3.23 FROM docker.arvancloud.ir/dunglas/frankenphp:1.11.2-php8.5-trixie
# Install common PHP extension dependencies RUN apt-get update \
RUN apk update && apk add --no-cache \ && apt-get install -y --no-install-recommends libpq-dev \
bash \
curl \
libpng \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
libwebp-dev \
libxml2-dev \
unzip \ unzip \
libzip-dev \ zip \
libpq-dev \ && install-php-extensions pdo_pgsql pgsql \
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \ && apt-get clean \
&& docker-php-ext-install pdo_pgsql gd zip && rm -rf /var/lib/apt/lists/*
# Set the working directory
WORKDIR /var/www/payment WORKDIR /var/www/payment
#ENV SERVER_NAME=your-domain-name.example.com
# Copy Laravel application
COPY . . COPY . .
RUN chmod -R 775 /var/www/payment/storage /var/www/payment/bootstrap/cache # Give permissions to storage and bootstrap/cache
RUN chmod -R 777 storage bootstrap/cache
# Install Composer # Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer COPY --from=docker.arvancloud.ir/composer:latest /usr/bin/composer /usr/bin/composer
ENV COMPOSER_ALLOW_SUPERUSER=1
# Default command CMD composer install;\
CMD composer install ;\ php artisan key:generate;\
composer dump-autoload --optimize --classmap-authoritative ;\ php artisan migrate;\
php artisan key:generate ;\ php artisan db:seed;\
php artisan migrate ;\ frankenphp php-server -r public/
php artisan db:seed ;\
php-fpm

View File

@@ -14,28 +14,19 @@ COPY . .
RUN composer dump-autoload --optimize --classmap-authoritative RUN composer dump-autoload --optimize --classmap-authoritative
FROM php:8.5.3-fpm-alpine3.23 AS application FROM docker.arvancloud.ir/dunglas/frankenphp:1.11.2-php8.5-trixie AS application
RUN apk update && apk add --no-cache \ RUN apt-get update \
bash \ && apt-get install -y --no-install-recommends libpq-dev unzip zip \
curl \ && install-php-extensions pdo_pgsql pgsql \
libpng \ && apt-get clean \
libpng-dev \ && rm -rf /var/lib/apt/lists/*
libjpeg-turbo-dev \
freetype-dev \
libwebp-dev \
libxml2-dev \
unzip \
libzip-dev \
libpq-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install pdo_pgsql gd zip
WORKDIR /var/www/payment WORKDIR /var/www/payment
COPY --from=builder /app /var/www/payment COPY --from=builder /app /var/www/payment
RUN chown -R www-data:www-data /var/www/payment \ RUN chown -R www-data:www-data /var/www/payment \
&& chmod -R 665 storage bootstrap/cache && chmod -R 775 storage bootstrap/cache
CMD ["php-fpm"] CMD ["frankenphp", "php-server", "-r", "public/"]

View File

@@ -9,14 +9,13 @@ use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;
#[Fillable(['name', 'email', 'password'])] #[Fillable(['name', 'email', 'password'])]
#[Hidden(['password', 'remember_token'])] #[Hidden(['password', 'remember_token'])]
class User extends Authenticatable class User extends Authenticatable
{ {
/** @use HasFactory<UserFactory> */ /** @use HasFactory<UserFactory> */
use HasFactory, Notifiable, HasApiTokens; use HasFactory, Notifiable;
/** /**
* Get the attributes that should be cast. * Get the attributes that should be cast.

View File

@@ -3,7 +3,6 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Laravel\Passport\Passport;
class AppServiceProvider extends ServiceProvider class AppServiceProvider extends ServiceProvider
{ {
@@ -20,6 +19,6 @@ class AppServiceProvider extends ServiceProvider
*/ */
public function boot(): void public function boot(): void
{ {
Passport::enablePasswordGrant(); //
} }
} }

View File

@@ -1,62 +0,0 @@
<?php
namespace App\User\Services\FIB;
use Exception;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class AuthorizationService
{
protected string $url;
protected string $channelName;
protected array $inputParameters;
public function __construct()
{
$this->url = config('fib.authorization.url');
$this->channelName = '';
}
public function setInputParameters(): void
{
$this->inputParameters = [
'client_id' => config('fib.authorization.client_id'),
'client_secret' => config('fib.authorization.client_secret'),
'grant_type' => 'client_credentials',
];
}
/**
* @throws Exception
*/
public function run(): array
{
try {
return $this->sendRequest();
}
catch (Exception $e) {
Log::channel($this->channelName)
->error(get_class($this),
[
'message' => $e->getMessage(),
]
);
throw $e;
}
}
/**
* @throws ConnectionException
*/
public function sendRequest(): array
{
return Http::withHeaders(['Content-Type' => 'application/json'])
->throw()
->withoutVerifying()
->post($this->url, $this->inputParameters)
->json();
}
}

View File

@@ -1,62 +0,0 @@
<?php
namespace App\User\Services\FIB;
use Exception;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class CancelPaymentService
{
protected string $url;
protected string $channelName;
protected string $accessToken;
protected array $headers;
public function __construct()
{
$this->url = config('fib.cancelPayment.url');
$this->channelName = '';
}
public function setHeaders(): void
{
$this->headers = [
'Authorization' => 'Bearer ' . $this->accessToken,
'Content-Type' => 'application/json',
];
}
/**
* @throws Exception
*/
public function run(): array
{
try {
return $this->sendRequest();
}
catch (Exception $e) {
Log::channel($this->channelName)
->error(get_class($this),
[
'message' => $e->getMessage(),
]
);
throw $e;
}
}
/**
* @throws ConnectionException
*/
public function sendRequest(): array
{
return Http::withHeaders($this->headers)
->throw()
->withoutVerifying()
->post($this->url)
->json();
}
}

View File

@@ -1,51 +0,0 @@
<?php
namespace App\User\Services\FIB;
use Exception;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class CheckPaymentStatusService
{
protected string $url;
protected string $channelName;
public function __construct()
{
$this->url = config('fib.checkPaymentStatus.url');
$this->channelName = '';
}
/**
* @throws Exception
*/
public function run(): array
{
try {
return $this->sendRequest();
}
catch (Exception $e) {
Log::channel($this->channelName)
->error(get_class($this),
[
'message' => $e->getMessage(),
]
);
throw $e;
}
}
/**
* @throws ConnectionException
*/
public function sendRequest(): array
{
return Http::throw()
->withoutVerifying()
->post($this->url)
->json();
}
}

View File

@@ -1,73 +0,0 @@
<?php
namespace App\User\Services\FIB;
use Exception;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class CreatePaymentService
{
protected string $url;
protected string $channelName;
protected string $accessToken;
protected array $headers;
protected array $inputParameters;
public function __construct()
{
$this->url = config('fib.createPayment.url');
$this->channelName = '';
}
public function setAccessToken(string $accessToken): void
{
$this->accessToken = $accessToken;
}
public function setHeaders(): void
{
$this->headers = [
'Authorization' => 'Bearer ' . $this->accessToken,
'Content-Type' => 'application/json',
];
}
public function setInputParameters(array $inputParameters): void
{
$this->inputParameters = $inputParameters;
}
/**
* @throws Exception
*/
public function run(): array
{
try {
return $this->sendRequest();
}
catch (Exception $e) {
Log::channel($this->channelName)
->error(get_class($this),
[
'message' => $e->getMessage(),
]
);
throw $e;
}
}
/**
* @throws ConnectionException
*/
public function sendRequest(): array
{
return Http::withHeaders($this->headers)
->throw()
->withoutVerifying()
->post($this->url, $this->inputParameters)
->json();
}
}

View File

@@ -1,62 +0,0 @@
<?php
namespace App\User\Services\FIB;
use Exception;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class RefundService
{
protected string $url;
protected string $channelName;
protected string $accessToken;
protected array $headers;
public function __construct()
{
$this->url = config('fib.refund.url');
$this->channelName = '';
}
public function setHeaders(): void
{
$this->headers = [
'Authorization' => 'Bearer ' . $this->accessToken,
'Content-Type' => 'application/json',
];
}
/**
* @throws Exception
*/
public function run(): array
{
try {
return $this->sendRequest();
}
catch (Exception $e) {
Log::channel($this->channelName)
->error(get_class($this),
[
'message' => $e->getMessage(),
]
);
throw $e;
}
}
/**
* @throws ConnectionException
*/
public function sendRequest(): array
{
return Http::withHeaders($this->headers)
->throw()
->withoutVerifying()
->post($this->url)
->json();
}
}

View File

@@ -7,7 +7,6 @@ use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__)) return Application::configure(basePath: dirname(__DIR__))
->withRouting( ->withRouting(
web: __DIR__.'/../routes/web.php', web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php', commands: __DIR__.'/../routes/console.php',
health: '/up', health: '/up',
) )

0
backend/bootstrap/cache/.gitignore vendored Executable file → Normal file
View File

View File

@@ -11,7 +11,6 @@
"require": { "require": {
"php": "^8.3", "php": "^8.3",
"laravel/framework": "^13.0", "laravel/framework": "^13.0",
"laravel/passport": "^13.0",
"laravel/tinker": "^3.0" "laravel/tinker": "^3.0"
}, },
"require-dev": { "require-dev": {
@@ -87,4 +86,4 @@
}, },
"minimum-stability": "stable", "minimum-stability": "stable",
"prefer-stable": true "prefer-stable": true
} }

1010
backend/composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -42,10 +42,6 @@ return [
'driver' => 'session', 'driver' => 'session',
'provider' => 'users', 'provider' => 'users',
], ],
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
], ],
/* /*

View File

@@ -1,25 +0,0 @@
<?php
return [
'authorization' => [
'url' => env('FIB_AUTHORIZATION_URL'),
'client_id' => env('FIB_CLIENT_ID'),
'client_secret' => env('FIB_CLIENT_SECRET'),
],
'createPayment' => [
'url' => env('FIB_CREATE_PAYMENT_URL'),
],
'checkPaymentStatus' => [
'url' => env('FIB_CHECK_PAYMENT_STATUS_URL'),
],
'cancelPayment' => [
'url' => env('FIB_CANCEL_PAYMENT_URL'),
],
'refund' => [
'url' => env('FIB_REFUND_URL'),
],
];

View File

@@ -1,48 +0,0 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Passport Guard
|--------------------------------------------------------------------------
|
| Here you may specify which authentication guard Passport will use when
| authenticating users. This value should correspond with one of your
| guards that is already present in your "auth" configuration file.
|
*/
'guard' => 'web',
'middleware' => [],
/*
|--------------------------------------------------------------------------
| Encryption Keys
|--------------------------------------------------------------------------
|
| Passport uses encryption keys while generating secure access tokens for
| your application. By default, the keys are stored as local files but
| can be set via environment variables when that is more convenient.
|
*/
'private_key' => env('PASSPORT_PRIVATE_KEY'),
'public_key' => env('PASSPORT_PUBLIC_KEY'),
/*
|--------------------------------------------------------------------------
| Passport Database Connection
|--------------------------------------------------------------------------
|
| By default, Passport's models will utilize your application's default
| database connection. If you wish to use a different connection you
| may specify the configured name of the database connection here.
|
*/
'connection' => env('PASSPORT_CONNECTION'),
];

View File

@@ -1,39 +0,0 @@
<?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('oauth_auth_codes', function (Blueprint $table) {
$table->char('id', 80)->primary();
$table->foreignId('user_id')->index();
$table->foreignUuid('client_id');
$table->text('scopes')->nullable();
$table->boolean('revoked');
$table->dateTime('expires_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('oauth_auth_codes');
}
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return $this->connection ?? config('passport.connection');
}
};

View File

@@ -1,41 +0,0 @@
<?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('oauth_access_tokens', function (Blueprint $table) {
$table->char('id', 80)->primary();
$table->foreignId('user_id')->nullable()->index();
$table->foreignUuid('client_id');
$table->string('name')->nullable();
$table->text('scopes')->nullable();
$table->boolean('revoked');
$table->timestamps();
$table->dateTime('expires_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('oauth_access_tokens');
}
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return $this->connection ?? config('passport.connection');
}
};

View File

@@ -1,37 +0,0 @@
<?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('oauth_refresh_tokens', function (Blueprint $table) {
$table->char('id', 80)->primary();
$table->char('access_token_id', 80)->index();
$table->boolean('revoked');
$table->dateTime('expires_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('oauth_refresh_tokens');
}
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return $this->connection ?? config('passport.connection');
}
};

View File

@@ -1,42 +0,0 @@
<?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('oauth_clients', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->nullableMorphs('owner');
$table->string('name');
$table->string('secret')->nullable();
$table->string('provider')->nullable();
$table->text('redirect_uris');
$table->text('grant_types');
$table->boolean('revoked');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('oauth_clients');
}
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return $this->connection ?? config('passport.connection');
}
};

View File

@@ -1,42 +0,0 @@
<?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('oauth_device_codes', function (Blueprint $table) {
$table->char('id', 80)->primary();
$table->foreignId('user_id')->nullable()->index();
$table->foreignUuid('client_id')->index();
$table->char('user_code', 8)->unique();
$table->text('scopes');
$table->boolean('revoked');
$table->dateTime('user_approved_at')->nullable();
$table->dateTime('last_polled_at')->nullable();
$table->dateTime('expires_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('oauth_device_codes');
}
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return $this->connection ?? config('passport.connection');
}
};

View File

@@ -1,8 +0,0 @@
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::get('/user', function (Request $request) {
return $request->user();
})->middleware('auth:api');

0
backend/storage/app/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/app/private/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/app/public/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/framework/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/framework/cache/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/framework/cache/data/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/framework/sessions/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/framework/testing/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/framework/views/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/logs/.gitignore vendored Executable file → Normal file
View File

View File

@@ -0,0 +1,60 @@
services:
postgres:
image: docker.arvancloud.ir/postgres:17.8-alpine3.23
container_name: pgsql
restart: unless-stopped
ports:
- "8091:5432"
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- payment-db:/var/lib/postgresql/data
networks:
- payment
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 30s
timeout: 10s
retries: 3
backend:
build:
context: ${BACKEND_PATH}
dockerfile: Dockerfile.production
container_name: laravel
tty: true
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80"]
interval: 30s
timeout: 10s
retries: 3
ports:
- "8003:80"
- "443:443"
- "443:443/udp"
volumes:
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
depends_on:
- postgres
networks:
- payment
logging:
driver: "syslog"
options:
syslog-address: "tcp://host.docker.internal:514"
tag: "laravel-backend"
syslog-facility: "daemon"
max-size: "10m"
mem_limit: 512M
cpus: 1
volumes:
payment-db:
driver: local
networks:
payment:
driver: bridge

View File

@@ -1,39 +1,14 @@
services: services:
nginx:
image: nginx:stable-alpine3.23-perl
container_name: nginx
restart: unless-stopped
ports:
- "8000:80"
volumes:
- ./nginx/payment.conf:/etc/nginx/conf.d/default.conf
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
networks:
- payment
redis:
image: redis:8.6.0-alpine3.23
container_name: redis
restart: unless-stopped
tty: true
networks:
- payment
postgres: postgres:
image: postgres:18.2-alpine3.23 image: docker.arvancloud.ir/postgres:17.8-alpine3.23
container_name: payment-db container_name: pgsql
restart: unless-stopped restart: unless-stopped
ports: ports:
- "8092:5432" - "8091:5432"
environment: environment:
POSTGRES_DB: ${POSTGRES_DB} POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER} POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
interval: 30s
timeout: 10s
retries: 3
volumes: volumes:
- payment-db:/var/lib/postgresql/data - payment-db:/var/lib/postgresql/data
networks: networks:
@@ -47,22 +22,17 @@ services:
tty: true tty: true
restart: unless-stopped restart: unless-stopped
ports: ports:
- "9000:9000" - "8003:80"
- "443:443"
- "443:443/udp"
volumes: volumes:
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME} - ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
# - caddy_data:/data
# - caddy_config:/config
depends_on: depends_on:
- postgres - postgres
networks: networks:
- payment - payment
# logging:
# driver: "syslog"
# options:
# syslog-address: "tcp://host.docker.internal:514"
# tag: "laravel-backend"
# syslog-facility: "daemon"
# max-size: "10m"
# mem_limit: 512M
# cpus: 1
volumes: volumes:
payment-db: payment-db:

View File

@@ -1,21 +0,0 @@
server {
listen 80;
listen [::]:80;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ ^/index\.php(/|$) {
include fastcgi_params;
fastcgi_pass laravel:9000;
fastcgi_index index.php;
fastcgi_hide_header X-Powered-By;
fastcgi_param SCRIPT_FILENAME /var/www/payment/public/index.php;
}
location ~ /\.(?!well-known).* {
deny all;
}
}