Skip to content

Tweak obs demo docker init image to pull out sbt steps outside docker build #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

piyush-zlai
Copy link
Contributor

@piyush-zlai piyush-zlai commented Dec 2, 2024

Summary

Speed up our local obs iteration flow by pulling all the forced sbt clean + build steps outside the docker compose build flow. We don't need to build the spark assembly, frontend and hub every time - we often just need to build one / two of these. This PR pulls the build piece out of the docker file so that we don't have to do it every time. Instead we wrap the build in a script and invoke the relevant build targets. The docker file copies the relevant artifacts over. This allows us to do things like:

Just build the hub webservice:

 ./docker-init/build.sh --hub 

Just build the spark assemblies:

 ./docker-init/build.sh --spark

Checklist

  • Added Unit Tests
  • Covered by existing CI
  • Integration tested
  • Documentation update

Summary by CodeRabbit

  • New Features
    • Introduced a new build script (build.sh) for easier module building and management.
  • Improvements
    • Simplified Dockerfile structure by removing multi-stage builds for both application and frontend.
    • Updated README to reflect new setup instructions and automated build processes.
    • Removed unnecessary service dependencies in the Docker Compose configuration.
  • Documentation
    • Enhanced clarity and detail in README regarding Docker environment setup and usage.

@piyush-zlai piyush-zlai requested a review from ken-zlai December 2, 2024 19:56
Copy link

coderabbitai bot commented Dec 2, 2024

Walkthrough

The pull request introduces significant changes to the Docker setup for the Chronon Observability project. It simplifies the Dockerfile by removing the initial build stage, allowing for direct copying of application artifacts from local paths. A new build script (build.sh) is added to automate the module building process, enhancing user instructions in the README. The frontend Dockerfile also shifts to a single-stage build using a Node.js base image, streamlining the process for handling frontend assets.

Changes

File Change Summary
docker-init/Dockerfile Removed initial build stage; updated COPY commands to reference local paths directly for application artifacts. Retained environment variable CHRONON_DRIVER_JAR and Spark dependency copying.
docker-init/README.md Updated title and instructions to emphasize using build.sh for building modules. Clarified commands for starting Docker containers and added details for selective module builds.
docker-init/build.sh New script added to facilitate building various project modules with command-line options. It includes options for cleaning and selectively building modules, triggering Docker Compose for the build process.
docker-init/frontend/Dockerfile Changed base image from base_image:latest to node:18-alpine. Removed build stage and commands related to building the frontend with SBT, now directly copying the ./frontend directory into the container.
docker-init/compose.yaml Removed base service definition and its references from app and frontend services, updating dependencies accordingly.

Possibly related PRs

Suggested reviewers

  • nikhil-zlai
  • chewy-zlai

Poem

🐰 In the land of code where rabbits hop,
We build and script, we never stop.
With Docker's charm, our paths align,
A simpler way, oh how divine!
From build stages gone, we cheer and play,
Chronon's bright future starts today! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a864a4a and 3af27f9.

📒 Files selected for processing (1)
  • docker-init/compose.yaml (0 hunks)
💤 Files with no reviewable changes (1)
  • docker-init/compose.yaml

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • 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 resolve resolve all the CodeRabbit review comments.
  • @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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (9)
docker-init/frontend/Dockerfile (2)

3-4: Consider adding validation for frontend build artifacts

The direct copy of the frontend directory might fail silently if the build artifacts aren't present. Consider adding a validation step:

# Copy the built frontend to the new container
+RUN [ -d "/app/frontend/build" ] || (echo "Frontend build artifacts not found. Run ./docker-init/build.sh --frontend first" && exit 1)
COPY ./frontend /app/frontend

4-4: Optimize frontend artifacts copying

Consider being more specific about which files to copy to reduce image size:

-COPY ./frontend /app/frontend
+COPY ./frontend/build /app/frontend/build
+COPY ./frontend/package.json /app/frontend/
docker-init/README.md (3)

17-18: Improve readability with proper punctuation

Add appropriate commas for better readability:

-The build script will build the relevant Chronon modules (Spark, Frontend, Hub) and then trigger the docker container build. While iterating, you can selectively
-build modules you care about to speed your dev loop.
+The build script will build the relevant Chronon modules (Spark, Frontend, Hub) and then trigger the docker container build. While iterating, you can selectively
+build modules you care about to speed up your dev loop.
🧰 Tools
🪛 LanguageTool

