diff --git a/.gitignore b/.gitignore index 55676e0..a1f0cc5 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,8 @@ composer.local.json composer.local.lock # Docker files -compose.override.yml +# (compose.override.yml is intentionally TRACKED — deploy.sh pins -f compose.yml +# so it is never merged on the server, but every developer gets the same setup) /docker/nginx/ssl/ # Docker data volumes @@ -45,4 +46,8 @@ docker/data/ *:Zone.Identifier # Temp files -/public/favicon-code.html \ No newline at end of file +/public/favicon-code.html + +# opencode (local AI agent config — kept out of the repo) +/AGENTS.md +/.opencode/ \ No newline at end of file diff --git a/README.md b/README.md index 83633aa..9d637f5 100644 --- a/README.md +++ b/README.md @@ -16,28 +16,65 @@ The repository serves for [webifycms.com](https://webifycms.com) site which runs ### Docker Setup (recommended) -**Local development:** +**Local development** — `compose.override.yml` is applied automatically by +`docker compose`, giving you live host bind-mounts (code and asset changes are +picked up instantly) and local HTTPS via self-signed certs: ```bash -# Start the containers (compose.override.yml is applied automatically) +# Host-side dependencies (target the same files the containers bind-mount) +npm install + +# Start the containers docker compose up -d # Install PHP dependencies docker compose exec app composer install -# Install front-end dependencies and build assets -docker compose exec app npm install +# Build front-end assets (this also copies assets/img/ → public/assets/img/) docker compose exec app npm run build ``` -**Production (server):** +The site is then available at `http://localhost:${NGINX_PORT}` and +`https://webifycms.com.local:${NGINX_PORT_SSL}` (both set in `.env`). For the +HTTPS hostname, add `127.0.0.1 webifycms.com.local` to `/etc/hosts` and trust +the self-signed cert in `docker/nginx/ssl/` once. + +**Production (server)** — only the base `compose.yml` is used, so the +local-only override is never merged: ```bash -# Ignore compose.override.yml — only the base compose.yml is used -docker compose -f compose.yml up -d +# Build and start (compose.override.yml is ignored) +docker compose -f compose.yml up -d --build ``` -The site will be available at `http://localhost:3000` (configurable via `NGINX_PORT` in `.env`). +The two environments differ only in `compose.override.yml`: + +| | Local (`docker compose`) | Production (`docker compose -f compose.yml`) | +|---|---|---| +| `app` image | `docker/php/local.Dockerfile` + host bind-mount | `docker/php/Dockerfile` (bundles code + assets + images) | +| nginx config | `docker/nginx/nginx.local.conf` (local TLS) | `docker/nginx/nginx.caddy.conf` (HTTP, Caddy terminates TLS) | +| SSL certs | `docker/nginx/ssl/` (gitignored, self-signed) | none (Caddy-managed) | +| Web root | host `./` bind-mounted | shared `app-data` volume seeded from the image | + +The `compose.override.yml` used for local development: + +```yaml +services: + app: + build: + context: . + dockerfile: ./docker/php/local.Dockerfile + volumes: + - ./:/var/www/html + server: + volumes: + - ./:/var/www/html + - ./docker/nginx/nginx.local.conf:/etc/nginx/conf.d/default.conf + - ./docker/nginx/ssl:/etc/nginx/ssl:ro + ports: + - "${NGINX_PORT}:80" + - "${NGINX_PORT_SSL}:443" +``` ### Manual Setup @@ -73,6 +110,7 @@ npm run build - JS is extracted from inline `