|
1 | | -# UDX Worker Node.js |
| 1 | +<img src="assets/logo.svg" alt="UDX Worker Node.js"> |
2 | 2 |
|
3 | 3 | [](https://hub.docker.com/r/usabilitydynamics/udx-worker-nodejs) [](LICENSE) |
4 | 4 |
|
5 | | -**A versatile Docker image for running Node.js applications with built-in process management, providing a ready-to-use environment to deploy and manage your JavaScript projects.** |
| 5 | +**Node.js runtime image built on UDX Worker.** |
6 | 6 |
|
7 | | -[Quick Start](#-quick-start) • [Development](#-development) • [Documentation](#-documentation) • [Contributing](#-contributing) |
| 7 | +[Quick Start](#quick-start) • [Usage](#usage) • [Development](#development) • [Resources](#resources) |
8 | 8 |
|
9 | | -## 🚀 Overview |
| 9 | +## Overview |
10 | 10 |
|
11 | | -UDX Worker Node.js is a specialized Docker image built on UDX Worker that provides: |
| 11 | +UDX Worker Node.js is a Docker image that provides a ready-to-use Node.js runtime with the same operational model as `udx/worker` (https://github.com/udx/worker). |
12 | 12 |
|
13 | | -- 🔧 **Node.js Runtime**: Ready-to-use environment for JavaScript applications |
14 | | -- 📦 **Process Management**: Built-in supervisor-based service management |
15 | | -- 🛠️ **Service Configuration**: YAML-based service definition and control |
16 | | -- 🔄 **Zero Downtime**: Seamless application updates and restarts |
17 | | -- 🏗️ **Base Image**: Built on `udx-worker` for secure, efficient operations |
| 13 | +## Quick Start |
18 | 14 |
|
19 | | -## 👨💻 Development |
| 15 | +Requirements: Docker and Node.js (for the CLI). |
20 | 16 |
|
21 | | -### 📋 Prerequisites |
22 | | - |
23 | | -- `Docker` installed and running on your system |
24 | | -- Node.js application code (optional) |
25 | | - |
26 | | -## 🚀 Quick Start |
27 | | - |
28 | | -### Example 1: Simple Service |
29 | | - |
30 | | -1. Create a service configuration in `.config/worker/services.yaml`: |
31 | | - |
32 | | -```yaml |
33 | | -kind: workerService |
34 | | -version: udx.io/worker-v1/service |
35 | | -services: |
36 | | - - name: "node-app" |
37 | | - command: "node index.js" |
38 | | - autostart: true |
39 | | - autorestart: true |
40 | | - envs: |
41 | | - - "PORT=3000" |
42 | | -``` |
43 | | -
|
44 | | -2. Pull and run the image: |
| 17 | +1. Install the deployment CLI ([@udx/worker-deployment](https://www.npmjs.com/package/@udx/worker-deployment)). |
45 | 18 |
|
46 | 19 | ```bash |
47 | | -docker pull usabilitydynamics/udx-worker-nodejs:latest |
48 | | -docker run -d --name my-node-app -p 3000:3000 -v $(pwd)/.config:/home/udx/.config usabilitydynamics/udx-worker-nodejs:latest |
49 | | -``` |
50 | | - |
51 | | -### Example 2: Custom Application |
52 | | - |
53 | | -1. Create your service configuration in `.config/worker/services.yaml`: |
54 | | - |
55 | | -```yaml |
56 | | -kind: workerService |
57 | | -version: udx.io/worker-v1/service |
58 | | -services: |
59 | | - - name: "api-server" |
60 | | - command: "node api/server.js" |
61 | | - autostart: true |
62 | | - autorestart: true |
63 | | - envs: |
64 | | - - "PORT=3000" |
65 | | - - "NODE_ENV=production" |
66 | | - - name: "worker-queue" |
67 | | - command: "node worker.js" |
68 | | - autostart: true |
69 | | - envs: |
70 | | - - "QUEUE_URL=redis://localhost:6379" |
| 20 | +npm install -g @udx/worker-deployment |
71 | 21 | ``` |
72 | 22 |
|
73 | | -2. Create a `docker-compose.yml`: |
74 | | - |
75 | | -```yaml |
76 | | -version: '3' |
77 | | -services: |
78 | | - app: |
79 | | - image: usabilitydynamics/udx-worker-nodejs:latest |
80 | | - volumes: |
81 | | - - ./:/usr/src/app |
82 | | - - ./.config:/home/udx/.config |
83 | | - ports: |
84 | | - - "3000:3000" |
85 | | -``` |
86 | | - |
87 | | -### Development Setup |
88 | | - |
89 | | -1. Clone this repository: |
| 23 | +2. Generate a config and edit `deploy.yml` for your app. |
90 | 24 |
|
91 | | -``` |
92 | | -git clone https://github.com/udx/udx-worker-nodejs.git |
93 | | -cd udx-worker-nodejs |
| 25 | +```bash |
| 26 | +worker config |
94 | 27 | ``` |
95 | 28 |
|
96 | | -2. Build the Docker image: |
| 29 | +3. Run the container. |
97 | 30 |
|
| 31 | +```bash |
| 32 | +worker run |
98 | 33 | ``` |
99 | | -make build |
100 | | -``` |
101 | | - |
102 | | -3. Run Tests to verify functionality: |
103 | 34 |
|
104 | | -``` |
105 | | -make run-all-tests |
106 | | -``` |
| 35 | +## Usage |
107 | 36 |
|
108 | | -You can add additional tests in the `src/tests/` directory as needed. |
| 37 | +- Deploy configuration: https://github.com/udx/worker-deployment/blob/latest/docs/deploy-config.md |
109 | 38 |
|
110 | | -## ⚙️ Configuration |
| 39 | +- Service configuration: https://github.com/udx/worker/blob/latest/docs/runtime/services.md |
111 | 40 |
|
112 | | -You can configure build and runtime variables in `Makefile.variables`: |
| 41 | +- Runtime config and secrets: https://github.com/udx/worker/blob/latest/docs/runtime/config.md |
113 | 42 |
|
114 | | -- Node.js version. _(Node.js 20.x LTS supported by default)_ |
115 | | -- Port mappings |
116 | | -- Source paths |
| 43 | +### Examples |
117 | 44 |
|
118 | | -Adjust these variables to suit your environment or specific deployment requirements. |
| 45 | +- `src/examples/simple-server` is included as a minimal sample. |
119 | 46 |
|
120 | | -## 🛠️ Makefile Commands Helper |
| 47 | +## Development |
121 | 48 |
|
122 | | -Use make to view all available commands: |
| 49 | +```bash |
| 50 | +git clone https://github.com/udx/worker-nodejs.git |
| 51 | +cd worker-nodejs |
123 | 52 |
|
| 53 | +make build |
| 54 | +make test |
124 | 55 | ``` |
125 | | -make help |
126 | | -``` |
127 | | - |
128 | | -These commands offer options for building, running, and testing your application seamlessly. |
129 | | - |
130 | | -## 📚 Documentation |
131 | | - |
132 | | -### 🔧 Based on udx-worker |
133 | | - |
134 | | -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 Node.js applications. |
135 | 56 |
|
136 | | -### Core Concepts |
| 57 | +To run a single test: |
137 | 58 |
|
138 | | -- **Process Management**: Uses supervisor-based worker process manager |
139 | | -- **Service Configuration**: Defined through `services.yaml` |
140 | | -- **Configuration**: Customizable through `Makefile.variables` |
141 | | - |
142 | | -### Additional Resources |
143 | | - |
144 | | -- Build variables can be configured in `Makefile.variables` |
145 | | -- View available commands with `make help` |
146 | | -- Test examples available in `src/tests/` |
| 59 | +```bash |
| 60 | +make run-test TEST_SCRIPT=10_validate_environment.sh |
| 61 | +``` |
147 | 62 |
|
148 | | -## 🛠️ Development |
| 63 | +Build defaults for contributors live in `Makefile.variables` (Node.js version, ports, build args). |
149 | 64 |
|
150 | | -Contribute to the project: |
| 65 | +## Resources |
151 | 66 |
|
152 | | -1. Fork the repository |
153 | | -2. Create your feature branch |
154 | | -3. Submit a pull request |
| 67 | +- Base image docs: https://github.com/udx/worker/tree/latest/docs |
| 68 | +- Deployment CLI: https://github.com/udx/worker-deployment/tree/latest/docs |
| 69 | +- Docker Hub: https://hub.docker.com/r/usabilitydynamics/udx-worker-nodejs |
155 | 70 |
|
156 | | -## 🤝 Contributing |
157 | | -We welcome contributions! Here's how you can help: |
| 71 | +## Contributing |
158 | 72 |
|
159 | 73 | 1. Fork the repository |
160 | 74 | 2. Create a feature branch |
161 | 75 | 3. Commit your changes |
162 | 76 | 4. Push to your branch |
163 | 77 | 5. Open a Pull Request |
164 | 78 |
|
165 | | -Please ensure your PR: |
166 | | -- Follows our coding standards |
167 | | -- Includes appropriate tests |
168 | | -- Updates relevant documentation |
169 | | - |
170 | | -## 🔗 Resources |
171 | | -- [Docker Hub](https://hub.docker.com/r/usabilitydynamics/udx-worker-nodejs) |
172 | | -- [UDX Worker Documentation](https://github.com/udx/worker) |
173 | | -- [Product Page](https://udx.io/products/udx-worker-nodejs) |
174 | | - |
175 | | -## 🎯 Custom Development |
176 | | -Need specific features or customizations? |
177 | | -[Contact our team](https://udx.io/) for professional development services. |
178 | | - |
179 | | -## 📄 License |
180 | | -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 79 | +Please ensure your PR includes appropriate tests and documentation updates. |
181 | 80 |
|
182 | 81 | --- |
| 82 | + |
183 | 83 | <div align="center"> |
184 | 84 | Built by <a href="https://udx.io">UDX</a> © 2025 |
185 | | -</div> |
| 85 | +</div> |
0 commit comments