|
1 | | -# UDX Worker PHP |
2 | | - |
3 | | -[](https://hub.docker.com/r/usabilitydynamics/udx-worker-php) [](LICENSE) |
| 1 | +<img src="assets/logo.svg" alt="UDX Worker PHP"> |
4 | 2 |
|
5 | | -**A versatile Docker image for running PHP applications with NGINX and PHP-FPM, providing a ready-to-use environment to deploy and serve your PHP projects.** |
| 3 | +# UDX Worker PHP |
6 | 4 |
|
7 | | -[Quick Start](#-quick-start) • [Development](#-development) • [Deployment](#-deployment) • [Contributing](#-contributing) |
| 5 | +[](https://hub.docker.com/r/usabilitydynamics/udx-worker-php) |
| 6 | +[](LICENSE) |
8 | 7 |
|
9 | | -## 🚀 Overview |
| 8 | +PHP runtime image built on UDX Worker with NGINX + PHP-FPM preconfigured. |
10 | 9 |
|
11 | | -The image is designed as a general-purpose base for PHP application development and deployment. It includes essential configurations for NGINX and PHP-FPM to streamline your setup, making it easy to get started with popular frameworks and custom applications alike. |
| 10 | +[Quick Start](#quick-start) • [Usage](#usage) • [Development](#development) • [Resources](#resources) |
12 | 11 |
|
13 | | -### 🔧 Based on udx-worker |
| 12 | +## Overview |
14 | 13 |
|
15 | | -Built on [`udx-worker`](https://github.com/udx/worker), this image benefits from secure, resource-efficient configurations and best practices, providing a reliable foundation for PHP applications. |
| 14 | +`udx-worker-php` extends [`udx/worker`](https://github.com/udx/worker) and keeps the same worker runtime model while adding: |
16 | 15 |
|
17 | | -## 👨💻 Development |
| 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` |
18 | 19 |
|
19 | | -### 📋 Prerequisites |
| 20 | +This image is intended as a base runtime for PHP applications and PHP-focused automation workloads. |
20 | 21 |
|
21 | | -- Ensure `Docker` is installed and running on your system. |
| 22 | +## Quick Start |
22 | 23 |
|
23 | | -### 🚀 Quick Start |
| 24 | +Requirements: Docker (and Make if you want local dev commands). |
24 | 25 |
|
25 | | -This image serves as a base for your PHP applications. The `src/tests/` directory includes sample tests for verifying PHP and NGINX functionality, but it does not contain application code by default. |
| 26 | +### Run from Docker Hub |
26 | 27 |
|
27 | | -### Running Built-In Tests |
| 28 | +```bash |
| 29 | +docker run -d \ |
| 30 | + --name my-php-app \ |
| 31 | + -p 80:80 \ |
| 32 | + -v "$(pwd)/my-php-app:/var/www" \ |
| 33 | + usabilitydynamics/udx-worker-php:latest |
| 34 | +``` |
28 | 35 |
|
29 | | -1. Clone this repository: |
| 36 | +Then open `http://localhost` (or your mapped host port). |
30 | 37 |
|
31 | | -``` |
32 | | -git clone https://github.com/udx/udx-worker-php.git |
33 | | -cd udx-worker-php |
34 | | -``` |
| 38 | +### Local Development Workflow |
35 | 39 |
|
36 | | -2. Build the Docker image: |
| 40 | +```bash |
| 41 | +git clone https://github.com/udx/worker-php.git |
| 42 | +cd worker-php |
37 | 43 |
|
38 | | -``` |
39 | 44 | make build |
| 45 | +make run |
| 46 | +make log FOLLOW_LOGS=true |
40 | 47 | ``` |
41 | 48 |
|
42 | | -3. Run Tests to verify functionality: |
43 | | - |
44 | | -``` |
45 | | -make run-all-tests |
46 | | -``` |
| 49 | +`make run` uses these defaults from `Makefile.variables`: |
47 | 50 |
|
48 | | -You can add additional tests in the `src/tests/` directory as needed. |
| 51 | +- volume: `./src/scripts:/var/www` |
| 52 | +- host/container port: `80:80` |
| 53 | +- env file: `.env` |
49 | 54 |
|
50 | | -## 🚀 Deployment |
| 55 | +## Usage |
51 | 56 |
|
52 | | -### Deploying Using the Pre-Built Image |
| 57 | +### Mount your own app code |
53 | 58 |
|
54 | | -If you want to use the pre-built image directly from Docker Hub without cloning the repository: |
| 59 | +```bash |
| 60 | +make run VOLUMES="$(pwd)/path-to-app:/var/www" HOST_PORT=8080 |
| 61 | +``` |
55 | 62 |
|
56 | | -1. Pull the Image: |
| 63 | +### Run interactively |
57 | 64 |
|
58 | | -``` |
59 | | -docker pull usabilitydynamics/udx-worker-php:latest |
| 65 | +```bash |
| 66 | +make run-it |
60 | 67 | ``` |
61 | 68 |
|
62 | | -2. Run the container with your application code: |
| 69 | +### Execute into the running container |
63 | 70 |
|
64 | | -``` |
65 | | -docker run -d --name my-php-app \ |
66 | | - -v $(pwd)/my-php-app:/var/www \ |
67 | | - -p 80:80 \ |
68 | | - usabilitydynamics/udx-worker-php:latest |
| 71 | +```bash |
| 72 | +make exec |
69 | 73 | ``` |
70 | 74 |
|
71 | | -This serves your application at http://localhost. |
| 75 | +### Deploy with Worker CLI config |
72 | 76 |
|
73 | | -3. Stop and remove the container when done: |
| 77 | +This repo includes a sample `deploy.yml` for [`@udx/worker-deployment`](https://www.npmjs.com/package/@udx/worker-deployment). |
74 | 78 |
|
| 79 | +```bash |
| 80 | +npm install -g @udx/worker-deployment |
| 81 | +worker run |
75 | 82 | ``` |
76 | | -docker rm -f my-php-app |
77 | | -``` |
78 | | - |
79 | | -### Deploying Using a Locally Built Image (Makefile Approach) |
80 | 83 |
|
81 | | -If you’ve cloned this repository and built the image locally, you can use the provided Makefile targets: |
| 84 | +## Testing |
82 | 85 |
|
83 | | -1. Build the Image (if not already built): |
| 86 | +Run all built-in tests: |
84 | 87 |
|
85 | | -``` |
86 | | -make build |
| 88 | +```bash |
| 89 | +make run-all-tests |
87 | 90 | ``` |
88 | 91 |
|
89 | | -2. Run the Container: |
| 92 | +Run full validation (build + tests): |
90 | 93 |
|
| 94 | +```bash |
| 95 | +make test |
91 | 96 | ``` |
92 | | -make run |
93 | | -``` |
94 | | - |
95 | | -By default, this command runs the container with the code located in the `src/` directory of this repository. |
96 | 97 |
|
97 | | -3. Deploy Application Code. If your PHP application code is located in a different directory or repository, use the deploy target to mount it as a volume: |
| 98 | +Run a specific test script: |
98 | 99 |
|
99 | | -``` |
100 | | -APP_PATH=/path/to/your-php-app make run |
| 100 | +```bash |
| 101 | +make run-test TEST_SCRIPT=10_nginx_test.php |
101 | 102 | ``` |
102 | 103 |
|
103 | | -- Replace `/path/to/your-php-app` with the path to your PHP application directory. |
104 | | -- This command will mount your specified application directory into the container’s `/var/www` directory, allowing you to run your custom application directly. |
| 104 | +Current tests live in `src/tests/` and cover: |
105 | 105 |
|
106 | | -## ⚙️ Configuration |
| 106 | +- NGINX HTTP response |
| 107 | +- PHP runtime availability |
| 108 | +- CLI execution |
| 109 | +- write permissions under `/var/www` |
107 | 110 |
|
108 | | -You can configure build and runtime variables in `Makefile.variables`: |
| 111 | +## Configuration |
109 | 112 |
|
110 | | -- PHP and NGINX versions. _(Only PHP8.4 supported for now)_ |
111 | | -- Port mappings |
112 | | -- Source paths |
| 113 | +Primary defaults are in `Makefile.variables`: |
113 | 114 |
|
114 | | -Adjust these variables to suit your environment or specific deployment requirements. |
| 115 | +- `DOCKER_IMAGE` |
| 116 | +- `CONTAINER_NAME` |
| 117 | +- `HOST_PORT` / `CONTAINER_PORT` |
| 118 | +- `VOLUMES` |
| 119 | +- `PHP_VERSION` |
115 | 120 |
|
116 | | -## 🛠️ Makefile Commands Helper |
| 121 | +Container/runtime config files: |
117 | 122 |
|
118 | | -Use make to view all available commands: |
| 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` |
119 | 127 |
|
120 | | -``` |
| 128 | +## Development |
| 129 | + |
| 130 | +Useful commands: |
| 131 | + |
| 132 | +```bash |
121 | 133 | make help |
| 134 | +make build |
| 135 | +make run |
| 136 | +make log |
| 137 | +make clean |
| 138 | +make test |
122 | 139 | ``` |
123 | 140 |
|
124 | | -These commands offer options for building, running, and testing your application seamlessly. |
| 141 | +## Resources |
| 142 | + |
| 143 | +- Docker Hub: https://hub.docker.com/r/usabilitydynamics/udx-worker-php |
| 144 | +- Source: https://github.com/udx/worker-php |
| 145 | +- Base runtime docs: https://github.com/udx/worker/tree/latest/docs |
| 146 | +- Deployment config docs: https://github.com/udx/worker-deployment/blob/latest/docs/deploy-config.md |
125 | 147 |
|
126 | | -## 🤝 Contributing |
127 | | -We welcome contributions! Here's how you can help: |
| 148 | +## Contributing |
128 | 149 |
|
129 | 150 | 1. Fork the repository |
130 | 151 | 2. Create a feature branch |
131 | 152 | 3. Commit your changes |
132 | 153 | 4. Push to your branch |
133 | | -5. Open a Pull Request |
134 | | - |
135 | | -Please ensure your PR: |
136 | | -- Follows our coding standards |
137 | | -- Includes appropriate tests |
138 | | -- Updates relevant documentation |
139 | | - |
140 | | -## 🔗 Resources |
141 | | -- [Docker Hub](https://hub.docker.com/r/usabilitydynamics/udx-worker-php) |
142 | | -- [Product Page](https://udx.io/products/udx-worker-php) |
| 154 | +5. Open a pull request |
143 | 155 |
|
144 | | -## 🎯 Custom Development |
145 | | -Need specific features or customizations? |
146 | | -[Contact our team](https://udx.io/) for professional development services. |
| 156 | +Include relevant tests and documentation updates with your changes. |
147 | 157 |
|
148 | | -## 📄 License |
149 | | -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 158 | +## License |
150 | 159 |
|
151 | | ---- |
152 | | -<div align="center"> |
153 | | -Built by <a href="https://udx.io">UDX</a> © 2025 |
154 | | -</div> |
| 160 | +MIT. See [`LICENSE`](LICENSE). |
0 commit comments