From 051a471e631671fd69e1becac42aa9ca9bcc9144 Mon Sep 17 00:00:00 2001 From: Dmitry Smirnov Date: Wed, 29 Jan 2025 17:41:08 +0200 Subject: [PATCH 1/3] fixes for modules configs refs --- etc/configs/worker/{default.yml => default.yaml} | 0 etc/configs/worker/{services.yml => services.yaml} | 4 ++-- lib/process_manager.sh | 2 +- lib/worker_config.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename etc/configs/worker/{default.yml => default.yaml} (100%) rename etc/configs/worker/{services.yml => services.yaml} (77%) diff --git a/etc/configs/worker/default.yml b/etc/configs/worker/default.yaml similarity index 100% rename from etc/configs/worker/default.yml rename to etc/configs/worker/default.yaml diff --git a/etc/configs/worker/services.yml b/etc/configs/worker/services.yaml similarity index 77% rename from etc/configs/worker/services.yml rename to etc/configs/worker/services.yaml index 84f809b7..82f0fa44 100644 --- a/etc/configs/worker/services.yml +++ b/etc/configs/worker/services.yaml @@ -4,7 +4,7 @@ version: udx.io/worker-v1/service services: - name: "app_service" ignore: "true" - command: "sh /usr/local/scripts/main.sh" + command: "sh ./main.sh" autostart: "true" autorestart: "false" envs: @@ -12,7 +12,7 @@ services: - "KEY2=value2" - name: "another_service" ignore: "true" - command: "sh /usr/local/scripts/main.sh" + command: "sh ./main.sh" autostart: "true" autorestart: "true" envs: [] diff --git a/lib/process_manager.sh b/lib/process_manager.sh index 466947bf..44fc2c23 100644 --- a/lib/process_manager.sh +++ b/lib/process_manager.sh @@ -1,7 +1,7 @@ #!/bin/bash # Define paths -DEFAULT_CONFIG_FILE="/usr/local/configs/worker/services.yml" +DEFAULT_CONFIG_FILE="/usr/local/configs/worker/services.yaml" # Define the user-specific configuration path search # shellcheck disable=SC2227 USER_CONFIG_PATH=$(find "/home/$USER" -name 'services.yaml' 2>/dev/null -print | head -n 1) diff --git a/lib/worker_config.sh b/lib/worker_config.sh index 6d3acd5c..b2f8bd21 100644 --- a/lib/worker_config.sh +++ b/lib/worker_config.sh @@ -1,7 +1,7 @@ #!/bin/bash # Paths for configurations -BUILT_IN_CONFIG="/usr/local/configs/worker/default.yml" +BUILT_IN_CONFIG="/usr/local/configs/worker/default.yaml" # Dynamically find user configuration in any subfolder of /home/$USER # shellcheck disable=SC2227 USER_CONFIG=$(find "/home/$USER" -name 'worker.yaml' 2>/dev/null -print | head -n 1) From 6cb51dad3033aa1972ada04e05f11ed462151a3e Mon Sep 17 00:00:00 2001 From: Dmitry Smirnov Date: Wed, 29 Jan 2025 17:57:06 +0200 Subject: [PATCH 2/3] changed modules dir scan logic to /Users/jonyfq --- lib/process_manager.sh | 3 +-- lib/worker_config.sh | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/process_manager.sh b/lib/process_manager.sh index 44fc2c23..a56c2a9d 100644 --- a/lib/process_manager.sh +++ b/lib/process_manager.sh @@ -4,7 +4,7 @@ DEFAULT_CONFIG_FILE="/usr/local/configs/worker/services.yaml" # Define the user-specific configuration path search # shellcheck disable=SC2227 -USER_CONFIG_PATH=$(find "/home/$USER" -name 'services.yaml' 2>/dev/null -print | head -n 1) +USER_CONFIG_PATH=$(find "$HOME" -name 'services.yaml' 2>/dev/null -print | head -n 1) # Use the first user-specific config found; if none, use the default CONFIG_FILE="${USER_CONFIG_PATH:-$DEFAULT_CONFIG_FILE}" @@ -73,7 +73,6 @@ parse_service_info() { # Function to start Supervisor with the generated configuration start_supervisor() { - echo "Starting Supervisor with the generated configuration..." supervisord } diff --git a/lib/worker_config.sh b/lib/worker_config.sh index b2f8bd21..ea24cfd3 100644 --- a/lib/worker_config.sh +++ b/lib/worker_config.sh @@ -2,9 +2,9 @@ # Paths for configurations BUILT_IN_CONFIG="/usr/local/configs/worker/default.yaml" -# Dynamically find user configuration in any subfolder of /home/$USER +# Dynamically find user configuration in any subfolder of $HOME # shellcheck disable=SC2227 -USER_CONFIG=$(find "/home/$USER" -name 'worker.yaml' 2>/dev/null -print | head -n 1) +USER_CONFIG=$(find "$HOME" -name 'worker.yaml' 2>/dev/null -print | head -n 1) MERGED_CONFIG="/usr/local/configs/worker/merged_worker.yaml" # Utility functions for logging From c6c494d9666bb8e7664ebebedfb2bd4cbe0a0813 Mon Sep 17 00:00:00 2001 From: Dmitry Smirnov Date: Wed, 29 Jan 2025 18:19:10 +0200 Subject: [PATCH 3/3] build fixes --- Dockerfile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index ce997f61..d4ce29f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,20 +4,20 @@ FROM ubuntu:24.04 # Set the maintainer of the image LABEL maintainer="UDX CAG Team" -# Define the user to be created -ARG USER=udx -ARG UID=500 -ARG GID=500 - # Set environment variables to avoid interactive prompts and set a fixed timezone ENV DEBIAN_FRONTEND=noninteractive \ TZ=Etc/UTC \ - USER=${USER} \ - HOME=/home/${USER} + USER=udx \ + UID=500 \ + GID=500 \ + HOME=/home/udx # Set the shell with pipefail option SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# Set user to root for installation +USER root + # Install necessary packages RUN apt-get update && \ apt-get install -y --no-install-recommends \ @@ -110,9 +110,9 @@ RUN mkdir -p /var/log/supervisor /var/run/supervisor && \ chown -R ${USER}:${USER} /var/log/supervisor /var/run/supervisor # Copy the CLI tool into the image -COPY lib/cli.sh /usr/local/bin/udx_worker_mgmt -RUN chmod +x /usr/local/bin/udx_worker_mgmt && \ - ln -s /usr/local/bin/udx_worker_mgmt /usr/local/bin/worker +COPY lib/cli.sh /usr/local/bin/worker_mgmt +RUN chmod +x /usr/local/bin/worker_mgmt && \ + ln -s /usr/local/bin/worker_mgmt /usr/local/bin/worker # Copy the bin, etc, and lib directories COPY etc/home /etc