update docker

This commit is contained in:
Kai Ton 2024-02-24 01:55:21 +00:00
parent 67c2504bfa
commit b7b4bc763e
5 changed files with 45 additions and 18 deletions

1
.env Normal file
View File

@ -0,0 +1 @@
VERSION=1

View File

@ -1,6 +1,6 @@
version : '3' version : '3'
name: laravel-rabbitmq name: laravel-rabbitmq${VERSION}
networks: networks:
laravel: laravel:
@ -13,14 +13,14 @@ services:
- ./src:/app - ./src:/app
command: "sh /app/laravel-entrypoint.sh" command: "sh /app/laravel-entrypoint.sh"
ports: ports:
- 1000:8000 - 100${VERSION}:8000
- 1001:8001
networks: networks:
- laravel - laravel
depends_on: depends_on:
- redis - redis
puppeteer: puppeteer:
container_name: puppeteer
build: build:
context: ./.docker/puppeteer context: ./.docker/puppeteer
dockerfile: Dockerfile dockerfile: Dockerfile
@ -29,6 +29,7 @@ services:
- laravel - laravel
socketio: socketio:
container_name: socketio
build: build:
context: ./.docker/socketio context: ./.docker/socketio
dockerfile: Dockerfile dockerfile: Dockerfile
@ -39,9 +40,8 @@ services:
redis: redis:
image: redis image: redis
container_name: redis
ports: ports:
- "6379:6379" - ":6379"
networks: networks:
- laravel - laravel

View File

@ -0,0 +1,33 @@
<?php
namespace App\Console\Commands;
use App\Jobs\ScreenshotJob;
use Illuminate\Console\Command;
class JobRun extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'job:run';
/**
* The console command description.
*
* @var string
*/
protected $description = '';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
dispatch(new ScreenshotJob);
}
}

View File

@ -9,7 +9,7 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
class ProcessJob implements ShouldQueue class ScreenshotJob implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
@ -21,7 +21,7 @@ class ProcessJob implements ShouldQueue
*/ */
public function __construct() public function __construct()
{ {
$process = 'process' . rand(1, 3); $process = 'process' . random_int(1, 3);
$this->process = $process; $this->process = $process;
$this->onQueue($process); $this->onQueue($process);
} }
@ -33,6 +33,9 @@ class ProcessJob implements ShouldQueue
*/ */
public function handle() public function handle()
{ {
var_dump('hello world'); file_put_contents(
public_path('pupeteer/' . time() . '.jpg'),
file_get_contents('http://puppeteer:4000?url=' . 'https://payment.nswteam.net/')
);
} }
} }

View File

@ -21,13 +21,3 @@ Route::get('/', function () {
}); });
Route::view('/queue', 'queue'); Route::view('/queue', 'queue');
Route::get('/pupeteer', function (Request $request) {
file_put_contents(
public_path('pupeteer/' . time() . '.jpg'),
file_get_contents('http://puppeteer:4000?url=' . $request->input('url'))
);
return dump(
glob(public_path('pupeteer/*'))
);
});