From 4049f9df53a0e9f9927d3bbfcd1128940add62e3 Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Fri, 22 Aug 2025 15:56:01 +0500 Subject: [PATCH 1/9] Fixes for not saving sorting in documentation. Add 'sort' attribute to fillable properties in Documentation model. --- app/application/app/Models/Documentation.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/application/app/Models/Documentation.php b/app/application/app/Models/Documentation.php index dd11136..8ac80ca 100644 --- a/app/application/app/Models/Documentation.php +++ b/app/application/app/Models/Documentation.php @@ -37,6 +37,7 @@ final class Documentation extends Model 'slug', 'is_public', 'category_id', + 'sort', ]; /** From 224240708ded9da0da2850bd3f8274da83f75d3f Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Fri, 22 Aug 2025 16:14:22 +0500 Subject: [PATCH 2/9] The cache was not cleared when saving Clearing the cache using tags did not work correctly. Had to abandon them. --- app/application/app/Enums/CacheTag.php | 18 ------------------ .../Http/Middleware/DocumentationVersion.php | 4 ++-- .../app/Http/Middleware/ProjectAndLanguage.php | 4 ++-- .../Middleware/ProjectDomainAndLanguage.php | 4 ++-- .../app/Http/Middleware/ProjectLanguage.php | 6 +++--- .../Project/DocumentationVersionService.php | 7 +++---- .../Admin/Project/TranslationService.php | 3 +-- .../app/Services/Admin/ProjectService.php | 7 +++---- .../app/Services/ClearCacheCommandHandler.php | 6 +++--- .../app/Services/Site/DocumentationService.php | 5 ++--- .../View/Components/Site/ChooseLanguage.php | 4 ++-- .../app/View/Components/Site/ChooseVersion.php | 6 ++---- 12 files changed, 25 insertions(+), 49 deletions(-) delete mode 100644 app/application/app/Enums/CacheTag.php diff --git a/app/application/app/Enums/CacheTag.php b/app/application/app/Enums/CacheTag.php deleted file mode 100644 index a9e7b6f..0000000 --- a/app/application/app/Enums/CacheTag.php +++ /dev/null @@ -1,18 +0,0 @@ -value); - } -} diff --git a/app/application/app/Http/Middleware/DocumentationVersion.php b/app/application/app/Http/Middleware/DocumentationVersion.php index e71fb39..8f951dc 100644 --- a/app/application/app/Http/Middleware/DocumentationVersion.php +++ b/app/application/app/Http/Middleware/DocumentationVersion.php @@ -2,8 +2,8 @@ namespace App\Http\Middleware; -use App\Enums\CacheTag; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Cache; use Symfony\Component\HttpFoundation\Response; final readonly class DocumentationVersion @@ -17,7 +17,7 @@ final readonly class DocumentationVersion } $seconds = 3600; - $version = CacheTag::DocumantationVersion->getCache()->remember(self::class . $project->id . '-' . $versionSlug, $seconds, function () use ($project, $versionSlug) { + $version = Cache::remember(self::class . $project->id . '-' . $versionSlug, $seconds, function () use ($project, $versionSlug) { return $project->documentationVersions()->where('slug', $versionSlug)->first() ?? false; }); if ($version === false) { diff --git a/app/application/app/Http/Middleware/ProjectAndLanguage.php b/app/application/app/Http/Middleware/ProjectAndLanguage.php index 36a7a63..a2dc478 100644 --- a/app/application/app/Http/Middleware/ProjectAndLanguage.php +++ b/app/application/app/Http/Middleware/ProjectAndLanguage.php @@ -2,8 +2,8 @@ namespace App\Http\Middleware; -use App\Enums\CacheTag; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Cache; use Symfony\Component\HttpFoundation\Response; use Closure; @@ -17,7 +17,7 @@ final class ProjectAndLanguage extends ProjectLanguage } $seconds = 3600; - $project = CacheTag::Project->getCache()->remember(self::class . $projectCode, $seconds, function () use ($projectCode) { + $project = Cache::remember(self::class . $projectCode, $seconds, function () use ($projectCode) { return $this->projectRepository->getProjectByCode($projectCode) ?? false; }); if ($project === false) { diff --git a/app/application/app/Http/Middleware/ProjectDomainAndLanguage.php b/app/application/app/Http/Middleware/ProjectDomainAndLanguage.php index 99d6236..2a7da34 100644 --- a/app/application/app/Http/Middleware/ProjectDomainAndLanguage.php +++ b/app/application/app/Http/Middleware/ProjectDomainAndLanguage.php @@ -2,9 +2,9 @@ namespace App\Http\Middleware; -use App\Enums\CacheTag; use Closure; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Cache; use Illuminate\Support\Str; use Symfony\Component\HttpFoundation\Response; @@ -21,7 +21,7 @@ final class ProjectDomainAndLanguage extends ProjectLanguage } $seconds = 3600; - $project = CacheTag::Project->getCache()->remember(self::class . $httpHost, $seconds, function () use ($httpHost) { + $project = Cache::remember(self::class . $httpHost, $seconds, function () use ($httpHost) { return $this->projectRepository->getProjectByHttpHost($httpHost) ?? false; }); if ($project === false) { diff --git a/app/application/app/Http/Middleware/ProjectLanguage.php b/app/application/app/Http/Middleware/ProjectLanguage.php index efaea63..f622fd9 100644 --- a/app/application/app/Http/Middleware/ProjectLanguage.php +++ b/app/application/app/Http/Middleware/ProjectLanguage.php @@ -2,13 +2,13 @@ namespace App\Http\Middleware; -use App\Enums\CacheTag; use App\Models\Project; use App\Repositories\ProjectLanguageRepository; use App\Repositories\ProjectRepository; use App\Repositories\ProjectTranslationRepository; use App\Services\WebsiteTranslations; use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\Cache; abstract class ProjectLanguage { @@ -21,7 +21,7 @@ abstract class ProjectLanguage protected function getWebsiteTranslations(Project $project, ?string $languageCode): ?WebsiteTranslations { $seconds = 3600 * 3; - $language = CacheTag::Project->getCache()->remember(self::class . $project->id . '-' . $languageCode, $seconds, function () use ($project, $languageCode) { + $language = Cache::remember(self::class . $project->id . '-' . $languageCode, $seconds, function () use ($project, $languageCode) { return $this->projectLanguageRepository->getProjectLanguageByCodeOrDefault($project, $languageCode) ?? false; }); if ($language === false) { @@ -34,7 +34,7 @@ abstract class ProjectLanguage } $seconds = 3600 * 24; - $translations = CacheTag::ProjectTranslation->getCache()->remember(self::class . '-translations-' . $project->id . '-' . $language->id, $seconds, function () use ($project, $language) { + $translations = Cache::remember(self::class . '-translations-' . $project->id . '-' . $language->id, $seconds, function () use ($project, $language) { return $this->projectTranslationRepository->getProjectTranslations($project->id, $language->id)->all()->pluck('text', 'code')->toArray(); }); diff --git a/app/application/app/Services/Admin/Project/DocumentationVersionService.php b/app/application/app/Services/Admin/Project/DocumentationVersionService.php index 22ef657..768bbc8 100644 --- a/app/application/app/Services/Admin/Project/DocumentationVersionService.php +++ b/app/application/app/Services/Admin/Project/DocumentationVersionService.php @@ -5,7 +5,6 @@ namespace App\Services\Admin\Project; use App\Dto\QuerySettingsDto; use App\Dto\Builder\DocumentationVersion as DocumentationVersionBuilderDto; use App\Dto\Service\Admin\Project\DocumentationVersion\StoreUpdate; -use App\Enums\CacheTag; use App\Enums\DocumentationVersionStatus; use App\Models\DocumentationVersion; use App\Models\User; @@ -141,7 +140,7 @@ final class DocumentationVersionService extends Service $dataVersion = $this->getDataVersion($data); return $this->documentationVersionCommandHandler->handleStore($project, $dataVersion); }); - $this->clearCacheCommandHandler->byTag(CacheTag::DocumantationVersion); + $this->clearCacheCommandHandler->all(); } catch (\Throwable $e) { report($e); return $this->errService(__('Server Error')); @@ -178,7 +177,7 @@ final class DocumentationVersionService extends Service $dataVersion = $this->getDataVersion($data); return $this->documentationVersionCommandHandler->handleUpdate($version, $dataVersion); }); - $this->clearCacheCommandHandler->byTag(CacheTag::DocumantationVersion); + $this->clearCacheCommandHandler->all(); } catch (\Throwable $e) { report($e); return $this->errService(__('Server Error')); @@ -207,7 +206,7 @@ final class DocumentationVersionService extends Service DB::transaction(function () use ($version) { $this->documentationVersionCommandHandler->handleDestroy($version); }); - $this->clearCacheCommandHandler->byTag(CacheTag::DocumantationVersion); + $this->clearCacheCommandHandler->all(); } catch (\Throwable $e) { report($e); return $this->errService(__('Server Error')); diff --git a/app/application/app/Services/Admin/Project/TranslationService.php b/app/application/app/Services/Admin/Project/TranslationService.php index 2a3d6fd..fabd3de 100644 --- a/app/application/app/Services/Admin/Project/TranslationService.php +++ b/app/application/app/Services/Admin/Project/TranslationService.php @@ -5,7 +5,6 @@ namespace App\Services\Admin\Project; use App\Dto\Service\Admin\Project\Translation\Translations; use App\Dto\Service\Admin\Project\Translation\Translation; use App\Dto\Service\Admin\Project\Translation\Update; -use App\Enums\CacheTag; use App\Jobs\Translate\ProcessTranslationText; use App\Models\ProjectTranslation; use App\Models\User; @@ -83,7 +82,7 @@ final class TranslationService extends Service DB::transaction(function () use ($data, $project, $language) { $this->translationModelSyncCommand->execute($project, $language, $data->getTranslations()); }); - $this->clearCacheCommandHandler->byTag(CacheTag::ProjectTranslation); + $this->clearCacheCommandHandler->all(); if (\config('translation_service.enable', false)) { $this->translateContent($projectId, $languageId, $data); } diff --git a/app/application/app/Services/Admin/ProjectService.php b/app/application/app/Services/Admin/ProjectService.php index b31bdc0..b4e5245 100644 --- a/app/application/app/Services/Admin/ProjectService.php +++ b/app/application/app/Services/Admin/ProjectService.php @@ -5,7 +5,6 @@ namespace App\Services\Admin; use App\Dto\Builder\Project as ProjectBuilderDto; use App\Dto\QuerySettingsDto; use App\Dto\Service\Admin\Project\StoreUpdate; -use App\Enums\CacheTag; use App\Enums\Morph; use App\Models\Project; use App\Models\ProjectLanguage; @@ -134,7 +133,7 @@ final class ProjectService extends Service return $project; }); - $this->clearCacheCommandHandler->byTag(CacheTag::Project); + $this->clearCacheCommandHandler->all(); } catch (\Throwable $e) { report($e); return $this->errService(__('Server Error')); @@ -177,7 +176,7 @@ final class ProjectService extends Service return $project; }); - $this->clearCacheCommandHandler->byTag(CacheTag::Project); + $this->clearCacheCommandHandler->all(); } catch (\Throwable $e) { report($e); return $this->errService(__('Server Error')); @@ -202,7 +201,7 @@ final class ProjectService extends Service DB::transaction(function () use ($project) { $this->projectCommandHandler->handleDestroy($project); }); - $this->clearCacheCommandHandler->byTag(CacheTag::Project); + $this->clearCacheCommandHandler->all(); } catch (\Throwable $e) { report($e); return $this->errService(__('Server Error')); diff --git a/app/application/app/Services/ClearCacheCommandHandler.php b/app/application/app/Services/ClearCacheCommandHandler.php index 2d00ded..409be87 100644 --- a/app/application/app/Services/ClearCacheCommandHandler.php +++ b/app/application/app/Services/ClearCacheCommandHandler.php @@ -2,12 +2,12 @@ namespace App\Services; -use App\Enums\CacheTag; +use Illuminate\Support\Facades\Cache; final readonly class ClearCacheCommandHandler { - public function byTag(CacheTag $tag): void + public function all(): void { - $tag->getCache()->flush(); + Cache::flush(); } } diff --git a/app/application/app/Services/Site/DocumentationService.php b/app/application/app/Services/Site/DocumentationService.php index 1c9bfaf..5cbe96f 100644 --- a/app/application/app/Services/Site/DocumentationService.php +++ b/app/application/app/Services/Site/DocumentationService.php @@ -3,7 +3,6 @@ namespace App\Services\Site; use App\Dto\Service\Site\Documentation; -use App\Enums\CacheTag; use App\Enums\DocumentationVersionStatus; use App\Models\DocumentationCategory; use App\Models\Documentation as ModelDocumentation; @@ -22,6 +21,7 @@ use App\Dto\Builder\Documentation as DocumentationBuilderDto; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Cache; final class DocumentationService extends Service { @@ -37,8 +37,7 @@ final class DocumentationService extends Service if ($user?->cannot('viewAny', DocumentationVersion::class)) { $isPublic = 1; } - $version = CacheTag::DocumantationVersion->getCache() - ->remember(self::class . $project->id . '_' . $isPublic ?? 0, $seconds, function () use ($project, $isPublic) { + $version = Cache::remember(self::class . $project->id . '_' . $isPublic ?? 0, $seconds, function () use ($project, $isPublic) { $versions = $project->documentationVersions() ->when($isPublic, function (Builder $query) { $query->where('is_public', 1); diff --git a/app/application/app/View/Components/Site/ChooseLanguage.php b/app/application/app/View/Components/Site/ChooseLanguage.php index 17c78b5..906281c 100644 --- a/app/application/app/View/Components/Site/ChooseLanguage.php +++ b/app/application/app/View/Components/Site/ChooseLanguage.php @@ -2,9 +2,9 @@ namespace app\View\Components\Site; -use App\Enums\CacheTag; use App\Models\Project; use App\Services\WebsiteTranslations; +use Illuminate\Support\Facades\Cache; use Illuminate\Support\Str; use Illuminate\View\Component; use Illuminate\View\View; @@ -24,7 +24,7 @@ final class ChooseLanguage extends Component } $seconds = 3600 * 12; - $languages = CacheTag::Project->getCache()->remember(self::class . $this->project->id, $seconds, function () { + $languages = Cache::remember(self::class . $this->project->id, $seconds, function () { return $this->project->languages; }); diff --git a/app/application/app/View/Components/Site/ChooseVersion.php b/app/application/app/View/Components/Site/ChooseVersion.php index e2f63fb..8552e2f 100644 --- a/app/application/app/View/Components/Site/ChooseVersion.php +++ b/app/application/app/View/Components/Site/ChooseVersion.php @@ -2,13 +2,12 @@ namespace App\View\Components\Site; -use App\Enums\CacheTag; use App\Models\DocumentationVersion; use App\Models\Project; use App\Models\User; use App\Services\WebsiteTranslations; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Support\Str; +use Illuminate\Support\Facades\Cache; use Illuminate\View\Component; use Illuminate\View\View; @@ -29,8 +28,7 @@ final class ChooseVersion extends Component } $seconds = 3600 * 12; - $versions = CacheTag::DocumantationVersion->getCache() - ->remember(self::class . $this->project->id . '-' . $isPublic ?? 0, $seconds, function () use ($isPublic) { + $versions = Cache::remember(self::class . $this->project->id . '-' . $isPublic ?? 0, $seconds, function () use ($isPublic) { return $this->project->documentationVersions() ->when($isPublic, function (Builder $query) { $query->where('is_public', 1); From ba74aa9977bc56f08f87da3124265ddc2cdcb019 Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Fri, 22 Aug 2025 16:42:20 +0500 Subject: [PATCH 3/9] The active menu was not highlighted if it was not the primary language. --- app/application/resources/views/layout/site.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/application/resources/views/layout/site.blade.php b/app/application/resources/views/layout/site.blade.php index a91a9ad..2053e6b 100644 --- a/app/application/resources/views/layout/site.blade.php +++ b/app/application/resources/views/layout/site.blade.php @@ -39,9 +39,9 @@
From 19b0e68b8b48f08a39c35d3e0cd70c01f269473b Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Fri, 22 Aug 2025 16:47:04 +0500 Subject: [PATCH 4/9] The active menu was not highlighted when we went to the documentation section. --- app/application/resources/views/layout/site.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/application/resources/views/layout/site.blade.php b/app/application/resources/views/layout/site.blade.php index 2053e6b..73c3f1a 100644 --- a/app/application/resources/views/layout/site.blade.php +++ b/app/application/resources/views/layout/site.blade.php @@ -40,7 +40,7 @@ From 3d4bef0e56b1e3f60f66d25dad54d323115e3304 Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Fri, 22 Aug 2025 19:07:55 +0500 Subject: [PATCH 5/9] Handle expired session errors gracefully - Add custom response for 419 (CSRF token expiration) using exception handler. - Update language files to include localized error messages for expired sessions. --- app/application/bootstrap/app.php | 12 ++++++++++-- app/application/lang/en/http-statuses.php | 1 + app/application/lang/ru/http-statuses.php | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/application/bootstrap/app.php b/app/application/bootstrap/app.php index 1f526b3..ca248d0 100644 --- a/app/application/bootstrap/app.php +++ b/app/application/bootstrap/app.php @@ -4,6 +4,7 @@ use Illuminate\Foundation\Application; use Illuminate\Foundation\Configuration\Exceptions; use Illuminate\Foundation\Configuration\Middleware; use Illuminate\Support\Facades\Route; +use Symfony\Component\HttpFoundation\Response; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( @@ -19,8 +20,15 @@ return Application::configure(basePath: dirname(__DIR__)) }, ) ->withMiddleware(function (Middleware $middleware) { - // + }) ->withExceptions(function (Exceptions $exceptions) { - // + $exceptions->respond(function (Response $response) { + if ($response->getStatusCode() === 419) { + return back() + ->withInput() + ->withErrors(['csrf' => __('http-statuses.csrfError')]); + } + return $response; + }); })->create(); diff --git a/app/application/lang/en/http-statuses.php b/app/application/lang/en/http-statuses.php index 3346f78..0290bd0 100644 --- a/app/application/lang/en/http-statuses.php +++ b/app/application/lang/en/http-statuses.php @@ -81,4 +81,5 @@ return [ '598' => 'Network Read Timeout Error', '599' => 'Network Connect Timeout Error', 'unknownError' => 'Unknown Error', + 'csrfError' => 'It looks like your session has expired. Please try again.', ]; diff --git a/app/application/lang/ru/http-statuses.php b/app/application/lang/ru/http-statuses.php index fe135a0..8537a09 100644 --- a/app/application/lang/ru/http-statuses.php +++ b/app/application/lang/ru/http-statuses.php @@ -81,4 +81,5 @@ return [ '598' => 'Истекло время ожидания', '599' => 'Истекло время подключения', 'unknownError' => 'Неизвестная ошибка', + 'csrfError' => 'Похоже, что срок действия Вашей сессии истек. Пожалуйста, попробуйте еще раз.', ]; From c33fcd1d7cb9996baf1df186d1b760331b04b1e9 Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Fri, 22 Aug 2025 22:33:39 +0500 Subject: [PATCH 6/9] Add required_with validation for `language.*.code` - Enforces `language.*.code` to be required when `language.*.source_language_id` is present. --- .../Requests/Admin/Projects/ServiceTranslate/UpdateRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/application/app/Http/Requests/Admin/Projects/ServiceTranslate/UpdateRequest.php b/app/application/app/Http/Requests/Admin/Projects/ServiceTranslate/UpdateRequest.php index 791811a..df06556 100644 --- a/app/application/app/Http/Requests/Admin/Projects/ServiceTranslate/UpdateRequest.php +++ b/app/application/app/Http/Requests/Admin/Projects/ServiceTranslate/UpdateRequest.php @@ -26,7 +26,7 @@ final class UpdateRequest extends FormRequest implements FormRequestDto { return [ 'language.*.id' => ['required', 'numeric', 'min:1'], - 'language.*.code' => ['nullable', 'string', 'min:2', 'max:50'], + 'language.*.code' => ['nullable', 'string', 'min:2', 'max:50', 'required_with:language.*.source_language_id'], 'language.*.source_language_id' => ['nullable', 'numeric', 'min:1', 'different:language.*.id'], ]; } From 94db6aa51d2196417f5d0cba6deb73fd59dc07b0 Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Sat, 23 Aug 2025 01:59:57 +0500 Subject: [PATCH 7/9] Add jq to Docker image and improve UNIT_SOURCE handling - Include jq in the Docker image for JSON processing. - Refactor UNIT_SOURCE logic to cleanly update configuration using jq. - Remove obsolete UNIT_SOURCE handling code. --- app/docker/Dockerfile | 2 +- app/docker/docker-entrypoint_dev.sh | 20 ++++++++++++++------ app/docker/docker-entrypoint_prod.sh | 20 ++++++++++++++------ docker-compose-prod.yml | 2 +- docker-compose-prod_docker-hub.yml | 2 +- docker-compose.yml | 4 +++- 6 files changed, 34 insertions(+), 16 deletions(-) diff --git a/app/docker/Dockerfile b/app/docker/Dockerfile index 8584616..fd1d63f 100644 --- a/app/docker/Dockerfile +++ b/app/docker/Dockerfile @@ -19,7 +19,7 @@ COPY --from=unit_builder /var/lib/unit/ /var/lib/unit/ COPY docker/unit-config.json /docker-entrypoint.d/config.json -RUN apk --no-cache add pcre2 libbz2 libpng libwebp libjpeg-turbo icu-libs freetype oniguruma libzip \ +RUN apk --no-cache add pcre2 libbz2 libpng libwebp libjpeg-turbo icu-libs freetype oniguruma libzip jq \ && apk add --no-cache --virtual .phpize-deps icu-dev libpng-dev bzip2-dev libwebp-dev libjpeg-turbo-dev freetype-dev oniguruma-dev libzip-dev pcre2-dev ${PHPIZE_DEPS} \ && docker-php-ext-configure intl --enable-intl && \ docker-php-ext-configure bcmath --enable-bcmath && \ diff --git a/app/docker/docker-entrypoint_dev.sh b/app/docker/docker-entrypoint_dev.sh index c447b67..9fc4564 100644 --- a/app/docker/docker-entrypoint_dev.sh +++ b/app/docker/docker-entrypoint_dev.sh @@ -42,6 +42,20 @@ if [ "$role" = "app" ]; then if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then echo "$0: /docker-entrypoint.d/ is not empty, applying initial configuration..." + if [[ -n "${UNIT_SOURCE:-}" ]]; then + config="/docker-entrypoint.d/config.json" + tmp="$(mktemp)" + jq --arg src "${UNIT_SOURCE}" ' + .listeners["*:9000"].forwarded.source = + ( $src + | split(",") + | map( gsub("^\\s+|\\s+$"; "") ) # trim пробелы + | map( select(. != "") ) # убрать пустые + ) + ' "$config" > "$tmp" + mv "$tmp" "$config" + fi + echo "$0: Looking for certificate bundles in /docker-entrypoint.d/..." for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.pem"); do echo "$0: Uploading certificates bundle: $f" @@ -60,12 +74,6 @@ if [ "$role" = "app" ]; then curl_put $f "config" done - if [ ! -z ${UNIT_SOURCE+x} ] - then - echo $UNIT_SOURCE > /docker-entrypoint.d/unit_source.json - curl_put "/docker-entrypoint.d/unit_source.json" "config/listeners/*:9000/forwarded/source" - fi - echo "$0: Looking for shell scripts in /docker-entrypoint.d/..." for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh"); do echo "$0: Launching $f"; diff --git a/app/docker/docker-entrypoint_prod.sh b/app/docker/docker-entrypoint_prod.sh index b066f56..8093a90 100644 --- a/app/docker/docker-entrypoint_prod.sh +++ b/app/docker/docker-entrypoint_prod.sh @@ -42,6 +42,20 @@ if [ "$role" = "app" ]; then if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then echo "$0: /docker-entrypoint.d/ is not empty, applying initial configuration..." + if [[ -n "${UNIT_SOURCE:-}" ]]; then + config="/docker-entrypoint.d/config.json" + tmp="$(mktemp)" + jq --arg src "${UNIT_SOURCE}" ' + .listeners["*:9000"].forwarded.source = + ( $src + | split(",") + | map( gsub("^\\s+|\\s+$"; "") ) # trim пробелы + | map( select(. != "") ) # убрать пустые + ) + ' "$config" > "$tmp" + mv "$tmp" "$config" + fi + echo "$0: Looking for certificate bundles in /docker-entrypoint.d/..." for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.pem"); do echo "$0: Uploading certificates bundle: $f" @@ -60,12 +74,6 @@ if [ "$role" = "app" ]; then curl_put $f "config" done - if [ ! -z ${UNIT_SOURCE+x} ] - then - echo $UNIT_SOURCE > /docker-entrypoint.d/unit_source.json - curl_put "/docker-entrypoint.d/unit_source.json" "config/listeners/*:9000/forwarded/source" - fi - echo "$0: Looking for shell scripts in /docker-entrypoint.d/..." for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh"); do echo "$0: Launching $f"; diff --git a/docker-compose-prod.yml b/docker-compose-prod.yml index 6772c61..e17e0bf 100644 --- a/docker-compose-prod.yml +++ b/docker-compose-prod.yml @@ -16,7 +16,7 @@ services: - ./app/application:/var/www/html environment: CONTAINER_ROLE: app - UNIT_SOURCE: '"172.16.0.0/12"' + UNIT_SOURCE: "172.16.0.0/12" queue: build: diff --git a/docker-compose-prod_docker-hub.yml b/docker-compose-prod_docker-hub.yml index 76f130d..d161692 100644 --- a/docker-compose-prod_docker-hub.yml +++ b/docker-compose-prod_docker-hub.yml @@ -13,7 +13,7 @@ services: env_file: app/.env environment: CONTAINER_ROLE: app - UNIT_SOURCE: '"172.16.0.0/12"' + UNIT_SOURCE: "172.16.0.0/12" volumes: - ./app/storage/app:/var/www/html/storage/app - ./app/storage/logs:/var/www/html/storage/logs diff --git a/docker-compose.yml b/docker-compose.yml index 16feedf..570c3f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.7' +#version: '3.7' services: app: build: @@ -13,6 +13,8 @@ services: - ${DOCKER_APP_PORT}:9000 volumes: - ./app/application:/var/www/html + environment: + CONTAINER_ROLE: app queue: build: From de496eaea19933fa8e0969def4acb9eef26b9dd2 Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Sat, 23 Aug 2025 02:28:49 +0500 Subject: [PATCH 8/9] Comment out version declaration in docker-compose-prod.yml --- docker-compose-prod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose-prod.yml b/docker-compose-prod.yml index e17e0bf..575e94f 100644 --- a/docker-compose-prod.yml +++ b/docker-compose-prod.yml @@ -1,4 +1,4 @@ -version: '3.7' +#version: '3.7' services: app: build: From d4174cf7d259934870db5fbefb3ead142c2adbd0 Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Sat, 23 Aug 2025 02:29:39 +0500 Subject: [PATCH 9/9] Update image version to 0.5.0 in production config --- docker-compose-prod_docker-hub.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docker-compose-prod_docker-hub.yml b/docker-compose-prod_docker-hub.yml index d161692..38492eb 100644 --- a/docker-compose-prod_docker-hub.yml +++ b/docker-compose-prod_docker-hub.yml @@ -1,8 +1,8 @@ -version: '3.7' +#version: '3.7' services: app: - # image: korelf/my-projects-website:0.4.0 # docker hub - image: docker.mdhub.kor-elf.net/kor-elf/my-projects-website:0.4.0 # MDHub + # image: korelf/my-projects-website:0.5.0 # docker hub + image: docker.mdhub.kor-elf.net/kor-elf/my-projects-website:0.5.0 # MDHub # restart: always depends_on: - db @@ -20,8 +20,8 @@ services: # - ./app/translate/authorized_key.json:/var/www/html/storage/translation_service/authorized_key.json queue: - # image: korelf/my-projects-website:0.4.0 # docker hub - image: docker.mdhub.kor-elf.net/kor-elf/my-projects-website:0.4.0 # MDHub + # image: korelf/my-projects-website:0.5.0 # docker hub + image: docker.mdhub.kor-elf.net/kor-elf/my-projects-website:0.5.0 # MDHub # restart: always depends_on: - db @@ -35,8 +35,8 @@ services: # - ./app/translate/authorized_key.json:/var/www/html/storage/translation_service/authorized_key.json scheduler: - # image: korelf/my-projects-website:0.4.0 # docker hub - image: docker.mdhub.kor-elf.net/kor-elf/my-projects-website:0.4.0 # MDHub + # image: korelf/my-projects-website:0.5.0 # docker hub + image: docker.mdhub.kor-elf.net/kor-elf/my-projects-website:0.5.0 # MDHub # restart: always depends_on: - db