Skip to content
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

chore: self host custom build #5228

Merged
merged 16 commits into from
Jul 25, 2024
Merged

Conversation

mguptahub
Copy link
Collaborator

@mguptahub mguptahub commented Jul 25, 2024

Summary by CodeRabbit

  • New Features

    • Updated setup instructions for deploying a self-hosted application, including clearer resource requirements.
    • Added APP_DOMAIN variable for improved configurability of URLs.
  • Bug Fixes

    • Corrected typographical errors and improved clarity in installation prompts.
  • Chores

    • Simplified Docker Compose configuration by removing the version declaration.
    • Enhanced the installation script for better image management and error handling.

Copy link
Contributor

coderabbitai bot commented Jul 25, 2024

Warning

Rate limit exceeded

@mguptahub has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 38 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 6860c38 and 8565548.

Walkthrough

The recent changes enhance the setup and deployment process of a self-hosted application, improving clarity, automation, and user experience. Key updates include refined environment variable management, adjustments in Docker configuration for efficient image handling, and an improved installation script that simplifies the overall process. These modifications ensure a more robust and user-friendly configuration and deployment experience.

Changes

Files Change Summary
deploy/selfhost/README.md Clarified setup instructions, corrected resource requirements, removed preview release section, and updated user prompt exit option.
deploy/selfhost/build.yml Removed explicit version declaration for Docker Compose, simplifying configuration.
deploy/selfhost/docker-compose.yml Changed pull_policy for multiple services to if_not_present and explicitly set restart policy for plane-proxy to unless-stopped.
deploy/selfhost/install.sh Enhanced functionality with new functions for image management and environment handling, refined build logic, and improved error handling and user prompts.
deploy/selfhost/variables.env Added APP_DOMAIN variable, updated WEB_URL and CORS_ALLOWED_ORIGINS to use APP_DOMAIN, improving configurability.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Script
    participant Docker
    participant Env

    User->>Script: Start installation
    Script->>Env: Check environment variables
    Env-->>Script: Return values
    Script->>Docker: Check for existing images
    Docker-->>Script: Return image status
    alt Image not present
        Script->>Docker: Build new image
    else Image present
        Script->>Docker: Pull existing image
    end
    Script->>User: Installation complete
Loading

🐇 In the garden where I hop and play,
New changes bloom like flowers in May.
With scripts that dance and variables bright,
Deployment's now a joyful delight!
So let us cheer, with a hop and a twirl,
For smoother setups in our coding world! 🌸✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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
Contributor

@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: 8

Outside diff range, codebase verification and nitpick comments (2)
deploy/selfhost/README.md (2)

228-228: Simplify redundant phrase.

The phrase "exit from prompt" is redundant. Consider simplifying it to "exit".

- Once done, choose `8` to exit from prompt.
+ Once done, choose `8` to exit.
Tools
LanguageTool

[style] ~228-~228: This phrase is redundant. Consider writing “exit”.
Context: .../upgrade.png) Once done, choose 8 to exit from prompt. > It is very important for you...

(EXIT_FROM)


230-230: Strengthen weak adjective.

The phrase "very important" uses a weak adjective. Consider removing "very" or using a stronger adjective.

- It is very important for you to validate the `plane.env` for the new changes.
+ It is crucial for you to validate the `plane.env` for the new changes.
Tools
LanguageTool

[style] ~230-~230: As an alternative to the over-used intensifier ‘very’, consider replacing this phrase.
Context: ...hoose 8 to exit from prompt. > It is very important for you to validate the plane.env for...

(EN_WEAK_ADJECTIVE)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1c155f6 and ff62fb7.

Files selected for processing (5)
  • deploy/selfhost/README.md (4 hunks)
  • deploy/selfhost/build.yml (1 hunks)
  • deploy/selfhost/docker-compose.yml (8 hunks)
  • deploy/selfhost/install.sh (9 hunks)
  • deploy/selfhost/variables.env (3 hunks)
