Add Docker Compose setup for local runs
PHP 8.3 + Apache image serving public/ on port 8080, with pdo_sqlite and mbstring built in. The container entrypoint applies migrations as www-data before starting Apache; the SQLite database and generated JWT signing key persist in a named "storage" volume. `docker compose up -d` is now the primary way to run the project without a local PHP toolchain. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,18 +11,35 @@ SQLite file, plus a single-page frontend (added in a later stage).
|
||||
| 2 | Todo CRUD API | planned |
|
||||
| 3 | Single-page frontend | planned |
|
||||
|
||||
## Requirements
|
||||
## Run with Docker
|
||||
|
||||
- PHP 8.1+ with the `pdo_sqlite` and `mbstring` extensions
|
||||
- [Composer](https://getcomposer.org/)
|
||||
The only requirement is Docker with the Compose plugin.
|
||||
|
||||
On Fedora:
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
This builds a PHP 8.3 + Apache image, applies migrations, and serves the API at
|
||||
<http://localhost:8080> (e.g. `curl http://localhost:8080/api/health`).
|
||||
|
||||
- The SQLite database and the generated JWT signing key live in the `storage`
|
||||
named volume, so they survive `docker compose restart` / `down` + `up`.
|
||||
- After changing PHP source or `composer.json`, rebuild: `docker compose up -d --build`.
|
||||
- `docker compose down -v` removes the volume and gives you a clean database.
|
||||
- Override settings via the environment or a `.env` file in this directory
|
||||
(Compose substitutes `APP_DEBUG`, `JWT_SECRET`, `JWT_TTL` — see
|
||||
[docker-compose.yml](docker-compose.yml)).
|
||||
|
||||
## Run without Docker
|
||||
|
||||
Requires PHP 8.1+ with the `pdo_sqlite` and `mbstring` extensions, plus
|
||||
[Composer](https://getcomposer.org/). On Fedora:
|
||||
|
||||
```bash
|
||||
sudo dnf install php-cli php-pdo php-mbstring composer
|
||||
```
|
||||
|
||||
## Setup
|
||||
### Setup
|
||||
|
||||
```bash
|
||||
composer install
|
||||
@@ -30,7 +47,7 @@ cp .env.example .env # optional; sane defaults are used without it
|
||||
composer migrate # creates storage/database.sqlite and its tables
|
||||
```
|
||||
|
||||
## Running
|
||||
### Running
|
||||
|
||||
```bash
|
||||
composer serve # http://localhost:8080 (php -S localhost:8080 -t public)
|
||||
@@ -154,6 +171,9 @@ src/Http/JsonErrorHandler.php Uniform JSON error envelope
|
||||
src/Http/Controllers/ Request handlers
|
||||
src/Repository/ Database access
|
||||
migrations/*.sql Schema, applied by bin/migrate.php
|
||||
Dockerfile PHP 8.3 + Apache image
|
||||
docker-compose.yml One-command local stack
|
||||
docker/ Apache vhost + container entrypoint
|
||||
```
|
||||
|
||||
## Provenance
|
||||
|
||||
Reference in New Issue
Block a user