[typographical] ~18-~18: Consider inserting a comma for improved readability.
Context: ...ating, you can selectively build modules you care about to speed your dev loop. For ...

(MISSING_COMMAS)


[typographical] ~18-~18: After the expression ‘for example’ a comma is usually used.
Context: ... care about to speed your dev loop. For example to only rebuild Spark modules: ```bash ...

(COMMA_FOR_EXAMPLE)


17-21: Add more examples of selective builds

Consider adding examples for other modules to make it clearer:

 For example to only rebuild Spark modules:
 ```bash
 $ ./docker-init/build.sh --spark

+Other available options:
+bash +$ ./docker-init/build.sh --frontend # Build only frontend +$ ./docker-init/build.sh --hub # Build only hub +


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

<details>
<summary>🪛 LanguageTool</summary>

[typographical] ~18-~18: Consider inserting a comma for improved readability.
Context: ...ating, you can selectively build modules you care about to speed your dev loop. For ...

(MISSING_COMMAS)

---

[typographical] ~18-~18: After the expression ‘for example’ a comma is usually used.
Context: ... care about to speed your dev loop. For example to only rebuild Spark modules: ```bash ...

(COMMA_FOR_EXAMPLE)

</details>

</details>

---

`27-30`: **Add troubleshooting section**

Consider adding a troubleshooting section to help users with common issues:

```markdown
## Troubleshooting

- If you encounter "Module not found" errors, ensure you've run `./docker-init/build.sh` with the appropriate flags
- For permission issues, ensure Docker daemon is running and you have necessary permissions
- To clean all build artifacts: `./docker-init/build.sh --clean`
🧰 Tools
🪛 Markdownlint (0.35.0)

29-29: null
Dollar signs used before commands without showing output

(MD014, commands-show-output)

docker-init/Dockerfile (2)

Line range hint 8-13: Consider using multi-stage build for Python dependencies

To reduce the final image size and potential security vulnerabilities, consider using a multi-stage build for Python dependencies:

-COPY docker-init/requirements.txt .
-# Python3.8 to allow for numpy==1.22.0 due to security concern
-RUN amazon-linux-extras enable python3.8
-RUN yum clean metadata; yum install -y python38 unzip
-RUN  pip3.8 install --upgrade pip; pip3.8 install -r requirements.txt
-ENV PYSPARK_PYTHON=python3.8
+# Use multi-stage build for Python dependencies
+FROM python:3.8-slim as python-deps
+COPY docker-init/requirements.txt .
+RUN pip install --no-cache-dir -r requirements.txt
+
+FROM amazoncorretto:17
+COPY --from=python-deps /usr/local/lib/python3.8 /usr/local/lib/python3.8
+ENV PYSPARK_PYTHON=python3.8

27-29: Consider using environment variables for version numbers

To make version updates easier and consistent:

+ARG SCALA_VERSION=2.12
+ARG PROJECT_VERSION=0.1.0-SNAPSHOT
-COPY ./spark/target/scala-2.12/spark-assembly-0.1.0-SNAPSHOT.jar /app/cli/spark.jar
-COPY ./cloud_aws/target/scala-2.12/cloud_aws-assembly-0.1.0-SNAPSHOT.jar /app/cli/cloud_aws.jar
+COPY ./spark/target/scala-${SCALA_VERSION}/spark-assembly-${PROJECT_VERSION}.jar /app/cli/spark.jar
+COPY ./cloud_aws/target/scala-${SCALA_VERSION}/cloud_aws-assembly-${PROJECT_VERSION}.jar /app/cli/cloud_aws.jar
docker-init/build.sh (2)

1-12: Add shell options and enhance usage documentation

Consider adding shell options for better error handling and including example commands in the usage.

 #!/bin/bash
+set -euo pipefail
 
 function print_usage() {
     echo "Usage: $0 [OPTIONS]"
     echo "Options:"
     echo "  --all       Build all modules (Spark, Frontend, Hub)"
     echo "  --clean     Clean and build all modules"
     echo "  --spark     Build Spark modules only"
     echo "  --frontend  Build frontend modules only"
     echo "  --hub       Build Hub modules only"
     echo "  -h, --help  Show this help message"
+    echo
+    echo "Examples:"
+    echo "  $0 --hub          # Build only the hub web service"
+    echo "  $0 --spark        # Build only the Spark assemblies"
+    echo "  $0 --clean --all  # Clean and rebuild everything"
 }

1-88: Consider build performance optimizations