Files skipped from review due to trivial changes (1)
  • deploy/selfhost/build.yml
Additional context used
LanguageTool
deploy/selfhost/README.md

[uncategorized] ~100-~100: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...in the options [1-8] will be popped up and this time hit 8 to exit. --- ### Co...

(COMMA_COMPOUND_SENTENCE_2)


[style] ~228-~228: This phrase is redundant. Consider writing “exit”.
Context: .../upgrade.png) Once done, choose 8 to exit from prompt. > It is very important for you...

(EXIT_FROM)


[style] ~230-~230: As an alternative to the over-used intensifier ‘very’, consider replacing this phrase.
Context: ...hoose 8 to exit from prompt. > It is very important for you to validate the plane.env for...

(EN_WEAK_ADJECTIVE)

Shellcheck
deploy/selfhost/install.sh

[warning] 11-11: RED appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 12-12: YELLOW appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 13-13: GREEN appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 14-14: NC appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 99-99: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 180-180: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)


[warning] 197-197: Declare and assign separately to avoid masking return values.

(SC2155)


[error] 503-503: Double quote array expansions to avoid re-splitting elements.

(SC2068)

Additional comments not posted (16)
deploy/selfhost/variables.env (3)

1-1: Good addition for configurability.

Adding APP_DOMAIN enhances the flexibility of the configuration by allowing easy updates to the domain.


10-10: Improved maintainability with dynamic domain.

Updating WEB_URL to use APP_DOMAIN enhances maintainability by ensuring the URL dynamically reflects the configured domain.


14-14: Improved maintainability with dynamic domain.

Updating CORS_ALLOWED_ORIGINS to use APP_DOMAIN enhances maintainability by ensuring the CORS allowed origins dynamically reflect the configured domain.

deploy/selfhost/docker-compose.yml (10)

47-47: Efficient image pulling policy.

Changing pull_policy to if_not_present improves efficiency by ensuring images are only pulled if not already present.


60-60: Efficient image pulling policy.

Changing pull_policy to if_not_present improves efficiency by ensuring images are only pulled if not already present.


74-74: Efficient image pulling policy.

Changing pull_policy to if_not_present improves efficiency by ensuring images are only pulled if not already present.


87-87: Efficient image pulling policy.

Changing pull_policy to if_not_present improves efficiency by ensuring images are only pulled if not already present.


102-102: Efficient image pulling policy.

Changing pull_policy to if_not_present improves efficiency by ensuring images are only pulled if not already present.


116-116: Efficient image pulling policy.

Changing pull_policy to if_not_present improves efficiency by ensuring images are only pulled if not already present.


130-130: Efficient image pulling policy.

Changing pull_policy to if_not_present improves efficiency by ensuring images are only pulled if not already present.


Line range hint 135-135:
Efficient image pulling policy.

Changing pull_policy to if_not_present improves efficiency by ensuring images are only pulled if not already present.


Line range hint 143-143:
Efficient image pulling policy.

Changing pull_policy to if_not_present improves efficiency by ensuring images are only pulled if not already present.


170-171: Efficient image pulling and clear restart policy.

Changing pull_policy to if_not_present improves efficiency by ensuring images are only pulled if not already present. Adding restart: unless-stopped clarifies the intended restart behavior.

deploy/selfhost/README.md (3)

13-13: Clearer resource requirements for EC2 instance.

Updating the description to specify minimum resource requirements (2vCPU and 4GB RAM) provides clearer guidance for users.


100-100: Updated exit option in user prompt.

Changing the exit option from 7 to 8 reflects the updated control flow of the setup process.

Tools
LanguageTool

[uncategorized] ~100-~100: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...in the options [1-8] will be popped up and this time hit 8 to exit. --- ### Co...

(COMMA_COMPOUND_SENTENCE_2)


230-230: Emphasis on validating plane.env file.

Updating the instructions to emphasize validating the plane.env file ensures the integrity of the configuration file used in the deployment.

