From 5c72cdbfd5740d846e273761e02a79c33a01cacb Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Wed, 17 Jul 2024 22:05:42 -0400 Subject: [PATCH] Start building out a PHP container that will run the server. --- app/src/Controller/DashboardPage.php | 7 +++++-- app/src/Routes.php | 4 ++++ app/templates/layouts/skeleton.twig | 2 +- deploy/php/Dockerfile | 20 ++++++++++++++++++++ docker-compose.yml | 8 +++++++- 5 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 deploy/php/Dockerfile diff --git a/app/src/Controller/DashboardPage.php b/app/src/Controller/DashboardPage.php index 6ad097e..0ef3061 100644 --- a/app/src/Controller/DashboardPage.php +++ b/app/src/Controller/DashboardPage.php @@ -2,18 +2,21 @@ namespace Slovocast\Controller; -use Slovocast\Controller\Controller; +use Slovocast\Domain\Repository\Channel\ChannelRepositoryInterface; use Slovocast\Domain\Repository\User\UserRepositoryInterface; use Psr\Http\Message\ResponseInterface as Response; class DashboardPage extends Controller { public function __construct( - protected UserRepositoryInterface $userRepository + protected UserRepositoryInterface $userRepository, + protected ChannelRepositoryInterface $channelRepository ) { } public function handle(): Response { + // get the user details + // get the channels return $this->render('dashboard.twig'); } } diff --git a/app/src/Routes.php b/app/src/Routes.php index 80b4d48..c7c0c71 100644 --- a/app/src/Routes.php +++ b/app/src/Routes.php @@ -25,6 +25,7 @@ class Routes $app->get('/healthcheck', HealthCheck::class); // User Routes self::users($app); + self::dashboard($app); } /** @@ -44,7 +45,10 @@ class Routes $app->post('/login', LoginUserAction::class) ->add(AuthenticatedMiddleware::class) ->setName('user-login-action'); + } + protected static function dashboard(App $app): void + { $app->get('/dashboard', DashboardPage::class) ->add(AuthenticatedMiddleware::class) ->setName('user-dashboard'); diff --git a/app/templates/layouts/skeleton.twig b/app/templates/layouts/skeleton.twig index 3d8c0e4..23f9e94 100644 --- a/app/templates/layouts/skeleton.twig +++ b/app/templates/layouts/skeleton.twig @@ -14,7 +14,7 @@
- {% include 'components/flash.twig' %} + {% include 'layouts/components/flash.twig' %} {% block content %}{% endblock %} diff --git a/deploy/php/Dockerfile b/deploy/php/Dockerfile new file mode 100644 index 0000000..b704a5b --- /dev/null +++ b/deploy/php/Dockerfile @@ -0,0 +1,20 @@ +FROM php:8.3-alpine + +# Install PHP extensions +RUN apk add --no-cache zip libzip-dev \ + && docker-php-ext-install pdo_mysql zip + +# Install composer +RUN curl -sS https://getcomposer.org/installer | php \ + && mv composer.phar /usr/bin/composer + +# Install xdebug +RUN apk add --no-cache $PHPIZE_DEPS +# && pecl install xdebug-2.7.1 \ +# && docker-php-ext-enable xdebug \ +# && echo 'xdebug.remote_enable=1' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + +WORKDIR /app +COPY ./app /app + +CMD [ "php", "server/server.php" ] diff --git a/docker-compose.yml b/docker-compose.yml index 1577a9f..c2d9d32 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.9' services: database: - image: mariadb:latest + image: mariadb:latest environment: MARIADB_DATABASE: "slovocast" MARIADB_USER: "slovocast" @@ -12,5 +12,11 @@ services: - "3306:3306" volumes: - slovocast_db:/var/lib/mysql/data/ + app: + build: + dockerfile: ./deploy/php/Dockerfile + volumes: + - ./app:/app + volumes: slovocast_db: