Skip to content

Commit

Permalink
fix: docker app.ini for PHP and healthchecks
Browse files Browse the repository at this point in the history
  • Loading branch information
mborne committed Dec 3, 2024
1 parent 77564fe commit 11cd92a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ RUN ln -sfT /dev/stderr "/var/log/apache2/error.log" \
#----------------------------------------------------------------------
# Configure PHP
#----------------------------------------------------------------------
COPY .docker/php.ini /etc/php/8.3/apache2/php.ini
# TODO .docker/php.ini /etc/php/8.3/cli/php.ini
COPY .docker/php.ini /etc/php/8.3/apache2/conf.d/99-app.ini
COPY .docker/php.ini /etc/php/8.3/cli/conf.d/99-app.ini

#----------------------------------------------------------------------
# Configure apache
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ services:
- DB_UPGRADE=1
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/validator_api?serverVersion=15&charset=utf8
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/validator_api?serverVersion=13&charset=utf8
- S3_ENDPOINT=${S3_ENDPOINT}
- S3_ACCESS_KEY=${S3_ACCESS_KEY}
- S3_SECRET_KEY=${S3_SECRET_KEY}
Expand Down
22 changes: 10 additions & 12 deletions src/Controller/Api/HealthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use League\Flysystem\FilesystemOperator;
Expand All @@ -21,15 +22,15 @@ class HealthController extends AbstractController
*
* @Route("/db", name="health_db")
*/
public function healthDB(EntityManager $entityManager)
public function healthDB(EntityManagerInterface $entityManager)
{
$sql = "SELECT postgis_version() as postgis_version";
try{
$entityManager->getConnection()->connect();
$check = $entityManager->getConnection()->isConnected();
$httpCode = $check ? Response::HTTP_OK : Response::HTTP_SERVICE_UNAVAILABLE;
return new JsonResponse($check, $httpCode);
$stmt = $entityManager->getConnection()->prepare($sql);
$result = $stmt->executeQuery();
return new JsonResponse($result->fetchOne(), Response::HTTP_OK);
} catch (Exception $e){
return new JsonResponse(False, Response::HTTP_NOT_FOUND);
return new JsonResponse($e->getMessage(), Response::HTTP_NOT_FOUND);
}
}

Expand All @@ -41,12 +42,9 @@ public function healthDB(EntityManager $entityManager)
public function healthS3(FilesystemOperator $dataStorage)
{
try {
$files = $dataStorage->listContents('.', TRUE);
$response = [];
foreach ($files as $file) {
$response[] = $file->path();
}
return new JsonResponse($response, Response::HTTP_OK);
$files = $dataStorage->listContents('.', false);
$numFiles = count($files->toArray());
return new JsonResponse('found '.$numFiles.' files', Response::HTTP_OK);
} catch (Exception $e) {
return new JsonResponse(False, Response::HTTP_NOT_FOUND);
}
Expand Down

0 comments on commit 11cd92a

Please sign in to comment.