Repository: Learnathon-By-Geeky-Solutions/byte-bandit
Pull request #187: chore: refactored run-services.sh and docker-compose.apps.yml
Author: login: voidCounter
Labels: name: ready for review
description: When all checks are passed on a pull request and there is no unresolved conversation.
Created: 2025-04-11T20:15:07Z | Merged: 2025-04-12T04:55:53Z

### Description
This PR introduces a robust CLI wrapper for `docker compose` operations:
- Added profiles to services in the docker-compose of `docker-compose.apps.yml`.
- Adds support for `start`, `stop`, `restart`, and `down` actions across modular service groups (`backend`, `infra`, `all`, or individual services).
- Supports `--no-build` flag to skip builds during service startup or restart.
- Applies `core` and `infra` profiles by default when no specific services are passed.
- Validates service names and provides clear error/help messages.
- Integrates with `build-services.sh` for targeted image building.
- Supports selective service actions: `start user-service infra`, `stop infra gateway`.
- Run `./run-services.sh` or `./run-services.sh -h` for documentation.
- Supports duplicate services: `start infra mailhog user-dev-db` will start `mailhog` and `user-dev-db` instead of throwing errors.

### Related Issue
Closes #185 
<!-- If this PR addresses an issue, please link to it here (e.g., `#123`). -->
<!-- related to #4, closes #9 -->

### Type of Change

- [ ] Bug fix
- [x] New feature
- [ ] Breaking change
- [ ] Documentation update
- [x] Chore (maintenance, refactoring, etc.)
- [ ] Other (please describe):

### Checklist

<!-- Please check the items that apply and make sure to complete them before submitting your PR. -->

- [x] I have tested my changes.
- [ ] I have updated the documentation (if necessary).
- [ ] I have added necessary tests (if applicable).

### Screenshots/videos (if applicable)

<!-- If your changes include visual updates, please include screenshots/gifs/videos here. -->

### Additional Context

<!-- Any other information or context that is helpful to understand your changes (e.g., implementation details, reasoning,
etc.). -->


Linked issue #185: Refactor run-services.sh
### Describe the Feature

Currently run-services.sh gives little flexibility
- It can just start all services(through no parameters) or a single service(e.g. `user-service`, `file-service`, etc) or backend services(through `backend` option)
- It just restarts(kills and remove containers, rebuild) the services not actually starting them. 
- There is no options to skip build stage, because sometimes we might just restart the container without building the image again. 
- There is no options to manage infra services. We might want to just spin up infrastructure containers not core services. 
- There is no way to ignore some services(e.g. client, docs) during building and running.
- There is no `--help` or `-h` option to see the available options or actions.
- There is no `down` action. `down` refers to stopping all running services and removing them along with the network they're running on, volumes they're mounted, images they're using.

### Acceptance Criteria

- [ ] It should differentiate between start and restart process of services(same as docker containers).
- [ ] It should have a option to ignore build image stage.
- [ ] It should start and stop services selectively. We should start `./run-services.sh infra user-service` and it should start only user-service, its dependencies, and the infrastructure containers. 
- [ ] It should have a down action. 

### Attachments

_No response_

### Additional Context

_No response_

Diff:
diff --git a/build-services.sh b/build-services.sh
index d88feb04..9830ffd2 100755
--- a/build-services.sh
+++ b/build-services.sh
@@ -1,9 +1,10 @@
 #!/bin/bash
 
 BACKEND_SERVICES="discovery-server config-server gateway user-service file-service sync-service"
+INFRA_SERVICES="user-dev-db mailhog"
 FRONTEND_SERVICE="client"
 DOCS_SERVICE="docs"
-ALL_SERVICES="$BACKEND_SERVICES $FRONTEND_SERVICE $DOCS_SERVICE"
+ALL_SERVICES="$BACKEND_SERVICES $FRONTEND_SERVICE $DOCS_SERVICE $INFRA_SERVICES"
 
 build_backend_service() {
   local service=$1
@@ -98,13 +99,16 @@ else
       *)
         # Check if it's a specific service
         if contains_service "$arg" "$ALL_SERVICES"; then
-          if contains_service "$arg" "$BACKEND_SERVICES"; then
+          if contains_service "$arg" "$INFRA_SERVICES";then
+            echo "Skipping build for infrastructure service: $arg"
+            continue
+          elif contains_service "$arg" "$BACKEND_SERVICES"; then
             build_backend_service "$arg"
           else
             build_non_maven_service "$arg"
           fi
         else
-          echo "Error: Unknown service or option '$arg'. Valid options: backend, client, docs, or a specific service ($ALL_SERVICES)"
+          echo "Error: Unknown service or option '$arg'. Valid options: ($ALL_SERVICES)"
           exit 1
         fi
         ;;
diff --git a/docker-compose.apps.yml b/docker-compose.apps.yml
index 7cddbc55..970fcc60 100644
--- a/docker-compose.apps.yml
+++ b/docker-compose.apps.yml
@@ -2,6 +2,8 @@ services:
   discovery-server:
     image: oakcan/discovery-server:latest
     container_name: oakcan-discovery-server
+    profiles:
+      - core
     ports:
       - "8761:8761"
     healthcheck:
@@ -14,6 +16,8 @@ services:
     container_name: oakcan-config-server
     environment:
       - EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://discovery-server:8761/eureka/
+    profiles:
+      - core
     ports:
       - "8071:8071"
     healthcheck:
@@ -27,10 +31,16 @@ services:
   gateway:
     image: oakcan/gateway:latest
     container_name: oakcan-gateway
+    profiles:
+      - core
     ports:
       - "8084:8084"
     environment:
       - EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://discovery-server:8761/eureka/
+      - USER_DEV_DB_URL=jdbc:postgresql://user-dev-db:5432/user-dev-db
+      - POSTGRES_USERNAME=postgres
+      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
+      - JWT_SECRET=${JWT_SECRET}
     healthcheck:
       test: [ "CMD", "wget", "-qO-", "http://localhost:8084/actuator/health" ]
       interval: 10s
@@ -41,9 +51,13 @@ services:
         condition: service_healthy
       config-server:
         condition: service_healthy
+      user-dev-db:
+        condition: service_healthy
   file-service:
     image: oakcan/file-service:latest
     container_name: oakcan-file-service
+    profiles:
+      - core
     ports:
       - "8081:8081"
     environment:
@@ -58,6 +72,8 @@ services:
   sync-service:
     image: oakcan/sync-service:latest
     container_name: oakcan-sync-service
+    profiles:
+      - core
     ports:
       - "8082:8082"
     environment:
@@ -72,6 +88,8 @@ services:
   user-service:
     image: oakcan/user-service:latest
     container_name: oakcan-user-service
+    profiles:
+      - core
     ports:
       - "8083:8083"
     environment:
@@ -99,6 +117,8 @@ services:
   user-dev-db:
     image: postgres:17-alpine
     container_name: user-dev-db
+    profiles:
+      - infra
     ports:
       - "15432:5432"
     environment:
@@ -117,6 +137,8 @@ services:
   mailhog:
     image: mailhog/mailhog
     container_name: mailhog
+    profiles:
+      - infra
     ports:
       - "1025:1025"
       - "8025:8025"
@@ -128,15 +150,19 @@ services:
       start_period: 5s
 
   client:
-    image: oakcan/client:0.0.1-SNAPSHOT
+    image: oakcan/client:latest
     container_name: oakcan-client
+    profiles:
+      - core
     build:
       context: ./apps/web
     ports:
       - "3000:3000"
   docs:
-    image: oakcan/docs:0.0.1-SNAPSHOT
+    image: oakcan/docs:latest
     container_name: oakcan-docs
+    profiles:
+      - core
     build:
       context: docs
     ports:
diff --git a/run-services.sh b/run-services.sh
index 10840be0..8520892e 100755
--- a/run-services.sh
+++ b/run-services.sh
@@ -2,57 +2,157 @@
 set -e  # Exit on error
 
 # List of backend services
+COMPOSE_FILE="docker-compose.apps.yml"
+INFRA_SERVICES="user-dev-db mailhog"
 BACKEND_SERVICES="discovery-server config-server gateway user-service file-service sync-service"
 FRONTEND_SERVICE="client"
 DOCS_SERVICE="docs"
-ALL_SERVICES="$BACKEND_SERVICES $FRONTEND_SERVICE $DOCS_SERVICE"
+ALL_SERVICES="$BACKEND_SERVICES $FRONTEND_SERVICE $DOCS_SERVICE $INFRA_SERVICES"
+ACTIVE_PROFILES="--profile infra --profile core"
 
