Skip to content

Commit

Permalink
Add healthcheck in PHP back end of Storybook and handle new env var P…
Browse files Browse the repository at this point in the history
…S_APP_VERSION
  • Loading branch information
Quetzacoalt91 committed Nov 22, 2024
1 parent ac0fe21 commit 8791756
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions storybook/.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=6ca3f5a44d55f1407362700a7565930c
PS_APP_VERSION=dev
###< symfony/framework-bundle ###
1 change: 1 addition & 0 deletions storybook/config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
app.version: '%env(PS_APP_VERSION)%'

services:
_defaults:
Expand Down
2 changes: 2 additions & 0 deletions storybook/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ services:
context: ..
dockerfile: storybook/.docker/Dockerfile
command: php -S 0.0.0.0:8000 -t public/
environment:
PS_APP_VERSION: dev
volumes:
- ./../:/autoupgrade
working_dir: /autoupgrade/storybook
Expand Down
21 changes: 21 additions & 0 deletions storybook/src/Controller/HealthCheckController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;


class HealthCheckController extends AbstractController
{
#[Route('/healthcheck')]
public function index(): Response
{
return new JsonResponse([
'status' => 'ok',
'version' => $this->getParameter('app.version'),
]);
}
}

0 comments on commit 8791756

Please sign in to comment.