Tools
LanguageTool

[style] ~230-~230: As an alternative to the over-used intensifier ‘very’, consider replacing this phrase.
Context: ...hoose 8 to exit from prompt. > It is very important for you to validate the plane.env for...

(EN_WEAK_ADJECTIVE)

deploy/selfhost/install.sh Outdated Show resolved Hide resolved
deploy/selfhost/install.sh Outdated Show resolved Hide resolved
deploy/selfhost/install.sh Show resolved Hide resolved
Comment on lines 11 to 14
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unused color variables.

The color variables RED, YELLOW, GREEN, and NC are declared but not used.

- RED='\033[0;31m'
- YELLOW='\033[1;33m'
- GREEN='\033[0;32m'
- NC='\033[0m' # No Color
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
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
Tools
Shellcheck

[warning] 11-11: RED appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 12-12: YELLOW appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 13-13: GREEN appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 14-14: NC appears unused. Verify use (or export if used externally).

(SC2034)

deploy/selfhost/install.sh Outdated Show resolved Hide resolved
deploy/selfhost/install.sh Outdated Show resolved Hide resolved
deploy/selfhost/install.sh Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ff62fb7 and 7bae3b5.

Files selected for processing (1)
  • deploy/selfhost/install.sh (9 hunks)
Additional context used
Shellcheck
deploy/selfhost/install.sh

[warning] 11-11: RED appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 12-12: YELLOW appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 13-13: GREEN appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 14-14: NC appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 99-99: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 180-180: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)


[warning] 197-197: Declare and assign separately to avoid masking return values.

(SC2155)

Additional comments not posted (8)
deploy/selfhost/install.sh (8)

99-99: Declare and assign separately to avoid masking return values.

Separate the declaration and assignment of value.

-            local value=$(grep "^$key=" $file | cut -d'=' -f2)
+            local value
+            value=$(grep "^$key=" $file | cut -d'=' -f2)
Tools
Shellcheck

[warning] 99-99: Declare and assign separately to avoid masking return values.

(SC2155)


106-130: LGTM! Efficient and well-structured updateEnvFile function.

The function handles various scenarios effectively.


132-139: LGTM! Effective use of updateEnvFile in updateCustomVariables function.

The function updates specific environment variables efficiently.


180-180: Handle potential failure of cd command.

Use cd ... || exit to handle potential failure of the cd command.

-    cd $PLANE_TEMP_CODE_DIR
+    cd $PLANE_TEMP_CODE_DIR || exit
Tools
Shellcheck

[warning] 180-180: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)


197-197: Declare and assign separately to avoid masking return values.

Separate the declaration and assignment of build_image.

-    local build_image=$(initialize)
+    local build_image
+    build_image=$(initialize)
Tools
Shellcheck

[warning] 197-197: Declare and assign separately to avoid masking return values.

(SC2155)


Line range hint 215-267:
LGTM! Comprehensive and well-structured download function.

The function handles downloading and updating files effectively.

Tools
Shellcheck

[warning] 273-273: Declare and assign separately to avoid masking return values.

(SC2155)


Line range hint 459-505:
LGTM! Comprehensive and well-structured askForAction function.

The function handles user prompts and actions effectively.


53-86: LGTM! Improved clarity and robustness in initialize function.

The changes enhance error handling and user feedback.

Ensure all calls to initialize are updated if there are any changes in its usage.

Verification successful

LGTM! Improved clarity and robustness in initialize function.

The changes enhance error handling and user feedback.

Ensure all calls to initialize are updated if there are any changes in its usage.


LGTM! Improved clarity and robustness in initialize function.

The changes enhance error handling and user feedback.

The usage of the initialize function is consistent with the new implementation.

  • deploy/selfhost/install.sh: Verified the function call and its handling.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `initialize` match the new implementation.

# Test: Search for the function usage. Expect: Only occurances of the new implementation.
rg --type shell -A 5 $'initialize'