To improve the build system's efficiency, consider implementing:

  1. Build caching using sbt's built-in caching mechanisms
  2. Parallel execution where possible
  3. Selective rebuilds based on changed files

Example improvements:

  • Add .sbtopts file to configure JVM memory and parallel execution
  • Implement file watching for development mode
  • Consider using sbt-revolver for faster iteration cycles
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6ee5dce and a864a4a.

📒 Files selected for processing (4)
  • docker-init/Dockerfile (3 hunks)
  • docker-init/README.md (1 hunks)
  • docker-init/build.sh (1 hunks)
  • docker-init/frontend/Dockerfile (1 hunks)
🧰 Additional context used
🪛 LanguageTool
docker-init/README.md

[typographical] ~18-~18: Consider inserting a comma for improved readability.
Context: ...ating, you can selectively build modules you care about to speed your dev loop. For ...

(MISSING_COMMAS)


[typographical] ~18-~18: After the expression ‘for example’ a comma is usually used.
Context: ... care about to speed your dev loop. For example to only rebuild Spark modules: ```bash ...

(COMMA_FOR_EXAMPLE)

🪛 Markdownlint (0.35.0)
docker-init/README.md

29-29: null
Dollar signs used before commands without showing output

(MD014, commands-show-output)

# Use the bitnami spark image to pull the relevan Spark jars for the CLI
FROM bitnami/spark:3.5.2 AS spark-source

# Start a new stage for the runtime image
# We expect some build artifacts to be pre-populated by running the docker-init/build.sh (or manually triggered sbt commands)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add validation for required build artifacts

Add checks for required build artifacts to fail fast with clear error messages:

# We expect some build artifacts to be pre-populated by running the docker-init/build.sh (or manually triggered sbt commands)
+ARG REQUIRED_FILES="spark/target/scala-2.12/spark-assembly-0.1.0-SNAPSHOT.jar cloud_aws/target/scala-2.12/cloud_aws-assembly-0.1.0-SNAPSHOT.jar hub/target/universal/hub-0.1.0-SNAPSHOT.zip"
+
+# Add a validation step
+COPY validate_artifacts.sh /
+RUN chmod +x /validate_artifacts.sh
+RUN /validate_artifacts.sh $REQUIRED_FILES

Create a new file validate_artifacts.sh:

#!/bin/bash
for file in "$@"; do
  if [ ! -f "$file" ]; then
    echo "Error: Required build artifact not found: $file"
    echo "Please run './docker-init/build.sh --all' first"
    exit 1
  fi
done

Comment on lines +14 to +18
# No arguments provided
if [ $# -eq 0 ]; then
print_usage
exit 1
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add directory validation

Ensure the script is being run from the correct directory by checking for essential project files.

+# Validate working directory
+if [[ ! -f "build.sbt" ]]; then
+    echo "Error: build.sbt not found. Please run this script from the project root directory."
+    exit 1
+fi
+
 # No arguments provided
 if [ $# -eq 0 ]; then
     print_usage
     exit 1
 fi
📝 Committable suggestion

‼️ 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.

Suggested change
# No arguments provided
if [ $# -eq 0 ]; then
print_usage
exit 1
fi
# Validate working directory
if [[ ! -f "build.sbt" ]]; then
echo "Error: build.sbt not found. Please run this script from the project root directory."
exit 1
fi
# No arguments provided
if [ $# -eq 0 ]; then
print_usage
exit 1
fi

Comment on lines +20 to +54
# Process command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--all)
BUILD_ALL=true
shift
;;
--clean)
CLEAN=true
BUILD_ALL=true
shift
;;
--spark)
BUILD_SPARK=true
shift
;;
--frontend)
BUILD_FRONTEND=true
shift
;;
--hub)
BUILD_HUB=true
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
echo "Unknown option: $1"
print_usage
exit 1
;;
esac
done
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Initialize variables and reconsider --clean behavior

  1. Variables should be initialized before use
  2. The --clean option automatically setting BUILD_ALL might be unexpected
+# Initialize variables
+BUILD_ALL=false
+CLEAN=false
+BUILD_SPARK=false
+BUILD_FRONTEND=false
+BUILD_HUB=false
+
 # Process command line arguments
 while [[ $# -gt 0 ]]; do
     case $1 in
         --all)
             BUILD_ALL=true
             shift
             ;;
         --clean)
             CLEAN=true
-            BUILD_ALL=true
             shift
             ;;
📝 Committable suggestion

‼️ 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.

Suggested change
# Process command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--all)
BUILD_ALL=true
shift
;;
--clean)
CLEAN=true
BUILD_ALL=true
shift
;;
--spark)
BUILD_SPARK=true
shift
;;
--frontend)
BUILD_FRONTEND=true
shift
;;
--hub)
BUILD_HUB=true
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
echo "Unknown option: $1"
print_usage
exit 1
;;
esac
done
# Initialize variables
BUILD_ALL=false
CLEAN=false
BUILD_SPARK=false
BUILD_FRONTEND=false
BUILD_HUB=false
# Process command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--all)
BUILD_ALL=true
shift
;;
--clean)
CLEAN=true
shift
;;
--spark)
BUILD_SPARK=true
shift
;;
--frontend)
BUILD_FRONTEND=true
shift
;;
--hub)
BUILD_HUB=true
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
echo "Unknown option: $1"
print_usage
exit 1
;;
esac
done

Comment on lines +87 to +88
echo "Wrapped up Chronon build. Triggering docker compose..."
docker compose -f docker-init/compose.yaml up --build
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance Docker Compose execution

The Docker Compose execution needs several improvements:

  1. Validate Docker installation
  2. Validate compose file existence
  3. Add option to skip Docker Compose
  4. Add error handling
+# Validate Docker installation
+if ! command -v docker >/dev/null 2>&1; then
+    echo "Error: docker is not installed or not in PATH"
+    exit 1
+fi
+
+# Validate compose file
+COMPOSE_FILE="docker-init/compose.yaml"
+if [ ! -f "$COMPOSE_FILE" ]; then
+    echo "Error: Docker Compose file not found at $COMPOSE_FILE"
+    exit 1
+fi
+
+# Add option to skip docker compose
+if [ "${SKIP_DOCKER:-false}" != "true" ]; then
     echo "Wrapped up Chronon build. Triggering docker compose..."
-    docker compose -f docker-init/compose.yaml up --build
+    if ! docker compose -f "$COMPOSE_FILE" up --build; then
+        echo "Error: Docker Compose failed"
+        exit 1
+    fi
+else
+    echo "Skipping Docker Compose as SKIP_DOCKER=true"
+fi
📝 Committable suggestion

‼️ 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.

Suggested change
echo "Wrapped up Chronon build. Triggering docker compose..."
docker compose -f docker-init/compose.yaml up --build
# Validate Docker installation
if ! command -v docker >/dev/null 2>&1; then
echo "Error: docker is not installed or not in PATH"
exit 1
fi
# Validate compose file
COMPOSE_FILE="docker-init/compose.yaml"
if [ ! -f "$COMPOSE_FILE" ]; then
echo "Error: Docker Compose file not found at $COMPOSE_FILE"
exit 1
fi
# Add option to skip docker compose
if [ "${SKIP_DOCKER:-false}" != "true" ]; then
echo "Wrapped up Chronon build. Triggering docker compose..."
if ! docker compose -f "$COMPOSE_FILE" up --build; then
echo "Error: Docker Compose failed"
exit 1
fi
else
echo "Skipping Docker Compose as SKIP_DOCKER=true"
fi

Comment on lines +56 to +85
# Clean if requested
if [ "$CLEAN" = true ]; then
echo "Cleaning project..."
sbt clean
fi

# Build all modules
if [ "$BUILD_ALL" = true ]; then
echo "Building all modules..."
sbt assembly
sbt dist
fi

# Build Spark modules
if [ "$BUILD_SPARK" = true ]; then
echo "Building Spark modules..."
sbt assembly
fi

# Build Hub modules
if [ "$BUILD_HUB" = true ]; then
echo "Building Hub distribution..."
sbt dist
fi

# Build frontend
if [ "$BUILD_FRONTEND" = true ]; then
echo "Building frontend distribution..."
sbt "project frontend" buildFrontend
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance build execution robustness and user feedback

Several improvements needed for the build execution:

  1. Add error handling for sbt commands
  2. Avoid duplicate sbt commands
  3. Validate sbt installation
  4. Add progress indication
+# Validate sbt installation
+if ! command -v sbt >/dev/null 2>&1; then
+    echo "Error: sbt is not installed or not in PATH"
+    exit 1
+fi
+
+# Helper function for sbt commands with error handling
+run_sbt() {
+    echo "Running: sbt $1"
+    if ! sbt "$1"; then
+        echo "Error: sbt command failed"
+        exit 1
+    fi
+}
+
 # Clean if requested
 if [ "$CLEAN" = true ]; then
     echo "Cleaning project..."
-    sbt clean
+    run_sbt clean
 fi
 
+# Track if any build was performed
+BUILD_PERFORMED=false
+
 # Build all modules
 if [ "$BUILD_ALL" = true ]; then
     echo "Building all modules..."
-    sbt assembly
-    sbt dist
+    run_sbt "assembly; dist"
+    BUILD_PERFORMED=true
 fi
 
 # Build Spark modules
-if [ "$BUILD_SPARK" = true ]; then
+if [ "$BUILD_SPARK" = true ] && [ "$BUILD_ALL" = false ]; then
     echo "Building Spark modules..."
-    sbt assembly
+    run_sbt assembly
+    BUILD_PERFORMED=true
 fi
 
 # Build Hub modules
-if [ "$BUILD_HUB" = true ]; then
+if [ "$BUILD_HUB" = true ] && [ "$BUILD_ALL" = false ]; then
     echo "Building Hub distribution..."
-    sbt dist
+    run_sbt dist
+    BUILD_PERFORMED=true
 fi
 
 # Build frontend
-if [ "$BUILD_FRONTEND" = true ]; then
-  echo "Building frontend distribution..."
-  sbt "project frontend" buildFrontend
+if [ "$BUILD_FRONTEND" = true ] && [ "$BUILD_ALL" = false ]; then
+    echo "Building frontend distribution..."
+    run_sbt "project frontend" buildFrontend
+    BUILD_PERFORMED=true
 fi
+
+if [ "$BUILD_PERFORMED" = false ] && [ "$CLEAN" = false ]; then
+    echo "Warning: No build targets were specified"
+    print_usage
+    exit 1
+fi
📝 Committable suggestion

‼️ 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.

Suggested change
# Clean if requested
if [ "$CLEAN" = true ]; then
echo "Cleaning project..."
sbt clean
fi
# Build all modules
if [ "$BUILD_ALL" = true ]; then
echo "Building all modules..."
sbt assembly
sbt dist
fi
# Build Spark modules
if [ "$BUILD_SPARK" = true ]; then
echo "Building Spark modules..."
sbt assembly
fi
# Build Hub modules
if [ "$BUILD_HUB" = true ]; then
echo "Building Hub distribution..."
sbt dist
fi
# Build frontend
if [ "$BUILD_FRONTEND" = true ]; then
echo "Building frontend distribution..."
sbt "project frontend" buildFrontend
fi
# Validate sbt installation
if ! command -v sbt >/dev/null 2>&1; then
echo "Error: sbt is not installed or not in PATH"
exit 1
fi
# Helper function for sbt commands with error handling
run_sbt() {
echo "Running: sbt $1"
if ! sbt "$1"; then
echo "Error: sbt command failed"
exit 1
fi
}
# Clean if requested
if [ "$CLEAN" = true ]; then
echo "Cleaning project..."
run_sbt clean
fi
# Track if any build was performed
BUILD_PERFORMED=false
# Build all modules
if [ "$BUILD_ALL" = true ]; then
echo "Building all modules..."
run_sbt "assembly; dist"
BUILD_PERFORMED=true
fi
# Build Spark modules
if [ "$BUILD_SPARK" = true ] && [ "$BUILD_ALL" = false ]; then
echo "Building Spark modules..."
run_sbt assembly
BUILD_PERFORMED=true
fi
# Build Hub modules
if [ "$BUILD_HUB" = true ] && [ "$BUILD_ALL" = false ]; then
echo "Building Hub distribution..."
run_sbt dist
BUILD_PERFORMED=true
fi
# Build frontend
if [ "$BUILD_FRONTEND" = true ] && [ "$BUILD_ALL" = false ]; then
echo "Building frontend distribution..."
run_sbt "project frontend" buildFrontend
BUILD_PERFORMED=true
fi
if [ "$BUILD_PERFORMED" = false ] && [ "$CLEAN" = false ]; then
echo "Warning: No build targets were specified"
print_usage
exit 1
fi

Copy link
Collaborator

@tchow-zlai tchow-zlai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but will want a second set of 👁️ 's too

Copy link
Contributor

@nikhil-zlai nikhil-zlai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ship it

@piyush-zlai piyush-zlai merged commit 1cf52fd into main Dec 3, 2024
1 check passed
@piyush-zlai piyush-zlai deleted the piyush/hub_docker branch December 3, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants