### Build and Run UDX Worker for Development Source: https://github.com/udx/worker/blob/latest/README.md This example outlines the steps for setting up a development environment for UDX Worker, including cloning the repository, building the image, running the container, viewing logs, and executing tests using `make` commands. ```bash # Clone and build git clone https://github.com/udx/worker.git cd worker make build # Run example service make run VOLUMES="$(pwd)/src/examples/simple-service:/home/udx" # View logs make log FOLLOW_LOGS=true # Run tests make test ``` -------------------------------- ### Development Setup and Commands for UDX Worker Source: https://github.com/udx/worker/blob/latest/README.md This snippet provides essential `make` commands for UDX Worker development, including cloning the repository, building the Docker image, running the container in detached or interactive modes, executing tests, and viewing available commands. ```bash # Clone repository git clone https://github.com/udx/worker.git cd worker # Build image make build # Run container make run # Detached mode make run-it # Interactive mode # Run tests make test # View all commands make help ``` -------------------------------- ### Configure and Run UDX Worker with Secret References Source: https://github.com/udx/worker/blob/latest/README.md This example shows how to define secret references in `worker.yaml` and run the UDX Worker container, which will resolve these secrets from cloud providers. It includes a command to verify that the secrets are resolved correctly without exposing their values. ```bash # Define secrets configuration cat > .config/worker/worker.yaml <<'EOF' kind: workerConfig version: udx.io/worker-v1/config config: secrets: API_KEY: "gcp/my-project/api-key" DB_PASS: "aws/database-password/us-west-2" EOF # Run with provider auth injected by the host/platform docker run -d \ --name my-secrets \ -v "$(pwd)/.config/worker:/home/udx/.config/worker" \ usabilitydynamics/udx-worker:latest # Verify the resolved environment without printing the secret value docker exec my-secrets sh -lc 'worker env show --filter API_KEY --format json | jq -e "'has(\"API_KEY\") and .API_KEY != """ >/dev/null' ``` -------------------------------- ### Dockerfile for Child Image Source: https://github.com/udx/worker/blob/latest/docs/child-images.md This Dockerfile extends the base UDX worker image and installs the 'jq' package. Use this to add specific dependencies required by your workload. ```dockerfile FROM usabilitydynamics/udx-worker:latest RUN apt-get update && apt-get install -y jq ``` -------------------------------- ### Test the Core Worker Image Source: https://github.com/udx/worker/blob/latest/docs/core-image.md Runs container-based tests for the worker image. This command mounts test and example configurations into the container to execute the test script. ```bash make test ``` -------------------------------- ### Runtime Environment Precedence Override Source: https://github.com/udx/worker/blob/latest/docs/config.md Demonstrates how deployment environment variables override worker.yaml configurations. The example shows a default secret in worker.yaml being overridden by an environment variable during a Docker run command. ```yaml # worker.yaml (production defaults) config: secrets: ES_PASSWORD: "gcp/prod-project/es-password" ``` ```bash docker run --rm \ -e ES_PASSWORD="gcp/staging-project/es-password" \ usabilitydynamics/udx-worker:latest ``` -------------------------------- ### Create and Run a Simple Service with UDX Worker Source: https://github.com/udx/worker/blob/latest/README.md This snippet demonstrates how to set up a project structure, create a simple service script, define its configuration in `services.yaml`, and run it using the UDX Worker Docker image. It also shows how to view the service logs. ```bash # Create project structure mkdir -p my-worker/.config/worker cd my-worker # Create a simple service script cat > index.sh <<'EOF' #!/bin/bash echo "Starting service..." trap 'echo "Shutting down..."; exit 0' SIGTERM while true; do echo "[$(date)] Service running..." sleep 5 done EOF chmod +x index.sh # Create service configuration cat > .config/worker/services.yaml <<'EOF' kind: workerService version: udx.io/worker-v1/service services: - name: "index" command: "/home/udx/index.sh" autostart: true autorestart: true EOF # Run the worker docker run -d \ --name my-service \ -v "$(pwd):/home/udx" \ usabilitydynamics/udx-worker:latest # View service logs docker logs -f my-service ``` -------------------------------- ### Basic Service Configuration Source: https://github.com/udx/worker/blob/latest/docs/services.md Defines a simple web server service with autostart and autorestart enabled, and sets environment variables. ```yaml kind: workerService version: udx.io/worker-v1/service services: - name: "web-server" command: "python app.py" autostart: true autorestart: true envs: - "PORT=8080" - "DEBUG=true" ``` -------------------------------- ### Show Service Command Help Source: https://github.com/udx/worker/blob/latest/docs/cli.md Displays help information for the `worker service` command. Use this to understand available service management options. ```bash worker service ``` -------------------------------- ### Child Image Placement for Python Source: https://github.com/udx/worker/blob/latest/docs/references/container-structure.md Demonstrates the recommended directory structure for a child image containing a Python application, ensuring worker directories are preserved. ```text / ├── usr/src/app/ # Python application code └── opt/worker/ # Worker directories (preserved) ``` -------------------------------- ### Run the Core Worker Image Source: https://github.com/udx/worker/blob/latest/docs/core-image.md Runs the worker image locally, mounting configurations. Use `make run-it` for an interactive shell or `make log FOLLOW_LOGS=true` to follow logs. ```bash make run ``` ```bash make run-it ``` ```bash make log FOLLOW_LOGS=true ``` -------------------------------- ### Child Image Placement for Node.js Source: https://github.com/udx/worker/blob/latest/docs/references/container-structure.md Illustrates the recommended directory structure for a child image containing a Node.js application, ensuring worker directories are preserved. ```text / ├── usr/src/app/ # Node.js application code └── opt/worker/ # Worker directories (preserved) ``` -------------------------------- ### Service with Command-Line Arguments Source: https://github.com/udx/worker/blob/latest/docs/services.md Configures a job-runner service that accepts command-line arguments for its configuration path, mode, and retry count. ```yaml kind: workerService version: udx.io/worker-v1/service services: - name: "job-runner" command: >- /home/udx/bin/job-runner.sh --config-path=/etc/app/config.json --mode=sync --retry=3 autostart: true autorestart: true ``` -------------------------------- ### Child Image Placement for PHP Source: https://github.com/udx/worker/blob/latest/docs/references/container-structure.md Shows the recommended directory structure for a child image containing a PHP application, ensuring worker directories are preserved. ```text / ├── var/www/ # PHP application code └── opt/worker/ # Worker directories (preserved) ``` -------------------------------- ### Base Directory Structure Source: https://github.com/udx/worker/blob/latest/docs/references/container-structure.md Illustrates the default directory layout within the UDX Worker container, highlighting key locations for worker internals and configurations. ```text / ├── opt/worker/ # Base directory for worker-specific files │ ├── apps/ # Worker applications and plugins │ └── data/ # Worker data storage and processing ├── etc/worker/ # Worker configuration files ├── usr/local/worker/ │ ├── bin/ # Worker executable files │ ├── lib/ # Worker library files │ └── etc/ # Additional worker configuration └── usr/local/configs/ # Cloud provider configurations ├── gcloud/ # Google Cloud SDK config ├── aws/ # AWS CLI config └── azure/ # Azure CLI config ``` -------------------------------- ### Mount Worker Simple Config using Docker Source: https://github.com/udx/worker/blob/latest/src/examples/simple-config/README.md Demonstrates how to run the UDX Worker with a simple configuration mounted into the container. This command uses Docker to mount the local configuration directory into the expected path within the container. Ensure you are in the correct directory before running. ```bash docker run -d \ --name worker-simple-config \ -v "$(pwd)/src/examples/simple-config/.config/worker:/home/udx/.config/worker" \ usabilitydynamics/udx-worker:latest ``` -------------------------------- ### Build Custom Child Image Source: https://github.com/udx/worker/blob/latest/docs/child-images.md Build and tag your custom child image using Docker. Ensure you use a descriptive tag for easy identification. ```bash docker build -t my-org/udx-worker-custom:latest . ``` -------------------------------- ### Service Reading Environment Variables Source: https://github.com/udx/worker/blob/latest/docs/services.md Defines a service that prints the value of the `SERVICE_NAME` environment variable before executing its startup script. ```yaml kind: workerService version: udx.io/worker-v1/service services: - name: "print-service-name" command: >- bash -lc 'echo "SERVICE_NAME=$SERVICE_NAME"; exec /home/udx/bin/start.sh' autostart: true autorestart: true envs: - "SERVICE_NAME=worker-api" ``` -------------------------------- ### Run Simple Service Container Source: https://github.com/udx/worker/blob/latest/src/examples/simple-service/README.md Runs a Docker container for the UDX worker service. It mounts the local scripts directory and configuration directory into the container. ```bash docker run -d \ --name my-service \ -v "$(pwd)/src/examples/simple-service:/home/udx" \ -v "$(pwd)/.config/worker:/home/udx/.config/worker" \ usabilitydynamics/udx-worker:latest ``` -------------------------------- ### Build the Core Worker Image Source: https://github.com/udx/worker/blob/latest/docs/core-image.md Builds the `usabilitydynamics/udx-worker` image. Common options include setting the Docker image name, enabling multi-platform builds, or enabling debug output. ```bash make build ``` -------------------------------- ### Run UDX Worker with a Custom Docker Image Source: https://github.com/udx/worker/blob/latest/docs/deployment.md This command demonstrates running a custom UDX worker Docker image. It's similar to the standard deployment but uses a different image name. ```bash docker run --rm \ -v "$(pwd)/.config/worker:/home/udx/.config/worker:ro" \ my-org/udx-worker-custom:latest ``` -------------------------------- ### Basic Worker Configuration Source: https://github.com/udx/worker/blob/latest/docs/config.md Defines basic environment variables and secret references for the worker. Secrets are resolved at startup. ```yaml kind: workerConfig version: udx.io/worker-v1/config config: env: APP_MODE: "worker" AWS_REGION: "us-west-2" secrets: DB_PASSWORD: "aws/db-password/us-west-2" API_KEY: "azure/kv-prod/api-key" ``` -------------------------------- ### Viewing Service Logs and Errors Source: https://github.com/udx/worker/blob/latest/docs/services.md Commands to view the logs and errors of a running service. Use `--tail` to limit output and `--follow` to stream logs. ```bash worker service logs logger --tail 100 --follow ``` ```bash worker service errors logger --tail 100 --follow ``` -------------------------------- ### Docker Dependency Changelog Template Source: https://github.com/udx/worker/blob/latest/ci/prompts/docker-dependency-output.md Use this template to format your Docker dependency changelogs. It includes sections for updated, unchanged, and observed dependencies, as well as a notes section. ```text Docker dependency changelog Updated: - : -> () Unchanged: - : () Observed but not pinned: - : () Notes: - ``` -------------------------------- ### Run UDX Worker Locally with Docker Source: https://github.com/udx/worker/blob/latest/docs/deployment.md Use this command to run the UDX worker locally using Docker. It mounts the local configuration directory into the container and sets an environment variable for API key. ```bash docker run --rm \ -v "$(pwd)/.config/worker:/home/udx/.config/worker:ro" \ -e API_KEY="gcp/my-project/api-key" \ usabilitydynamics/udx-worker:latest ``` -------------------------------- ### Run Worker and Capture Runtime Output Source: https://github.com/udx/worker/blob/latest/docs/runtime-output.md This command runs the UDX worker container and redirects its stdout to a JSON file, capturing the runtime output contract. Ensure the WORKER_RUNTIME_OUTPUT environment variable is set to true. ```bash docker run \ -e WORKER_RUNTIME_OUTPUT=true \ usabilitydynamics/udx-worker:latest > runtime-output/runtime.json ``` -------------------------------- ### Validate Runtime Contract Artifact Source: https://github.com/udx/worker/blob/latest/docs/runtime-output.md These commands use `jq` to validate the structure of the captured runtime output JSON. They check if the 'env' field is an object and the 'redacted' field is an array, confirming the presence and type of key contract elements. ```bash jq -e '.env | type == "object"' runtime-output/runtime.json ``` ```bash jq -e '.redacted | type == "array"' runtime-output/runtime.json ``` -------------------------------- ### Resolve a Single Secret Reference Source: https://github.com/udx/worker/blob/latest/docs/secrets.md Manually resolve a specific secret reference from the command line. ```bash worker env resolve gcp/my-project/api-key ``` -------------------------------- ### Service Writing to Stdout Source: https://github.com/udx/worker/blob/latest/docs/services.md Configures a logger service that continuously writes to stdout. Use `worker service logs` to view its output. ```yaml kind: workerService version: udx.io/worker-v1/service services: - name: "logger" command: >- bash -lc 'echo "[startup] logger"; while true; do echo "[tick] $(date)"; sleep 5; done' autostart: true autorestart: true ``` -------------------------------- ### Two Independent Concurrent Services Source: https://github.com/udx/worker/blob/latest/docs/services.md Defines two independent services, serviceA and serviceB, that run concurrently. Each service has its own environment variables and logs. ```yaml kind: workerService version: udx.io/worker-v1/service services: - name: "serviceA" command: >- bash -lc 'echo "starting $SERVICE_NAME"; exec /home/udx/bin/service_a.sh' autostart: true autorestart: true envs: - "SERVICE_NAME=serviceA" - "LOG_LEVEL=info" - name: "serviceB" command: >- bash -lc 'echo "starting $SERVICE_NAME"; exec /home/udx/bin/service_b.sh' autostart: true autorestart: true envs: - "SERVICE_NAME=serviceB" - "LOG_LEVEL=warn" ``` -------------------------------- ### Define a Simple Worker Service Source: https://github.com/udx/worker/blob/latest/src/examples/simple-service/README.md Defines a worker service named 'long-running' that executes a shell script. The service is configured to autostart and autorestart. ```yaml kind: workerService version: udx.io/worker-v1/service services: - name: "long-running" command: "/home/udx/10_long_running.sh" autostart: true autorestart: true ``` -------------------------------- ### Define Secrets in worker.yaml Source: https://github.com/udx/worker/blob/latest/docs/secrets.md Map environment variable names to provider references within the worker configuration file. ```yaml kind: workerConfig version: udx.io/worker-v1/config config: secrets: DB_PASSWORD: "azure/kv-prod/db-password" API_KEY: "gcp/my-project/api-key" env: DATABASE_URL: "aws/database-url/us-west-2" ``` -------------------------------- ### Inspect Resolved Environment Status Source: https://github.com/udx/worker/blob/latest/docs/cli.md Shows the current status of the resolved environment variables. Useful for debugging or verifying environment configurations. ```bash worker env status ``` -------------------------------- ### Run Worker for Contract Only and Exit Source: https://github.com/udx/worker/blob/latest/docs/runtime-output.md This command runs the UDX worker container with the runtime output enabled and immediately exits after capturing the contract. Use this when the workflow only needs the contract and no other worker processes are required. ```bash docker run --rm \ -e WORKER_RUNTIME_OUTPUT=true \ usabilitydynamics/udx-worker:latest \ true > runtime-output/runtime.json ``` -------------------------------- ### Re-apply Worker Configuration Source: https://github.com/udx/worker/blob/latest/docs/cli.md Reloads and re-applies the worker configuration, including environment variables and secrets, after provider authentication has been established. This is equivalent to the resolution path used by the entrypoint. ```bash worker env reload ``` -------------------------------- ### Static Environment Variable and Secret Reference Source: https://github.com/udx/worker/blob/latest/docs/config.md Injects a static environment variable directly and references a secret to be resolved at runtime. This is useful for development or specific configurations. ```yaml kind: workerConfig version: udx.io/worker-v1/config config: env: API_KEY: "dev-only-static-key" secrets: DB_PASSWORD: "azure/kv-prod/db-password" ``` -------------------------------- ### Check Service Logs Source: https://github.com/udx/worker/blob/latest/src/examples/simple-service/README.md Retrieves the logs for a specific service named 'long-running' managed by the worker service. ```bash worker service logs long-running ``` -------------------------------- ### Re-resolve Secrets After Internal Authentication Source: https://github.com/udx/worker/blob/latest/docs/secrets.md Rerun worker secret resolution after authenticating with provider-native tooling inside the container. This is useful for development, testing, or validation workflows. ```bash worker env reload ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.