Length of output: 63


Script:

#!/bin/bash
# Description: Verify all function calls to `initialize` match the new implementation.

# Test: Search for the function usage. Expect: Only occurrences of the new implementation.
rg 'initialize' --glob '*.sh' -A 5

Length of output: 881

deploy/selfhost/install.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7bae3b5 and a0edc06.

Files selected for processing (1)
  • deploy/selfhost/install.sh (9 hunks)
Additional context used
Shellcheck
deploy/selfhost/install.sh

[warning] 11-11: RED appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 12-12: YELLOW appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 13-13: GREEN appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 14-14: NC appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 99-99: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 180-180: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)


[warning] 197-197: Declare and assign separately to avoid masking return values.

(SC2155)

Additional comments not posted (7)
deploy/selfhost/install.sh (7)

11-14: Remove unused color variables.

The color variables RED, YELLOW, GREEN, and NC are declared but not used.

Tools
Shellcheck

[warning] 11-11: RED appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 12-12: YELLOW appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 13-13: GREEN appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 14-14: NC appears unused. Verify use (or export if used externally).

(SC2034)


38-51: Ensure process ID is valid before using it in spinner function.

Add a check to ensure the process ID is valid before using it.


53-86: Add error handling for Docker command in initialize function.

Ensure the Docker command's success before proceeding.


99-99: Declare and assign separately to avoid masking return values.

Separate the declaration and assignment of value.

Tools
Shellcheck

[warning] 99-99: Declare and assign separately to avoid masking return values.

(SC2155)


180-180: Handle potential failure of cd command.

Use cd ... || exit to handle potential failure of the cd command.

Tools
Shellcheck

[warning] 180-180: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)


197-197: Declare and assign separately to avoid masking return values.

Separate the declaration and assignment of build_image.

Tools
Shellcheck

[warning] 197-197: Declare and assign separately to avoid masking return values.

(SC2155)


141-160: Enhance error handling in syncEnvFile function.

Add error handling for file operations to ensure robustness.

deploy/selfhost/install.sh Outdated Show resolved Hide resolved
mguptahub and others added 2 commits July 25, 2024 17:39
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@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: 4

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a0edc06 and 6860c38.

Files selected for processing (1)
  • deploy/selfhost/install.sh (9 hunks)
Additional context used
Shellcheck
deploy/selfhost/install.sh

[warning] 11-11: RED appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 12-12: YELLOW appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 13-13: GREEN appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 14-14: NC appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 103-103: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 184-184: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)


[warning] 201-201: Declare and assign separately to avoid masking return values.

(SC2155)

Additional comments not posted (6)
deploy/selfhost/install.sh (6)

38-55: Improved error handling for valid process ID.

The added check ensures the process ID is valid before using it, enhancing robustness.


110-134: LGTM!

The function is well-structured and handles environment variable updates correctly.


136-143: LGTM!

The function correctly updates the specified environment variables.


145-164: LGTM!

The function includes improved error handling and correctly syncs environment variables.


Line range hint 220-271:
LGTM!

The function is well-structured and handles downloading and updating Docker-related files correctly.

Tools
Shellcheck

[warning] 277-277: Declare and assign separately to avoid masking return values.

(SC2155)


Line range hint 462-563:
LGTM!

The function correctly handles user input for selecting actions.

deploy/selfhost/install.sh Show resolved Hide resolved
deploy/selfhost/install.sh Outdated Show resolved Hide resolved
deploy/selfhost/install.sh Show resolved Hide resolved
deploy/selfhost/install.sh Outdated Show resolved Hide resolved
mguptahub and others added 2 commits July 25, 2024 17:43
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@mguptahub
Copy link
Collaborator Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jul 25, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@sriramveeraghanta sriramveeraghanta merged commit d0e68cd into preview Jul 25, 2024
13 of 14 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore/self-host-custom-build branch July 25, 2024 15:05
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.

2 participants