Skip to content

Commit

Permalink
Dockerfile: Run composer install in ENTRYPOINT
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
philbates35 authored and Phil Bates committed Jan 18, 2024
1 parent e3fcc6b commit 106c542
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -40,28 +41,34 @@ Front end:

## Getting started

1. Install front end dependencies:
```shell
pnpm install
```
1. Clone this repo:
```shell
git clone [email protected]: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
Expand Down
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
|
*/

'url' => env('APP_URL', 'http://localhost'),
'url' => env('APP_URL', 'https://localhost'),

'asset_url' => env('ASSET_URL'),

Expand Down

0 comments on commit 106c542

Please sign in to comment.