Skip to content

Commit bb57797

Browse files
committed
improve worker-php docs
1 parent cfbc741 commit bb57797

2 files changed

Lines changed: 119 additions & 79 deletions

File tree

README.md

Lines changed: 49 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -5,156 +5,126 @@
55
[![Docker Pulls](https://img.shields.io/docker/pulls/usabilitydynamics/udx-worker-php.svg)](https://hub.docker.com/r/usabilitydynamics/udx-worker-php)
66
[![License](https://img.shields.io/github/license/udx/worker-php.svg)](LICENSE)
77

8-
PHP runtime image built on UDX Worker with NGINX + PHP-FPM preconfigured.
8+
PHP runtime image built on UDX Worker with NGINX and PHP-FPM wired for `/var/www`.
99

10-
[Quick Start](#quick-start) [Usage](#usage) [Development](#development) [Resources](#resources)
10+
[Quick Start](#quick-start) - [Runtime](#runtime) - [Development](#development) - [Deployment](#deployment) - [Agent Context](#agent-context)
1111

1212
## Overview
1313

14-
`udx-worker-php` extends [`udx/worker`](https://github.com/udx/worker) and keeps the same worker runtime model while adding:
14+
`udx-worker-php` extends [`usabilitydynamics/udx-worker`](https://github.com/udx/worker) and keeps the worker runtime model while adding a PHP web stack:
1515

16-
- NGINX configured for `/var/www`
17-
- PHP-FPM (`8.4`) with socket-based NGINX integration
18-
- Worker service definitions that autostart both `php-fpm` and `nginx`
16+
- NGINX serves `/var/www`.
17+
- PHP-FPM runs behind NGINX through a Unix socket.
18+
- PHP CLI and common extensions are installed for application and automation workloads.
19+
- Worker service definitions start both `php-fpm` and `nginx`.
1920

20-
This image is intended as a base runtime for PHP applications and PHP-focused automation workloads.
21+
Use this image as a base for PHP applications, automation jobs, or deployment workflows that need the Worker runtime contract.
2122

2223
## Quick Start
2324

24-
Requirements: Docker (and Make if you want local dev commands).
25+
Requirements: Docker. Make is optional but recommended for local development.
2526

26-
### Run from Docker Hub
27+
Run the published image:
2728

2829
```bash
2930
docker run -d \
3031
--name my-php-app \
31-
-p 80:80 \
32+
-p 8080:80 \
3233
-v "$(pwd)/my-php-app:/var/www" \
3334
usabilitydynamics/udx-worker-php:latest
3435
```
3536

36-
Then open `http://localhost` (or your mapped host port).
37+
Then open `http://localhost:8080`.
3738

38-
### Local Development Workflow
39+
Build and run locally:
3940

4041
```bash
4142
git clone https://github.com/udx/worker-php.git
4243
cd worker-php
4344

4445
make build
45-
make run
46+
make run HOST_PORT=8080
4647
make log FOLLOW_LOGS=true
4748
```
4849

49-
`make run` uses these defaults from `Makefile.variables`:
50+
`make run` uses defaults from `Makefile.variables`, including `./src/scripts:/var/www`, `.env`, and container port `80`.
5051

51-
- volume: `./src/scripts:/var/www`
52-
- host/container port: `80:80`
53-
- env file: `.env`
52+
## Runtime
5453

55-
## Usage
54+
The runtime contract is defined by the Dockerfile and the configs copied into the image:
5655

57-
### Mount your own app code
56+
- `Dockerfile` pins the base Worker image and Ubuntu package versions.
57+
- `etc/configs/nginx/` defines the NGINX server and PHP FastCGI integration.
58+
- `etc/configs/php/` defines PHP-FPM process and pool behavior.
59+
- `etc/configs/worker/services.yaml` declares Worker-managed services.
5860

59-
```bash
60-
make run VOLUMES="$(pwd)/path-to-app:/var/www" HOST_PORT=8080
61-
```
62-
63-
### Run interactively
61+
See [docs/runtime.md](docs/runtime.md) for runtime layout.
6462

65-
```bash
66-
make run-it
67-
```
63+
## Development
6864

69-
### Execute into the running container
65+
Common commands:
7066

7167
```bash
68+
make help
69+
make build
70+
make run HOST_PORT=8080
7271
make exec
72+
make log
73+
make clean
7374
```
7475

75-
### Deploy with Worker CLI config
76-
77-
This repo includes a sample `deploy.yml` for [`@udx/worker-deployment`](https://www.npmjs.com/package/@udx/worker-deployment).
76+
Run all validation:
7877

7978
```bash
80-
npm install -g @udx/worker-deployment
81-
worker run
79+
make test
8280
```
8381

84-
## Testing
85-
86-
Run all built-in tests:
82+
Run only the container test suite against an already built image:
8783

8884
```bash
8985
make run-all-tests
9086
```
9187

92-
Run full validation (build + tests):
93-
94-
```bash
95-
make test
96-
```
97-
98-
Run a specific test script:
88+
Run one test script:
9989

10090
```bash
10191
make run-test TEST_SCRIPT=10_nginx_test.php
10292
```
10393

104-
Current tests live in `src/tests/` and cover:
94+
Current tests live in `src/tests/` and cover NGINX HTTP response, PHP runtime availability, PHP CLI execution, and write permissions under `/var/www`.
10595

106-
- NGINX HTTP response
107-
- PHP runtime availability
108-
- CLI execution
109-
- write permissions under `/var/www`
96+
## Deployment
11097

111-
## Configuration
98+
This repo includes `deploy.yml`, a minimal [`@udx/worker-deployment`](https://www.npmjs.com/package/@udx/worker-deployment) config for running the image through Worker CLI tooling:
11299

113-
Primary defaults are in `Makefile.variables`:
100+
```bash
101+
npm install -g @udx/worker-deployment
102+
worker run
103+
```
114104

115-
- `DOCKER_IMAGE`
116-
- `CONTAINER_NAME`
117-
- `HOST_PORT` / `CONTAINER_PORT`
118-
- `VOLUMES`
119-
- `PHP_VERSION`
105+
The GitHub release pipeline is declared in `.github/workflows/docker-ops.yml` and delegates Docker publishing to `udx/reusable-workflows`.
120106

121-
Container/runtime config files:
107+
For dependency upgrades, include the changed base image/packages and the local verification result in the PR description.
122108

123-
- `etc/configs/nginx/default.conf`
124-
- `etc/configs/php/php-fpm.conf`
125-
- `etc/configs/php/www.conf`
126-
- `etc/configs/worker/services.yaml`
109+
## Agent Context
127110

128-
## Development
111+
This repo exposes generated agent context in `.rabbit/context.yaml`. Treat it as evidence for agents and automation, not as a hand-authored contract.
129112

130-
Useful commands:
113+
Do not edit `.rabbit/context.yaml` manually. After changing source docs, Dockerfile, workflows, or manifests, refresh it with:
131114

132115
```bash
133-
make help
134-
make build
135-
make run
136-
make log
137-
make clean
138-
make test
116+
dev.kit repo
139117
```
140118

119+
The human-authored deployment contract remains `deploy.yml`.
120+
141121
## Resources
142122

143123
- Docker Hub: https://hub.docker.com/r/usabilitydynamics/udx-worker-php
144124
- Source: https://github.com/udx/worker-php
145125
- Base runtime docs: https://github.com/udx/worker/tree/latest/docs
146126
- Deployment config docs: https://github.com/udx/worker-deployment/blob/latest/docs/deploy-config.md
147127

148-
## Contributing
149-
150-
1. Fork the repository
151-
2. Create a feature branch
152-
3. Commit your changes
153-
4. Push to your branch
154-
5. Open a pull request
155-
156-
Include relevant tests and documentation updates with your changes.
157-
158128
## License
159129

160-
MIT. See [`LICENSE`](LICENSE).
130+
MIT. See [LICENSE](LICENSE).

docs/runtime.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Runtime
2+
3+
`udx-worker-php` extends `usabilitydynamics/udx-worker` with a PHP web stack while keeping the Worker lifecycle and service supervision model.
4+
5+
## Image Layout
6+
7+
- Application root: `/var/www`
8+
- NGINX config: `/etc/nginx/nginx.conf` and `/etc/nginx/sites-available/default`
9+
- PHP-FPM config: `/etc/php/<php-version>/fpm/php-fpm.conf`
10+
- PHP-FPM pool: `/etc/php/<php-version>/fpm/pool.d/www.conf`
11+
- Worker services: `$HOME/.config/worker/services.yaml`
12+
13+
`/var/www` is both the declared volume and the working directory.
14+
15+
## Services
16+
17+
Worker starts:
18+
19+
- `php-fpm`, using the PHP-FPM pool config copied from `etc/configs/php/www.conf`
20+
- `nginx`, using the server config copied from `etc/configs/nginx/default.conf`
21+
22+
NGINX sends PHP requests to the PHP-FPM Unix socket configured during the image build.
23+
24+
## Permissions
25+
26+
The Docker build creates runtime directories and assigns ownership to the Worker user:
27+
28+
- `/var/log/php`
29+
- `/var/log/nginx`
30+
- `/run/php`
31+
- `/tmp`
32+
- `/var/lib/nginx`
33+
- `/var/www`
34+
35+
Keep permission setup in the image build. Runtime startup should not need broad permission repair.
36+
37+
## Local Mounts
38+
39+
The default local mount is:
40+
41+
```bash
42+
./src/scripts:/var/www
43+
```
44+
45+
Override it for an app directory:
46+
47+
```bash
48+
make run VOLUMES="$(pwd)/path-to-app:/var/www" HOST_PORT=8080
49+
```
50+
51+
## Validation
52+
53+
Use the repo contract command:
54+
55+
```bash
56+
make test
57+
```
58+
59+
This builds the image, starts the container, waits for the HTTP readiness check, and runs the PHP test scripts in `src/tests/`.
60+
61+
## Runtime Output
62+
63+
`worker-php` inherits Worker runtime output. Set `WORKER_OUTPUT_FILE` to write a redacted JSON snapshot for workflow or deployment integrations:
64+
65+
```bash
66+
docker run --rm \
67+
-e WORKER_OUTPUT_FILE=/tmp/worker-runtime.json \
68+
usabilitydynamics/udx-worker-php:latest \
69+
sh -lc 'test -s /tmp/worker-runtime.json'
70+
```

0 commit comments

Comments
 (0)