-# Function to rebuild and restart a specific service
-rebuild_service() {
-  local service=$1
-
-   if [[ " ${ALL_SERVICES[*]} " =~ ${service} ]]; then
-      if ! ./build-services.sh "$service"; then  # Build the specified service
-        echo "ERROR: FAILED TO BUILD $service"
-        exit 1
-      fi
-   else
-     echo "Service $service not found!"
-     exit 1
-   fi
+# --- Helper Functions ---
+usage() {
+  echo "Usage: $0 <action> [service...] [options]"
+  echo ""
+  echo "Actions:"
+  echo "  start   Build (if needed) and start specified services (or all core/infra if none specified)."
+  echo "  stop    Stop specified services (or all)."
+  echo "  restart Stop, remove, build (optional), and start specified services."
+  echo "  down    Stop and remove all containers, networks defined in the compose file."
+  echo ""
+  echo "Services:"
+  echo "  <service_name>  Specify one or more service names (e.g., user-service gateway)."
+  echo "  backend         Apply action to all backend services ($BACKEND_SERVICES)."
+  echo "  all             Apply action to all defined services ($ALL_SERVICES)."
+  echo "  (none)          Default depends on action (e.g., 'start' defaults to core+infra, 'ps' shows all)."
+  echo ""
+  echo "Options:"
+  echo "  -n, --no-build   Skip the build step during 'start' or 'restart'."
+  echo "  -h, --help       Show this help message."
+  exit 1
+}
 
-  echo "Stopping $service..."
-  docker-compose -f docker-compose.apps.yml stop "$service" || { echo "ERROR: FAILED TO STOP $service"; exit 1; }
+ACTION=""
+TARGET_SERVICES=()
+NO_BUILD=false
 
-  echo "Removing old container for $service..."
-  docker-compose -f docker-compose.apps.yml rm -f "$service" || { echo "ERROR: FAILED TO REMOVE $service CONTAINER"; exit 1; }
+run_compose() {
+  docker compose -f "$COMPOSE_FILE" $ACTIVE_PROFILES "$@"
+}
 
-  echo "Starting $service..."
-  docker-compose -f docker-compose.apps.yml up -d "$service" || { echo "ERROR: FAILED TO START $service"; exit 1; }
+# Function to check if a service is in a list
+contains_service() {
+  local service=$1
+  local service_list="$2"
+  echo "$service_list" | grep -qw "$service"
 }
 
-# Full rebuild (if no arguments are provided)
-full_rebuild() {
-  for service in $ALL_SERVICES; do
-    rebuild_service "$service"
-  done
 
-  echo "Removing dangling images..."
-  docker image prune -f
+# Parse action first
+if [[ $# -eq 0 ]]; then
+  usage
+fi
+ACTION=$1
+shift
+if [[ "$ACTION" == "-h" || "$ACTION" == "--help" ]]; then
+  usage
+elif [[ "$ACTION" != "start" && "$ACTION" != "stop" && "$ACTION" != "restart" && "$ACTION" != "down" && "$ACTION" != "-h" && "$ACTION" != "--help" ]]; then
+  echo "Error: Invalid action '$ACTION'. Valid actions are: start, stop, restart, down, -h, --help."
+  exit 1
+fi
+
+while [[ $# -gt 0 ]]; do
+  case "$1" in
+    -n|--no-build)
+      NO_BUILD=true
+      shift
+      ;;
+    backend)
+      TARGET_SERVICES+=("$BACKEND_SERVICES")
+      shift
+      ;;
+    infra)
+      NO_BUILD=true # for infra, we don't need to build images
+      TARGET_SERVICES+=("$INFRA_SERVICES")
+      shift
+      ;;
+    all)
+      TARGET_SERVICES+=("$ALL_SERVICES")
+      shift
+      ;;
+    -*)
+      echo "Error: Invalid option '$1'. Use -h or --help for usage."
+      exit 1
+      ;;
+    *) # it's a service name
+      if contains_service "$1" "$ALL_SERVICES"; then
+        TARGET_SERVICES+=("$1")
+      else
+        echo "Error: Unknown service '$1'. Valid options: backend, all, infra, or a specific service ($ALL_SERVICES)"
+        exit 1
+      fi
+      shift
+      ;;
+  esac
+done
+# remove duplicates
+mapfile -t TARGET_SERVICES < <(echo "${TARGET_SERVICES[@]}" | tr ' ' '\n' | sort -u)
 
-  echo "Starting all application services..."
-  docker-compose -f docker-compose.apps.yml up -d --remove-orphans
-}
 
