From 106c542a982291679cf48e5f28c3fb91d0e2b0a9 Mon Sep 17 00:00:00 2001 From: Phil Bates Date: Thu, 18 Jan 2024 10:24:35 +0000 Subject: [PATCH] Dockerfile: Run composer install in ENTRYPOINT I realised going through the docs the getting started steps on a fresh project didn't work, there were a couple of issues: 1. The .env wasn't being created 2. The composer:latest used to do the initial "composer install" uses PHP8.2 but the project requires PHP8.3 so it fails. It makes much more sense to do the "composer install" as part of the initial "docker-compose up" meaning one less step for the developer. --- .env.example | 2 +- Dockerfile | 2 +- README.md | 29 ++++++++++++++++++----------- config/app.php | 2 +- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.env.example b/.env.example index c8fb015..ac73271 100644 --- a/.env.example +++ b/.env.example @@ -2,7 +2,7 @@ APP_NAME=Laravel APP_ENV=local APP_KEY= APP_DEBUG=true -APP_URL=http://localhost +APP_URL=https://localhost LOG_CHANNEL=stack LOG_DEPRECATIONS_CHANNEL=null diff --git a/Dockerfile b/Dockerfile index c93d7e1..12251ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,4 +10,4 @@ ENV COMPOSER_ALLOW_SUPERUSER=1 RUN cp $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini; \ sed -i 's/variables_order = "GPCS"/variables_order = "EGPCS"/' $PHP_INI_DIR/php.ini; -ENTRYPOINT ["php", "artisan", "octane:start", "--server=frankenphp", "--host=localhost", "--port=443", "--admin-port=2019", "--https"] +ENTRYPOINT ["/bin/sh", "-c" , "composer install && php artisan octane:start --server=frankenphp --host=localhost --port=443 --admin-port=2019 --https"] diff --git a/README.md b/README.md index 6b16d5d..5278a7e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ This is a modern, strict, strongly typed Laravel application skeleton that can b You should ensure that you have the following installed on your host machine: +* Git * Docker * Docker-compose * pnpm v8 @@ -40,28 +41,34 @@ Front end: ## Getting started -1. Install front end dependencies: - ```shell - pnpm install - ``` +1. Clone this repo: + ```shell + git clone git@github.com:philbates35/laravel-starter.git example-project + cd example-project + ``` -2. Run the Vite dev server: +2. Create the `.env` file: + ```shell + cp .env.example .env + ``` +3. Install composer dependencies, then start Octane (FrankenPHP): ```shell - pnpm run dev + docker-compose up -d ``` -3. Install composer dependencies: +4. Install front end dependencies: ```shell - docker run --rm -it -u $(id -u $USER) -v $PWD:/app composer:latest composer install + pnpm install ``` -4. Start Octane (FrankenPHP): +5. Run the Vite dev server: + ```shell - docker-compose up -d + pnpm run dev ``` -5. Go to https://localhost/, accept the potential security risk (it's a self-signed certificate), and you should see the Laravel welcome page. +6. Go to https://localhost/, accept the potential security risk (it's a self-signed certificate), and you should see the Laravel welcome page. ## Cheat sheet diff --git a/config/app.php b/config/app.php index 7920426..d4fdd98 100644 --- a/config/app.php +++ b/config/app.php @@ -57,7 +57,7 @@ | */ - 'url' => env('APP_URL', 'http://localhost'), + 'url' => env('APP_URL', 'https://localhost'), 'asset_url' => env('ASSET_URL'),