Skip to content

Commit 11cd92a

Browse files
committed
fix: docker app.ini for PHP and healthchecks
1 parent 77564fe commit 11cd92a

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

.docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ RUN ln -sfT /dev/stderr "/var/log/apache2/error.log" \
8787
#----------------------------------------------------------------------
8888
# Configure PHP
8989
#----------------------------------------------------------------------
90-
COPY .docker/php.ini /etc/php/8.3/apache2/php.ini
91-
# TODO .docker/php.ini /etc/php/8.3/cli/php.ini
90+
COPY .docker/php.ini /etc/php/8.3/apache2/conf.d/99-app.ini
91+
COPY .docker/php.ini /etc/php/8.3/cli/conf.d/99-app.ini
9292

9393
#----------------------------------------------------------------------
9494
# Configure apache

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ services:
2020
- DB_UPGRADE=1
2121
- POSTGRES_USER=${POSTGRES_USER}
2222
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
23-
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/validator_api?serverVersion=15&charset=utf8
23+
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/validator_api?serverVersion=13&charset=utf8
2424
- S3_ENDPOINT=${S3_ENDPOINT}
2525
- S3_ACCESS_KEY=${S3_ACCESS_KEY}
2626
- S3_SECRET_KEY=${S3_SECRET_KEY}

src/Controller/Api/HealthController.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
77
use Symfony\Component\Routing\Annotation\Route;
88
use Doctrine\ORM\EntityManager;
9+
use Doctrine\ORM\EntityManagerInterface;
910
use Symfony\Component\HttpFoundation\JsonResponse;
1011
use Symfony\Component\HttpFoundation\Response;
1112
use League\Flysystem\FilesystemOperator;
@@ -21,15 +22,15 @@ class HealthController extends AbstractController
2122
*
2223
* @Route("/db", name="health_db")
2324
*/
24-
public function healthDB(EntityManager $entityManager)
25+
public function healthDB(EntityManagerInterface $entityManager)
2526
{
27+
$sql = "SELECT postgis_version() as postgis_version";
2628
try{
27-
$entityManager->getConnection()->connect();
28-
$check = $entityManager->getConnection()->isConnected();
29-
$httpCode = $check ? Response::HTTP_OK : Response::HTTP_SERVICE_UNAVAILABLE;
30-
return new JsonResponse($check, $httpCode);
29+
$stmt = $entityManager->getConnection()->prepare($sql);
30+
$result = $stmt->executeQuery();
31+
return new JsonResponse($result->fetchOne(), Response::HTTP_OK);
3132
} catch (Exception $e){
32-
return new JsonResponse(False, Response::HTTP_NOT_FOUND);
33+
return new JsonResponse($e->getMessage(), Response::HTTP_NOT_FOUND);
3334
}
3435
}
3536

@@ -41,12 +42,9 @@ public function healthDB(EntityManager $entityManager)
4142
public function healthS3(FilesystemOperator $dataStorage)
4243
{
4344
try {
44-
$files = $dataStorage->listContents('.', TRUE);
45-
$response = [];
46-
foreach ($files as $file) {
47-
$response[] = $file->path();
48-
}
49-
return new JsonResponse($response, Response::HTTP_OK);
45+
$files = $dataStorage->listContents('.', false);
46+
$numFiles = count($files->toArray());
47+
return new JsonResponse('found '.$numFiles.' files', Response::HTTP_OK);
5048
} catch (Exception $e) {
5149
return new JsonResponse(False, Response::HTTP_NOT_FOUND);
5250
}

0 commit comments

Comments
 (0)