-if [[ -n "$1" ]]; then
-  if [ "$1" = "backend" ]; then
-    echo "Rebuilding all backend services..."
-    for service in $BACKEND_SERVICES; do
-      rebuild_service "$service"  # Rebuild and restart all backend services
-    done
-  else
-  rebuild_service "$1"  # Rebuild and restart only the specified service
-  fi
-else
-  full_rebuild  # Rebuild all services if no argument is provided
-fi
\ No newline at end of file
+echo "Action: $ACTION"
+if [[ ${#TARGET_SERVICES[*]} -gt 0 ]]; then
+    echo "Target(s): ${TARGET_SERVICES[*]}"
+fi
+echo "Options: No-Build=${NO_BUILD}"
+echo "---"
+
+case "$ACTION" in
+  start)
+    if [[ "$NO_BUILD" = false ]]; then
+      echo "Building necessary images..."
+      # Build only targets if specified, otherwise build based on profiles for 'up'
+      if [[ ${#TARGET_SERVICES[@]} -gt 0 ]]; then
+          chmod +x ./build-services.sh
+          ./build-services.sh "${TARGET_SERVICES[@]}"
+      fi
+    else
+      echo "Skipping build step..."
+    fi
+    echo "Starting services..."
+    # Start specific targets, or default to core+infra profiles if no targets given
+    run_compose up -d --remove-orphans "${TARGET_SERVICES[@]}"
+  ;;
+  stop)
+    echo "Stopping services..."
+    run_compose stop "${TARGET_SERVICES[@]}"
+  ;;
+  restart)
+    echo "Restarting services..."
+    # 1. Stop
+    run_compose stop "${TARGET_SERVICES[@]}"
+    # 2. Remove
+    run_compose rm -f "${TARGET_SERVICES[@]}"
+    # 3. Build (if needed)
+    if [[ "$NO_BUILD" = false ]]; then
+      echo "Building necessary images..."
+      # Build only targets if specified, otherwise build based on profiles for 'up'
+      if [[ ${#TARGET_SERVICES[@]} -gt 0 ]]; then
+          chmod +x ./build-services.sh
+          ./build-services.sh "${TARGET_SERVICES[@]}"
+      fi
+    else
+      echo "Skipping build step..."
+    fi
+    # 4. Start
+    echo "Starting services..."
+    run_compose up -d --remove-orphans "${TARGET_SERVICES[@]}"
+  ;;
+  down)
+    echo "Stopping and removing all services..."
+    run_compose down --remove-orphans
+  ;;
+  *)
+    echo "Error: Unknown action '$ACTION'."
+    exit 1
+  ;;
+esac


Reviews:
user: login: coderabbitai[bot]
body: **Actionable comments posted: 1**

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: ASSERTIVE**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 9c631fc7f231c3370705dec679b823a887d4cbd1 and 5427af9472b6cb230535dea1967db1d0892eaeb7.

</details>

<details>
<summary>📒 Files selected for processing (3)</summary>

* `build-services.sh` (2 hunks)
* `docker-compose.apps.yml` (9 hunks)
* `run-services.sh` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (2)</summary>

<details>
<summary>build-services.sh (1)</summary><blockquote>

<details>
<summary>run-services.sh (1)</summary>

* `contains_service` (44-48)

</details>

</blockquote></details>
<details>
<summary>run-services.sh (1)</summary><blockquote>

<details>
<summary>build-services.sh (1)</summary>

* `contains_service` (68-72)

</details>

</blockquote></details>

</details><details>
<summary>🪛 Shellcheck (0.10.0)</summary>

<details>
<summary>run-services.sh</summary>

[info] 40-40: Double quote to prevent globbing and word splitting.

(SC2086)

---

[warning] 99-99: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

(SC2207)

</details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (1)</summary>

* GitHub Check: test-and-coverage

</details>

<details>
<summary>🔇 Additional comments (19)</summary><blockquote>

<details>
<summary>build-services.sh (3)</summary>

`4-7`: **[Geeky Bot] Good addition of infrastructure services.**  
The introduction of the `INFRA_SERVICES` variable and its inclusion in `ALL_SERVICES` enhances modularity, allowing the script to distinguish between backend and infrastructure services when processing build commands.

---

`101-105`: **[Geeky Bot] Solid conditional handling for infra services.**  
The added check to skip builds for infrastructure services is clear and prevents undesired processing.

---

`111-113`: **[Geeky Bot] Clear and concise error messaging.**  
The error now references the entire `ALL_SERVICES` list, which simplifies the guidance when an unknown service is encountered.

</details>
<details>
<summary>run-services.sh (6)</summary>

`5-11`: **[Geeky Bot] Enhanced variable declarations are effective.**  
The new variables (`COMPOSE_FILE`, `INFRA_SERVICES`, and `ACTIVE_PROFILES`) provide improved configuration control and consistency across services.

---

`13-33`: **[Geeky Bot] Comprehensive usage information.**  
The `usage` function now details available actions, options, and services clearly—this will significantly assist users in interacting with the CLI.

---

`64-78`: **[Geeky Bot] Robust argument parsing with clear service categorization.**  
The script distinguishes between `backend`, `infra`, and other service names appropriately and sets the `NO_BUILD` flag for infrastructure services as intended.

---

`108-123`: **[Geeky Bot] Well-structured 'start' action flow.**  
The conditional build step and subsequent Docker Compose up command using `run_compose` provide clear operational flow and robust logging.

---

`128-148`: **[Geeky Bot] Neat and modular handling of the 'restart' action.**  
Breaking the restart process into stopping, removing, conditionally building, and then starting services makes the script both clear and maintainable.

---

`149-157`: **[Geeky Bot] Efficient handling of the 'down' command.**  
The use of `run_compose down --remove-orphans` cleanly stops and removes all containers without any unnecessary complexity.

</details>
<details>
<summary>docker-compose.apps.yml (10)</summary>

`5-6`: **[Geeky Bot] Great inclusion of service profiles for discovery-server.**  
Assigning the `core` profile to the discovery-server service improves grouping and management within Docker Compose.

---

`19-20`: **[Geeky Bot] Consistent profile configuration for config-server.**  
Adding the `profiles` key with the `core` profile ensures that config-server is managed in line with other core services.

---

`34-35`: **[Geeky Bot] Proper profile assignment for gateway.**  
The gateway service now correctly includes the `core` profile, aligning it with the unified orchestration strategy.

---

`59-60`: **[Geeky Bot] Consistent profile application for file-service.**  
Using the `core` profile for file-service reinforces consistency and helps with organized service management.

---

`75-76`: **[Geeky Bot] Correct profile setup for sync-service.**  
Assigning the `core` profile here ensures that sync-service is properly categorized among essential services.

---

`91-92`: **[Geeky Bot] User-service profiles look good.**  
The inclusion of the `core` profile for user-service maintains consistency with your overall service classification.

---

`120-121`: **[Geeky Bot] Distinct handling for infrastructure service: user-dev-db.**  
By assigning the `infra` profile, the configuration clearly differentiates this service from the core business logic.

---

`140-141`: **[Geeky Bot] Mailhog now correctly identified as an infrastructure service.**  
The assignment of the `infra` profile here ensures proper separation from core application services.

---

`153-156`: **[Geeky Bot] Updated client service configuration.**  
Switching the image tag to `latest` and applying the `core` profile simplifies deployments and ensures the most recent image is used.

---

`162-165`: **[Geeky Bot] Aligned documentation service configuration with latest image usage.**  
The docs service now benefits from using the `latest` image tag while retaining the `core` profile for consistent service grouping.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-11T20:19:09Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 1**

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: ASSERTIVE**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 5427af9472b6cb230535dea1967db1d0892eaeb7 and b5f71639b0fd07f37c43569e62de67d16139048c.

</details>

<details>
<summary>📒 Files selected for processing (3)</summary>

* `build-services.sh` (2 hunks)
* `docker-compose.apps.yml` (9 hunks)
* `run-services.sh` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (2)</summary>

<details>
<summary>build-services.sh (1)</summary><blockquote>

<details>
<summary>run-services.sh (1)</summary>

* `contains_service` (44-48)

</details>

</blockquote></details>
<details>
<summary>run-services.sh (1)</summary><blockquote>

<details>
<summary>build-services.sh (1)</summary>

* `contains_service` (68-72)

</details>

</blockquote></details>

</details><details>
<summary>🪛 Shellcheck (0.10.0)</summary>

<details>
<summary>run-services.sh</summary>

[info] 40-40: Double quote to prevent globbing and word splitting.

(SC2086)

</details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (2)</summary>

* GitHub Check: test-and-coverage
* GitHub Check: Analyze (java-kotlin)

</details>

<details>
<summary>🔇 Additional comments (13)</summary><blockquote>

<details>
<summary>build-services.sh (2)</summary>

`3-7`: **[INFO: Updated Service Groupings]**  
Beep boop! The addition of the `INFRA_SERVICES` variable (line 4) and its incorporation into `ALL_SERVICES` (line 7) is clear and consistent with the new service categorization in the Docker Compose file. This enhances modular handling of infrastructure-specific services.

---

`92-107`: **[INFO: Infrastructure Service Skip Logic in Build]**  
Beep boop! The conditional check within the service processing block (lines 92–107) now correctly identifies infrastructure services via `contains_service` and skips their build process. This logic is sound; just ensure that appropriate unit tests cover these conditions.

</details>
<details>
<summary>run-services.sh (4)</summary>

`5-11`: **[INFO: New Variable Declarations for Enhanced Service Management]**  
Beep boop! The new variables—`COMPOSE_FILE`, `INFRA_SERVICES`, the updated `ALL_SERVICES`, and `ACTIVE_PROFILES` (lines 5–11)—are well declared. They align the CLI's configuration with the updated Docker Compose definitions, ensuring consistency across scripts.

---

`64-73`: **[INFO: Command-Line Argument Parsing Improvements]**  
Beep boop! The argument parsing logic—including the handling of options like `-n/--no-build` and service group selections (lines 64–73)—is clearly structured. The use of arrays for `TARGET_SERVICES` helps maintain flexibility. Nice job integrating the new infrastructure options!

---

`98-99`: **[APPROVE: Duplicate Removal Logic]**  
Beep boop! The use of `mapfile -t TARGET_SERVICES` to remove duplicates (line 99) is effective and clear. This approach ensures that each target service is processed only once.

---

`109-159`: **[APPROVE: Comprehensive Action Handling]**  
Beep boop! The refactored case block (lines 109–159) for handling the `start`, `stop`, `restart`, and `down` actions is robust and well-organized. The conditional build step and clear logging substantially improve user interaction.

</details>
<details>
<summary>docker-compose.apps.yml (7)</summary>

`2-7`: **[APPROVE: Service Profiles for discovery-server]**  
Beep boop! The addition of the `profiles` key for the `discovery-server` service (lines 5–7) correctly assigns it to the `core` profile, aligning with the overall grouping strategy.

---

`15-21`: **[APPROVE: Profiles for config-server]**  
Beep boop! The `config-server` now includes a `profiles` key (lines 19–20) set to `core`, which is consistent with the intended service categorization.

---

`32-43`: **[APPROVE: Enhanced Environment Configuration for gateway]**  
Beep boop! The `gateway` service now has an extended environment configuration (lines 40–43), introducing variables like `USER_DEV_DB_URL`, `POSTGRES_USERNAME`, `POSTGRES_PASSWORD`, and `JWT_SECRET`. This enriches its setup and is well aligned with infrastructure needs—just ensure secure management of these variables.

---

`118-121`: **[APPROVE: Infra Service Profile for user-dev-db]**  
Beep boop! The `user-dev-db` service is now assigned the `infra` profile (lines 120–121), effectively distinguishing it from the core services.

---

`138-141`: **[APPROVE: Infra Service Profile for mailhog]**  
Beep boop! The `mailhog` service now correctly uses the `infra` profile (lines 140–141), which is consistent with the overall infrastructure service grouping.

---

`152-157`: **[APPROVE: Updated Image Tag for client Service]**  
Beep boop! The update for the `client` service image tag—from a versioned snapshot to `latest` (lines 152–157)—is properly applied, indicating a shift to always deploy the newest image version. Ensure that your CI/CD workflow is aware of this change.

---

`162-166`: **[APPROVE: Updated Image Tag and Profile for docs Service]**  
Beep boop! The changes made to the `docs` service (lines 162–166) to update its image to `latest` and assign the `core` profile are correctly implemented and consistent with the overall strategy.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-11T20:53:35Z
user: login: tajbirahmed
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-04-12T04:55:40Z

Review comments:
diff_hunk: @@ -2,57 +2,156 @@
 set -e  # Exit on error
 
 # List of backend services
+COMPOSE_FILE="docker-compose.apps.yml"
+INFRA_SERVICES="user-dev-db mailhog"
 BACKEND_SERVICES="discovery-server config-server gateway user-service file-service sync-service"
 FRONTEND_SERVICE="client"
 DOCS_SERVICE="docs"
-ALL_SERVICES="$BACKEND_SERVICES $FRONTEND_SERVICE $DOCS_SERVICE"
+ALL_SERVICES="$BACKEND_SERVICES $FRONTEND_SERVICE $DOCS_SERVICE $INFRA_SERVICES"
+ACTIVE_PROFILES="--profile infra --profile core"
 
-# Function to rebuild and restart a specific service
-rebuild_service() {
-  local service=$1
-
-   if [[ " ${ALL_SERVICES[*]} " =~ ${service} ]]; then
-      if ! ./build-services.sh "$service"; then  # Build the specified service
-        echo "ERROR: FAILED TO BUILD $service"
-        exit 1
-      fi
-   else
-     echo "Service $service not found!"
-     exit 1
-   fi
+# --- Helper Functions ---
+usage() {
+  echo "Usage: $0 <action> [service...] [options]"
+  echo ""
+  echo "Actions:"
+  echo "  start   Build (if needed) and start specified services (or all core/infra if none specified)."
+  echo "  stop    Stop specified services (or all)."
+  echo "  restart Stop, remove, build (optional), and start specified services."
+  echo "  down    Stop and remove all containers, networks defined in the compose file."
+  echo ""
+  echo "Services:"
+  echo "  <service_name>  Specify one or more service names (e.g., user-service gateway)."
+  echo "  backend         Apply action to all backend services ($BACKEND_SERVICES)."
+  echo "  all             Apply action to all defined services ($ALL_SERVICES)."
+  echo "  (none)          Default depends on action (e.g., 'start' defaults to core+infra, 'ps' shows all)."
+  echo ""
+  echo "Options:"
+  echo "  -n, --no-build   Skip the build step during 'start' or 'restart'."
+  echo "  -h, --help       Show this help message."
+  exit 1
+}
 
-  echo "Stopping $service..."
-  docker-compose -f docker-compose.apps.yml stop "$service" || { echo "ERROR: FAILED TO STOP $service"; exit 1; }
+ACTION=""
+TARGET_SERVICES=()
+NO_BUILD=false
 
-  echo "Removing old container for $service..."
-  docker-compose -f docker-compose.apps.yml rm -f "$service" || { echo "ERROR: FAILED TO REMOVE $service CONTAINER"; exit 1; }
+run_compose() {
+  docker compose -f "$COMPOSE_FILE" $ACTIVE_PROFILES "$@"
+}
 
-  echo "Starting $service..."
-  docker-compose -f docker-compose.apps.yml up -d "$service" || { echo "ERROR: FAILED TO START $service"; exit 1; }
+# Function to check if a service is in a list
+contains_service() {
+  local service=$1
+  local service_list="$2"
+  echo "$service_list" | grep -qw "$service"
 }
 
-# Full rebuild (if no arguments are provided)
-full_rebuild() {
-  for service in $ALL_SERVICES; do
-    rebuild_service "$service"
-  done
 
-  echo "Removing dangling images..."
-  docker image prune -f
+# Parse action first
+if [[ $# -eq 0 ]]; then
+  usage
+fi
+ACTION=$1
+shift
+if [[ "$ACTION" == "-h" || "$ACTION" == "--help" ]]; then
+  usage
+elif [[ "$ACTION" != "start" && "$ACTION" != "stop" && "$ACTION" != "restart" && "$ACTION" != "down" && "$ACTION" != "-h" && "$ACTION" != "--help" ]]; then
+  echo "Error: Invalid action '$ACTION'. Valid actions are: start, stop, restart, down, -h, --help."
+  exit 1
+fi
 
-  echo "Starting all application services..."
-  docker-compose -f docker-compose.apps.yml up -d --remove-orphans
-}
+while [[ $# -gt 0 ]]; do
+  case "$1" in
+    -n|--no-build)
+      NO_BUILD=true
+      shift
+      ;;
+    backend)
+      TARGET_SERVICES+=("$BACKEND_SERVICES")
+      shift
+      ;;
+    infra)
+      NO_BUILD=true # for infra, we don't need to build images
+      TARGET_SERVICES+=("$INFRA_SERVICES")
+      shift
+      ;;
+    all)
+      TARGET_SERVICES+=("$ALL_SERVICES")
+      shift
+      ;;
+    -*)
+      echo "Error: Invalid option '$1'. Use -h or --help for usage."
+      exit 1
+      ;;
+    *) # it's a service name
+      if contains_service "$1" "$ALL_SERVICES"; then
+        TARGET_SERVICES+=("$1")
+      else
+        echo "Error: Unknown service '$1'. Valid options: backend, all, infra, or a specific service ($ALL_SERVICES)"
+        exit 1
+      fi
+      shift
+      ;;
+  esac
+done
+# remove duplicates
+TARGET_SERVICES=($(echo "${TARGET_SERVICES[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
path: run-services.sh
user: login: coderabbitai[bot]
body: _💡 Verification agent_

<details>
<summary>❓ Verification inconclusive</summary>

**[Geeky Bot] Consider improving duplicate removal logic.**  
The current splitting of `TARGET_SERVICES` using command substitution may lead to subtle word splitting issues as flagged by Shellcheck (SC2207). Consider using `readarray` to safely split the output. For example:  

```diff
- TARGET_SERVICES=($(echo "${TARGET_SERVICES[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
+ readarray -t TARGET_SERVICES < <(printf "%s\n" "${TARGET_SERVICES[@]}" | sort -u)
```

---



</details>

**Attention: Duplicate-Removal Potential Pitfall**  
Beep boop! The current command substitution used for splitting and deduplicating `TARGET_SERVICES` may trigger subtle word splitting issues (Shellcheck SC2207). For improved safety and readability, please refactor using `readarray` as shown below:

```diff
- TARGET_SERVICES=($(echo "${TARGET_SERVICES[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
+ readarray -t TARGET_SERVICES < <(printf "%s\n" "${TARGET_SERVICES[@]}" | sort -u)
```

Please update accordingly.  


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

`````suggestion
readarray -t TARGET_SERVICES < <(printf "%s\n" "${TARGET_SERVICES[@]}" | sort -u)
`````

</details>

<!-- suggestion_end -->

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 Shellcheck (0.10.0)</summary>

[warning] 99-99: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

(SC2207)

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-04-11T20:19:07Z
author_association: CONTRIBUTOR
diff_hunk: @@ -2,57 +2,157 @@
 set -e  # Exit on error
 
 # List of backend services
+COMPOSE_FILE="docker-compose.apps.yml"
+INFRA_SERVICES="user-dev-db mailhog"
 BACKEND_SERVICES="discovery-server config-server gateway user-service file-service sync-service"
 FRONTEND_SERVICE="client"
 DOCS_SERVICE="docs"
-ALL_SERVICES="$BACKEND_SERVICES $FRONTEND_SERVICE $DOCS_SERVICE"
+ALL_SERVICES="$BACKEND_SERVICES $FRONTEND_SERVICE $DOCS_SERVICE $INFRA_SERVICES"
+ACTIVE_PROFILES="--profile infra --profile core"
 
-# Function to rebuild and restart a specific service
-rebuild_service() {
-  local service=$1
-
-   if [[ " ${ALL_SERVICES[*]} " =~ ${service} ]]; then
-      if ! ./build-services.sh "$service"; then  # Build the specified service
-        echo "ERROR: FAILED TO BUILD $service"
-        exit 1
-      fi
-   else
-     echo "Service $service not found!"
-     exit 1
-   fi
+# --- Helper Functions ---
+usage() {
+  echo "Usage: $0 <action> [service...] [options]"
+  echo ""
+  echo "Actions:"
+  echo "  start   Build (if needed) and start specified services (or all core/infra if none specified)."
+  echo "  stop    Stop specified services (or all)."
+  echo "  restart Stop, remove, build (optional), and start specified services."
+  echo "  down    Stop and remove all containers, networks defined in the compose file."
+  echo ""
+  echo "Services:"
+  echo "  <service_name>  Specify one or more service names (e.g., user-service gateway)."
+  echo "  backend         Apply action to all backend services ($BACKEND_SERVICES)."
+  echo "  all             Apply action to all defined services ($ALL_SERVICES)."
+  echo "  (none)          Default depends on action (e.g., 'start' defaults to core+infra, 'ps' shows all)."
+  echo ""
+  echo "Options:"
+  echo "  -n, --no-build   Skip the build step during 'start' or 'restart'."
+  echo "  -h, --help       Show this help message."
+  exit 1
+}
 
-  echo "Stopping $service..."
-  docker-compose -f docker-compose.apps.yml stop "$service" || { echo "ERROR: FAILED TO STOP $service"; exit 1; }
+ACTION=""
+TARGET_SERVICES=()
+NO_BUILD=false
 
-  echo "Removing old container for $service..."
-  docker-compose -f docker-compose.apps.yml rm -f "$service" || { echo "ERROR: FAILED TO REMOVE $service CONTAINER"; exit 1; }
+run_compose() {
+  docker compose -f "$COMPOSE_FILE" $ACTIVE_PROFILES "$@"
+}
path: run-services.sh
user: login: coderabbitai[bot]
body: _🧹 Nitpick (assertive)_

**[SUGGEST OPTIONAL REFACTOR: Quote Active Profiles]**  
Beep boop! In the `run_compose` function (lines 39–41), the unquoted `$ACTIVE_PROFILES` might lead to subtle word splitting issues. Consider storing the profiles in an array or quoting this variable explicitly to avoid potential glitches during command execution.

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 Shellcheck (0.10.0)</summary>

[info] 40-40: Double quote to prevent globbing and word splitting.

(SC2086)

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-04-11T20:53:34Z
author_association: CONTRIBUTOR

PR comments:
user: login: coderabbitai[bot]
created_at: 2025-04-11T20:15:14Z
body: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- walkthrough_start -->

<details>
<summary>📝 Walkthrough</summary>

## Summary by CodeRabbit

- **New Features**
	- Enhanced service build and run commands that now differentiate core application services from infrastructure components, resulting in streamlined builds.
	- Introduced profile management for organizing services and updated image references to use the latest versions.
	- Improved command-line usability with detailed guidance, flexible options, and comprehensive logging for easier service management.
## Walkthrough
This pull request updates three key scripts: **build-services.sh**, **docker-compose.apps.yml**, and **run-services.sh**. It introduces an `INFRA_SERVICES` variable that groups infrastructure services and updates the handling of these services during build and runtime. The Docker Compose file now assigns service profiles and uses updated image tags, while the run-services script has been refactored to support actions like start, stop, restart, and down, and it includes options to skip the build step with improved argument parsing and user guidance.

## Changes

| File(s)                  | Change Summary                                                                                                                                                                                                                                                                                |
|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| build-services.sh        | Added `INFRA_SERVICES` (with `user-dev-db` and `mailhog`), updated `ALL_SERVICES` to include infra services, adjusted build logic to skip infra service builds, and simplified error messages referencing available services.                                                              |
| docker-compose.apps.yml  | Added `profiles` for services (assigning `core` for most and `infra` for `user-dev-db` and `mailhog`), updated image tags for `client` and `docs` from `0.0.1-SNAPSHOT` to `latest`, and expanded the gateway service’s environment variables.                                      |
| run-services.sh         | Introduced new variables (`COMPOSE_FILE`, `INFRA_SERVICES`, `ACTIVE_PROFILES`), updated `ALL_SERVICES` to include infra services, removed the separate rebuild function in favor of an integrated control flow, added a usage function, and implemented robust CLI parsing (including `-n/--no-build`) with support for actions: start, stop, restart, and down. |

## Sequence Diagram(s)
```mermaid
sequenceDiagram
    participant User
    participant RunSvc["run-services.sh"]
    participant Compose["Docker Compose"]

    User->>RunSvc: Execute command (e.g. start infra user-service -n)
    RunSvc->>RunSvc: Parse and validate command-line arguments
    alt Build required?
      RunSvc->>Compose: Trigger build for selected services
    else
      RunSvc->>RunSvc: Log "skip build" for infra services
    end
    RunSvc->>Compose: Execute action (start/stop/restart/down)
    Compose-->>RunSvc: Return execution status
    RunSvc-->>User: Display log output and service status
```

## Assessment against linked issues

| Objective (from [#185])                                           | Addressed | Explanation            |
|-------------------------------------------------------------------|-----------|------------------------|
| Differentiate between start and restart processes of services     | ✅        |                        |
| Provide an option to ignore the build image stage (`-n/--no-build`) | ✅        |                        |
| Selectively start/stop services including infra service management | ✅        |                        |
| Support a down action to stop and remove containers and networks    | ✅        |                        |

## Poem
> Beep boop, lines of code align,  
> Infra and core in a seamless design.  
> Scripts flow smoothly, actions initiate—  
> Start, stop, restart, down; the control is great.  
> Code rhythms pulse in digital art,  
> A robotic celebration from every part.  
> 🤖✨

</details>

<!-- walkthrough_end -->

<!-- announcements_start -->

> [!TIP]
> <details>
> <summary>⚡💬 Agentic Chat (Pro Plan, General Availability)</summary>
> 
> - We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
> 
> </details>

<!-- announcements_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpADK2VmgqyjcEj2wAbb5AokAI7Y0riQ4rjedJAARAyw+AFcAQBmaGKJ0RTYGGCIlBLwDNIaiLDoGPS0+AwA1pRgTMzc+Pla3NyIGrLM3jGQAO5oyIjYAszqNPRy4bCe2Pl8EvjwtADC+Dk0fJj0qKvs8Cnw0cPWdhhOApSQAIwAHADsG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ikX98D8IiDyDqD+m6DmDtm+gQAA== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details>
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=Learnathon-By-Geeky-Solutions/byte-bandit&utm_content=187):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Generate unit testing code for this file.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai generate unit testing code for this file.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and generate unit testing code.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai plan` to trigger planning for file edits and PR creation.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
author_association: CONTRIBUTOR
user: login: Warhammer4000
created_at: 2025-04-11T20:15:21Z
body: ![](https://res.cloudinary.com/snyk/image/upload/r-d/scm-platform/snyk-pull-requests/pr-banner-default.svg)

### :tada: **Snyk checks have passed. No issues have been found so far.**

:white_check_mark: **security/snyk** check is complete. No issues have been found. [(View Details)](https://app.snyk.io/org/warhammer4000/pr-checks/9ec87ee8-63f0-4ee1-8220-e52976df8a9a?refs=b5f71639b0fd07f37c43569e62de67d16139048c&source=prChecksComment)



author_association: CONTRIBUTOR
user: login: sonarqubecloud[bot]
created_at: 2025-04-11T20:53:36Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=Learnathon-By-Geeky-Solutions_byte-bandit&pullRequest=187) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=Learnathon-By-Geeky-Solutions_byte-bandit&pullRequest=187&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=Learnathon-By-Geeky-Solutions_byte-bandit&pullRequest=187&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=Learnathon-By-Geeky-Solutions_byte-bandit&pullRequest=187&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=Learnathon-By-Geeky-Solutions_byte-bandit&pullRequest=187&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=Learnathon-By-Geeky-Solutions_byte-bandit&pullRequest=187&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=Learnathon-By-Geeky-Solutions_byte-bandit&pullRequest=187)


author_association: NONE