This commit is contained in:
f4ilji
2024-11-02 13:14:37 +05:00
parent 114819f36c
commit 34983efe79
11 changed files with 554 additions and 522 deletions
+1 -5
View File
@@ -28,9 +28,6 @@ RUN apt-get update && apt-get install -y zlib1g-dev libicu-dev g++
RUN docker-php-ext-configure intl RUN docker-php-ext-configure intl
RUN docker-php-ext-install intl RUN docker-php-ext-install intl
# Установка Supervisor
RUN apt-get update && apt-get install -y supervisor
# Копирование конфигурационного файла PHP # Копирование конфигурационного файла PHP
COPY ./_docker/app/php.ini /usr/local/etc/php/conf.d/php.ini COPY ./_docker/app/php.ini /usr/local/etc/php/conf.d/php.ini
@@ -38,8 +35,6 @@ COPY ./_docker/app/php.ini /usr/local/etc/php/conf.d/php.ini
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y nodejs npm RUN apt-get install -y nodejs npm
# Копирование конфигурации Supervisor
COPY ./_docker/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE 6001 EXPOSE 6001
EXPOSE 5173 EXPOSE 5173
@@ -50,3 +45,4 @@ RUN curl -sS https://getcomposer.org/installer | php -- \
--install-dir=/usr/local/bin --install-dir=/usr/local/bin
WORKDIR /var/www WORKDIR /var/www
+2 -3
View File
@@ -1,8 +1,7 @@
server { server {
client_max_body_size 200M; client_max_body_size 200M;
large_client_header_buffers 8 256k; large_client_header_buffers 4 128k;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
root /var/www/public; root /var/www/public;
location / { location / {
+21
View File
@@ -0,0 +1,21 @@
FROM php:8.2-fpm
# Установка Supervisor и необходимых пакетов
RUN apt-get update && \
apt-get install -y supervisor curl gnupg2 && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Копирование конфигурации Supervisor
COPY ./_docker/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Установка рабочего каталога
WORKDIR /var/www
EXPOSE 13714
# Команда для запуска Supervisor
CMD ["/usr/bin/supervisord"]
+4 -6
View File
@@ -1,7 +1,7 @@
[supervisord] [supervisord]
nodaemon=true nodaemon=true
[program:laravel-worker] [program:laravel-queue]
process_name=%(program_name)s_%(process_num)02d process_name=%(program_name)s_%(process_num)02d
command=php /var/www/artisan queue:work --sleep=3 --tries=3 command=php /var/www/artisan queue:work --sleep=3 --tries=3
autostart=true autostart=true
@@ -9,14 +9,12 @@ autorestart=true
user=www-data user=www-data
numprocs=1 numprocs=1
redirect_stderr=true redirect_stderr=true
stdout_logfile=/var/www/storage/logs/worker.log stdout_logfile=/var/www/storage/logs/queue.log
[program:inertia-worker] [program:inertia-ssr]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/artisan inertia:start-ssr command=php /var/www/artisan inertia:start-ssr
autostart=true autostart=true
autorestart=true autorestart=true
user=www-data user=www-data
numprocs=1
redirect_stderr=true redirect_stderr=true
stdout_logfile=/var/www/storage/logs/inertia-worker.log stdout_logfile=/var/www/storage/logs/inertia-ssr.log
+5 -4
View File
@@ -60,10 +60,11 @@ class PostResource extends Resource implements HasShieldPermissions
return $table return $table
->columns([ ->columns([
Tables\Columns\TextColumn::make('id'), Tables\Columns\TextColumn::make('id'),
Tables\Columns\TextColumn::make('title')->label('Заголовок') Tables\Columns\TextColumn::make('title')->label('Заголовок')->searchable(),
->searchable(), Tables\Columns\TextColumn::make('status')->label('Статус')->badge(),
Tables\Columns\TextColumn::make('status')->label('Статус')->badge() Tables\Columns\TextColumn::make('publish_at')->sortable(),
])->defaultSort('created_at', 'desc')
])->defaultSort('publish_at', 'desc')
->filters([ ->filters([
// //
]) ])
@@ -61,8 +61,11 @@ class CreatePost extends CreateRecord
if ($rowData === null) { if ($rowData === null) {
$rowData = $this->getFirstBlockByName('paragraph', $data['content']); $rowData = $this->getFirstBlockByName('paragraph', $data['content']);
} }
if ($rowData !== null) {
$description = strip_tags($rowData['data']['content']); $description = strip_tags($rowData['data']['content']);
$image = ($data['preview'] !== null) ? $data['preview'] : null; } else {
$description = null;
} $image = ($data['preview'] !== null) ? $data['preview'] : null;
return [ return [
'title' => $title, 'title' => $title,
@@ -24,6 +24,7 @@ class EditPost extends EditRecord
$this->seoData = $this->generateSeo($data); $this->seoData = $this->generateSeo($data);
$this->publicationAgreements = $data['publication']; $this->publicationAgreements = $data['publication'];
unset($data['publication']); unset($data['publication']);
unset($data['publish_setting']);
$data['preview_text'] = $this->setPreviewText($data); $data['preview_text'] = $this->setPreviewText($data);
$data['publish_at'] = $this->setPublishDateTime($data['status'], $this->record->publish_at); $data['publish_at'] = $this->setPublishDateTime($data['status'], $this->record->publish_at);
$data['search_data'] = $this->generateSearchData($data['content']); $data['search_data'] = $this->generateSearchData($data['content']);
@@ -38,14 +39,19 @@ class EditPost extends EditRecord
$this->postToSocialMedia($this->publicationAgreements, $this->record->content, $this->record->title, Carbon::parse($this->record->publish_at)->timestamp); $this->postToSocialMedia($this->publicationAgreements, $this->record->content, $this->record->title, Carbon::parse($this->record->publish_at)->timestamp);
} }
private function setPreviewText(array $data) : string private function setPreviewText(array $data) : string|null
{ {
$rowData = $this->getBlockBySeoActiveState('paragraph', $data['content']); $rowData = $this->getBlockBySeoActiveState('paragraph', $data['content']);
if ($rowData === null) { if ($rowData === null) {
$rowData = $this->getFirstBlockByName('paragraph', $data['content']); $rowData = $this->getFirstBlockByName('paragraph', $data['content']);
} }
if ($rowData !== null) {
$preview_text = strip_tags($rowData['data']['content']); $preview_text = strip_tags($rowData['data']['content']);
return Str::limit($preview_text, 160); return Str::limit($preview_text, 160);
} else {
$preview_text = null;
return $preview_text;
}
} }
private function getBlockBySeoActiveState(string $name, array $content) : array|null private function getBlockBySeoActiveState(string $name, array $content) : array|null
@@ -72,7 +78,11 @@ class EditPost extends EditRecord
if ($rowData === null) { if ($rowData === null) {
$rowData = $this->getFirstBlockByName('paragraph', $data['content']); $rowData = $this->getFirstBlockByName('paragraph', $data['content']);
} }
if ($rowData !== null) {
$description = strip_tags($rowData['data']['content']); $description = strip_tags($rowData['data']['content']);
} else {
$description = null;
}
$image = ($this->record->preview !== null) ? $this->record->preview : null; $image = ($this->record->preview !== null) ? $this->record->preview : null;
return [ return [
+1 -1
View File
@@ -58,7 +58,7 @@ class PostFactory extends Factory
'reading_time' => $reading_time, 'reading_time' => $reading_time,
'category_id' => $category_id, 'category_id' => $category_id,
'user_id' => $user_id, 'user_id' => $user_id,
'publish_at' => ($status == PostStatus::PUBLISHED) ? now() : null, 'publish_at' => ($status === PostStatus::PUBLISHED) ? now() : null,
'created_at' => now(), 'created_at' => now(),
'updated_at' => now(), 'updated_at' => now(),
]; ];
+5 -1
View File
@@ -20,7 +20,10 @@ services:
container_name: ntspi-php container_name: ntspi-php
ports: ports:
- '5173' - '5173'
command: ["/usr/bin/supervisord"] depends_on:
- db
command: >
sh -c "php artisan inertia:start-ssr & php-fpm"
db: db:
image: mysql:8.0 image: mysql:8.0
@@ -35,3 +38,4 @@ services:
- MYSQL_PASSWORD=secret - MYSQL_PASSWORD=secret
ports: ports:
- "3306:3306" - "3306:3306"
+493 -493
View File
File diff suppressed because it is too large Load Diff
@@ -81,7 +81,7 @@
</Link> </Link>
</li> </li>
<li class="text-sm"> <li class="text-sm">
<Link :href="$inertia.page.props.ziggy.location" class="flex items-center text-gray-500 hover:text-blue-600"> <Link :href="$page.props.ziggy.location" class="flex items-center text-gray-500 hover:text-blue-600">
{{ postTitle }} {{ postTitle }}
</Link> </Link>
</li> </li>