### Minimal deploy.yml Configuration Example Source: https://context7.com/udx/worker-deployment/llms.txt Provides a basic example of a `deploy.yml` file, demonstrating essential configuration for running a Docker container, including image, volumes, environment variables, and command. ```yaml # Minimal deploy.yml configuration kind: workerDeployConfig version: udx.io/worker-v1/deploy config: image: "usabilitydynamics/udx-worker:latest" volumes: - "./:/workspace" env: DEBUG: "true" command: "worker" args: - "run" - "my-task" ``` -------------------------------- ### Install and Verify @udx/worker-deployment Source: https://context7.com/udx/worker-deployment/llms.txt Installs the worker-deployment package globally using npm and provides a command to verify the installation by displaying the help message. ```bash # Global installation npm install -g @udx/worker-deployment # Verify installation worker --help ``` -------------------------------- ### Full deploy.yml Configuration Example Source: https://context7.com/udx/worker-deployment/llms.txt Illustrates a comprehensive `deploy.yml` configuration file, showcasing all available options such as environment variables, volume mounts, port mappings, container naming, and GCP service account settings. ```yaml # Full deploy.yml with all options kind: workerDeployConfig version: udx.io/worker-v1/deploy config: # Docker image (required) image: "usabilitydynamics/udx-worker:latest" # Environment variables env: DEBUG: "true" PROJECT_NAME: "my-project" LOG_LEVEL: "info" # Volume mounts (host:container or host:container:ro) volumes: - "./:/workspace" - "./data:/data:ro" # Command to run (optional - uses container default if omitted) command: "node" # Arguments passed to command args: - "-e" - "console.log('hello_world')" # Port mappings ports: - "8080:80" - "443:443" # Docker network network: "my-custom-network" # Container name (optional - Docker auto-generates if omitted) container_name: "my-worker-container" # GCP Service Account (optional) service_account: # Option 1: Custom key file path key_path: "./path/to/service-account-key.json" # Option 2: Token file path (for Workload Identity) # token_path: "./path/to/credentials.json" # Option 3: Use impersonation (requires gcloud auth) # email: "worker-sa@my-project.iam.gserviceaccount.com" ``` -------------------------------- ### Install Worker Deploy CLI Source: https://github.com/udx/worker-deployment/blob/latest/README.md Installs the Worker Deploy CLI globally using npm. This command requires Node.js and npm to be installed on your system. ```bash npm install -g @udx/worker-deployment ``` -------------------------------- ### Worker Deployment with Command and Args (YAML) Source: https://github.com/udx/worker-deployment/blob/latest/docs/deploy-config.md Recommended for handling special characters in commands, this example explicitly defines the command and its arguments. It's particularly useful for scripting or executing specific code snippets. ```yaml config: image: "usabilitydynamics/udx-worker-nodejs:latest" command: "node" args: - "-e" - "console.log('hello_world')" ``` -------------------------------- ### Complete Workflow: Generate, Configure, and Run Worker Source: https://context7.com/udx/worker-deployment/llms.txt An end-to-end bash script demonstrating the setup of a new worker project. It covers generating the deployment configuration, editing it, previewing the execution, running the container, and entering an interactive debugging shell. ```bash # Step 1: Generate deployment configuration worker config # Output: Config template created: deploy.yml # Step 2: Edit deploy.yml with your settings cat > deploy.yml << 'EOF' kind: workerDeployConfig version: udx.io/worker-v1/deploy config: image: "usabilitydynamics/udx-worker-nodejs:latest" volumes: - "./:/workspace" env: NODE_ENV: "development" DEBUG: "true" command: "node" args: - "-e" - "console.log('Hello from worker!')" EOF # Step 3: Preview execution worker run --dry-run # Output: Shows docker run command that would be executed # Step 4: Run container worker run # Output: Hello from worker! # Step 5: Interactive debugging worker run run-it # Opens shell inside container ``` -------------------------------- ### Generate deploy.yml Configuration Template Source: https://context7.com/udx/worker-deployment/llms.txt Generates a `deploy.yml` configuration template file. Supports custom filenames, forcing overwrites, and execution via npx without global installation. ```bash # Generate default deploy.yml worker config # Generate with custom filename worker config --output=my-deployment.yml # Force overwrite existing file worker config --force # Using npx without installation npx @udx/worker-deployment worker config ``` -------------------------------- ### Minimal Worker Deployment Configuration (YAML) Source: https://github.com/udx/worker-deployment/blob/latest/docs/deploy-config.md A basic example of a worker deployment configuration. It specifies the image, a volume mount, an environment variable, and the command to run. ```yaml kind: workerDeployConfig version: udx.io/worker-v1/deploy config: image: "usabilitydynamics/udx-worker:latest" volumes: - "./:/workspace" env: DEBUG: "true" command: "worker" args: - "run" - "my-task" ``` -------------------------------- ### Run Worker Deploy CLI with npx Source: https://github.com/udx/worker-deployment/blob/latest/README.md Executes Worker Deploy CLI commands directly using npx without a global installation. This is useful for trying out the tool or running commands occasionally. Requires Node.js and npm. ```bash npx @udx/worker-deployment worker config npx @udx/worker-deployment worker run ``` -------------------------------- ### Worker Deploy CLI Commands Source: https://github.com/udx/worker-deployment/blob/latest/README.md A list of available commands for the Worker Deploy CLI. These commands allow for configuration generation, container execution, previewing deployments, and managing worker images. Requires the CLI to be installed or run via npx. ```bash # Generate config template worker config # Run your container worker run # Preview without executing worker run --dry-run # Interactive mode (shell access) worker run run-it # Use custom config file worker run --config=custom.yml # Generate child image repo (dry-run + prompt) worker gen repo # Generate Dockerfile only (dry-run + prompt) worker gen dockerfile # List worker images from GitHub/Docker Hub worker images --all ``` -------------------------------- ### Generate Worker Repository Skeleton using npx Source: https://github.com/udx/worker-deployment/blob/latest/docs/commands/worker-gen.md This command generates a skeleton for a child image repository using the '@udx/worker-deployment' package. It sets up the basic structure for a new worker image, including necessary files and directories. The command utilizes npx to execute the package without global installation. ```bash npx @udx/worker-deployment worker gen repo ``` -------------------------------- ### Prerequisites and Execution for Service Account Impersonation Source: https://context7.com/udx/worker-deployment/llms.txt Provides bash commands to set up Google Cloud authentication and grant necessary IAM permissions for service account impersonation. It then shows how to run a worker with these credentials. ```bash # Prerequisites for impersonation # 1. Authenticate with gcloud gcloud auth login gcloud auth application-default login # 2. Grant impersonation permission (run once) gcloud iam service-accounts add-iam-policy-binding \ worker-sa@my-project.iam.gserviceaccount.com \ --member="user:$(gcloud config get-value account)" \ --role="roles/iam.serviceAccountTokenCreator" \ --project=my-project # 3. Run with impersonation worker run ``` -------------------------------- ### Scaffold New Worker Project Repository Source: https://context7.com/udx/worker-deployment/llms.txt Bash commands to create a new worker project with a complete repository structure. This includes generating a Dockerfile, README, Makefile, .dockerignore, and configuration files for worker services. ```bash # Create a child image project mkdir my-worker && cd my-worker # Generate complete repository structure worker gen repo --name=my-worker --apply # Creates: Dockerfile, README.md, Makefile, .dockerignore, # .config/worker/worker.yaml, .config/worker/services.yaml # Build the image make build # Output: Successfully built usabilitydynamics/udx-worker-child:latest # Run the image make run # Debug with shell access make shell ``` -------------------------------- ### Scaffold Child Image Repository Source: https://context7.com/udx/worker-deployment/llms.txt Generates template files for child image repositories, including Dockerfile, Makefile, and worker configuration. Supports various generation options, applying changes, and using npx. ```bash # Generate complete repo skeleton (dry-run with prompt) worker gen repo # Generate only Dockerfile worker gen dockerfile # Generate worker.yaml configuration worker gen worker.yaml # Generate services.yaml for service definitions worker gen services.yaml # Apply changes without prompting worker gen repo --apply # Custom base image and output directory worker gen dockerfile --base=usabilitydynamics/udx-worker-nodejs:latest --output-dir=./my-worker --apply # Full repo with custom project name worker gen repo --name=my-custom-worker --apply --force # Using npx npx @udx/worker-deployment worker gen repo --apply ``` -------------------------------- ### Generate Dockerfile Template for Worker Image Source: https://context7.com/udx/worker-deployment/llms.txt A Dockerfile template generated by `worker gen dockerfile` that extends a base worker image. It sets up the application directory, ownership, and working directory, and defines the entrypoint and default command. ```dockerfile # Generated Dockerfile from worker gen dockerfile FROM usabilitydynamics/udx-worker:latest LABEL maintainer="UDX" ENV APP_HOME="/usr/src/app" USER root RUN mkdir -p "/usr/src/app" && \ chown -R "${USER}:${USER}" "/usr/src/app" && \ chmod -R 755 "/usr/src/app" USER "${USER}" WORKDIR "/usr/src/app" # Use the parent image's entrypoint ENTRYPOINT ["/usr/local/worker/bin/entrypoint.sh"] # Default command (override in your runtime) CMD ["tail", "-f", "/dev/null"] ``` -------------------------------- ### Execute Docker Container with deploy.yml Source: https://context7.com/udx/worker-deployment/llms.txt Runs a Docker container based on the `deploy.yml` configuration. Features include dry-run mode, interactive shell access, using custom configuration files, and execution via npx. ```bash # Run container with default deploy.yml worker run # Preview command without executing worker run --dry-run # Run interactively with shell access worker run run-it # Use custom configuration file worker run --config=staging-deploy.yml # Using npx npx @udx/worker-deployment worker run --dry-run ``` -------------------------------- ### Service Definitions (services.yaml) Source: https://context7.com/udx/worker-deployment/llms.txt Defines multiple services to be run within a single worker container. Each service entry specifies its name, command, and restart policies, along with environment variables specific to that service. ```yaml # .config/worker/services.yaml kind: workerService version: udx.io/worker-v1/service services: - name: "web-server" command: "node server.js" autostart: true autorestart: true envs: - "PORT=3000" - "LOG_LEVEL=info" - name: "background-worker" command: "node worker.js" autostart: true autorestart: true envs: - "QUEUE_URL=redis://localhost:6379" ``` -------------------------------- ### Discover Worker Images on GitHub and Docker Hub Source: https://context7.com/udx/worker-deployment/llms.txt Searches for available worker images across GitHub and Docker Hub within the UDX organization. Allows filtering by source, limiting results, writing to a file, and execution via npx. ```bash # Search both GitHub and Docker Hub (default) worker images --all # Search only GitHub worker images --github # Search only Docker Hub worker images --dockerhub # Limit results worker images --all --limit=20 # Write results to file worker images --all --output=available-images.txt --apply # Using npx npx @udx/worker-deployment worker images --all ``` -------------------------------- ### Deploy Worker Configuration with Service Account Impersonation Source: https://context7.com/udx/worker-deployment/llms.txt Defines worker deployment configuration, including the container image, service account for impersonation, volume mounts, and the command to execute. This is used to set up how a worker service will be deployed. ```yaml kind: workerDeployConfig version: udx.io/worker-v1/deploy config: image: "usabilitydynamics/udx-worker:latest" service_account: email: "worker-sa@my-project.iam.gserviceaccount.com" volumes: - "./:/workspace" command: "worker" args: - "deploy" - "--env=staging" ``` -------------------------------- ### Execute Worker Container Source: https://github.com/udx/worker-deployment/blob/latest/docs/commands/worker-run.md This command initiates the execution of a Docker container as defined in the 'deploy.yml' file. It automatically manages and applies necessary credentials for the container's operation. The command can be run directly or through npx. ```bash worker run ``` ```bash npx @udx/worker-deployment worker run ``` -------------------------------- ### Worker Deployment Using Container Default Command (YAML) Source: https://github.com/udx/worker-deployment/blob/latest/docs/deploy-config.md This configuration relies on the container's default command and entrypoint. It's useful when the container image is designed to be self-executable. ```yaml config: image: "usabilitydynamics/udx-worker:latest" volumes: - "./:/workspace" # No command specified - uses container's default CMD/ENTRYPOINT ``` -------------------------------- ### Worker Deployment with Service Account Impersonation (YAML) Source: https://github.com/udx/worker-deployment/blob/latest/docs/deploy-config.md This configuration demonstrates how to set up service account impersonation for the worker. It allows the worker to act with the permissions of a specified service account. ```yaml config: image: "usabilitydynamics/udx-worker:latest" service_account: email: "worker-sa@my-project.iam.gserviceaccount.com" volumes: - "./:/workspace" command: "worker" args: - "deploy" - "--env=staging" ``` -------------------------------- ### Worker Configuration (worker.yaml) Source: https://context7.com/udx/worker-deployment/llms.txt Defines environment variables and secrets for worker containers using a `workerConfig` kind. This file specifies runtime configurations like log levels and references to secrets stored in GCP. ```yaml # .config/worker/worker.yaml kind: workerConfig version: udx.io/worker-v1/config config: env: LOG_LEVEL: "info" NODE_ENV: "production" secrets: DB_PASSWORD: "gcp/my-project/db-password" API_KEY: "gcp/my-project/api-key" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.