Skip to content

Commit

Permalink
Merge pull request #78 from udx/UAT-69
Browse files Browse the repository at this point in the history
Dynamic home dir detection for modules [UAT-69]
  • Loading branch information
fqjony authored Jan 29, 2025
2 parents 0441f60 + c6c494d commit 880002c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
20 changes: 10 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ 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:
- "KEY1=value1"
- "KEY2=value2"
- name: "another_service"
ignore: "true"
command: "sh /usr/local/scripts/main.sh"
command: "sh ./main.sh"
autostart: "true"
autorestart: "true"
envs: []
5 changes: 2 additions & 3 deletions lib/process_manager.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/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)
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}"
Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions lib/worker_config.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

# Paths for configurations
BUILT_IN_CONFIG="/usr/local/configs/worker/default.yml"
# Dynamically find user configuration in any subfolder of /home/$USER
BUILT_IN_CONFIG="/usr/local/configs/worker/default.yaml"
# 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
Expand Down

0 comments on commit 880002c

Please sign in to comment.