Skip to content

Added support for portal & other apps in containerized Ghost#22121

Merged
cmraible merged 1 commit into
TryGhost:mainfrom
cmraible:run-apps-from-docker-2
Feb 6, 2025
Merged

Added support for portal & other apps in containerized Ghost#22121
cmraible merged 1 commit into
TryGhost:mainfrom
cmraible:run-apps-from-docker-2

Conversation

@cmraible
Copy link
Copy Markdown
Collaborator

@cmraible cmraible commented Feb 6, 2025

no issue

  • The yarn dev command accepts dash-dash-args to conditionally build & run other apps, like portal, comments, etc.
  • Passing these flags to the docker compose setup directly doesn't work, so the only way to run these apps in docker was to either change the command in the Dockerfile or override the command in the compose.yml file
  • This commit extends yarn dev to also check for the GHOST_DEV_APP_FLAGS environment variable for these flags, which can be forwarded into the container and make it easier to run these apps using docker compose.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 6, 2025

Walkthrough

The changes consolidate the handling of command-line flags and environment variables for the Ghost application. In the dev.js script, flags from an environment variable (GHOST_DEV_APP_FLAGS) and from command-line arguments (prefixed with --) are merged into a single array, replacing the previous DASH_DASH_ARGS approach. The compose.yml file now features an expanded set of port mappings and added environment variables (DEBUG, GHOST_DEV_APP_FLAGS, GHOST_DEV_MODE) for the Ghost service. In package.json, Docker-related scripts have been updated to use a default COMPOSE_PROFILES value, and a new Docker script has been introduced.

Changes

File(s) Change Summary
.github/scripts/dev.js Updated flag handling: Combines CLI arguments (prefixed --) and GHOST_DEV_APP_FLAGS into a unified GHOST_APP_FLAGS array. Conditionals for commands (ghost, admin, etc.) now reference the new flag array; error handling for Stripe command is adjusted accordingly.
compose.yml Revised Ghost service configuration: Expanded port mappings (including ports 4173, 41730, 4175, 4176, 4177, 4178, 6174, 7173, 7174) with documented purposes and added environment variables (DEBUG, GHOST_DEV_APP_FLAGS, GHOST_DEV_MODE).
package.json Updated Docker scripts to use COMPOSE_PROFILES=${COMPOSE_PROFILES:-full} for default profile handling; added a new "docker" script for running the Ghost application in a Docker container.

Sequence Diagram(s)

sequenceDiagram
    participant User as Developer
    participant Script as dev.js
    participant Env as Environment
    User ->> Script: Run command with flags (--flag)
    Env -->> Script: Supply GHOST_DEV_APP_FLAGS value
    Script ->> Script: Merge CLI flags and env variable into GHOST_APP_FLAGS array
    Script ->> Script: Evaluate and choose command (ghost, admin, etc.)
    Script -->> User: Execute chosen command, handling errors (e.g., Stripe) accordingly
Loading

Possibly related PRs

Suggested labels

browser-tests

Suggested reviewers

  • aileen

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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>, 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 for this PR. (Beta)
  • @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
Copy Markdown
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: 0

🔭 Outside diff range comments (1)
.github/scripts/dev.js (1)

106-127:

Details

🧩 Analysis chain

Consider adding validation for mutually exclusive flags.

While the portal implementation looks good, there's a potential edge case where both HTTP and HTTPS URLs could be set if the environment has portal__url pre-configured and the HTTPS flag is toggled.


🏁 Script executed:

#!/bin/bash
# Check if there are any existing configurations that might conflict
rg "portal__url.*=.*localhost:(4175|4176)" --type-add 'config:*.json' --type config

Length of output: 85


I'll run another shell script to search for any other occurrences of setting or referencing "portal__url" in the codebase (and to review the surrounding context in .github/scripts/dev.js) to check if there's any evidence of conflicting pre-configurations or additional logic for mutually exclusive flags.


🏁 Script executed:

#!/bin/bash
# 1. Search for assignments of 'portal__url' throughout the repository
rg "COMMAND_GHOST.env\\['portal__url'\\]" -n .

# 2. Show the surrounding context in .github/scripts/dev.js (lines 90 to 140)
sed -n '90,140p' .github/scripts/dev.js

Length of output: 2212


Validation for mutually exclusive flags in portal configuration is missing.
Our inspection of .github/scripts/dev.js shows that COMMAND_GHOST.env['portal__url'] is always overwritten within the portal block based solely on the presence of the https flag without checking whether a value has been pre-configured. This implies a potential edge case where an externally set portal__url might conflict with the in-code assignment, leading to unpredictable behavior.

  • The file directly sets the URL based on the flag without validating against an existing configuration.
  • There’s no condition to handle or warn if both conditions might inadvertently override one another.

Recommendation: Implement a validation check to ensure that if a portal__url is already configured, the code either retains the pre-configured setting or issues an appropriate warning/error when mutually exclusive flags (HTTP versus HTTPS) are activated.

🧹 Nitpick comments (3)
.github/scripts/dev.js (2)

129-138: Consider consolidating the signup form command logic.

The conditional command for signup form could be simplified.

-        command: GHOST_APP_FLAGS.includes('signup') ? 'nx run @tryghost/signup-form:dev' : 'nx run @tryghost/signup-form:preview',
+        command: `nx run @tryghost/signup-form:${GHOST_APP_FLAGS.includes('signup') ? 'dev' : 'preview'}`,

140-149: Consider standardizing flag naming conventions.

The announcement bar flags use multiple variations (announcement-bar, announcementBar, announcementbar). While this provides flexibility, it might be better to standardize on kebab-case for consistency with other flags.

-if (GHOST_APP_FLAGS.includes('announcement-bar') || GHOST_APP_FLAGS.includes('announcementBar') || GHOST_APP_FLAGS.includes('announcementbar') || GHOST_APP_FLAGS.includes('all')) {
+if (GHOST_APP_FLAGS.includes('announcement-bar') || GHOST_APP_FLAGS.includes('all')) {

Also applies to: 178-198

compose.yml (1)

10-21: Consider security implications of exposed ports.

While the port mappings are necessary for development, exposing multiple ports increases the attack surface. Consider:

  1. Using a reverse proxy for HTTPS endpoints
  2. Limiting port exposure in production
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5631e80 and 7ca76e4.

📒 Files selected for processing (3)
  • .github/scripts/dev.js (8 hunks)
  • compose.yml (2 hunks)
  • package.json (1 hunks)
🔇 Additional comments (3)
.github/scripts/dev.js (1)

37-40: LGTM! Improved flag handling mechanism.

The new implementation elegantly consolidates flags from both environment variables and command-line arguments, making it more flexible for containerized environments.

compose.yml (1)

31-34: LGTM! Well-structured environment variables.

The environment variables are properly configured with default empty values, making them optional but available when needed.

package.json (1)

37-43: LGTM! Well-structured Docker scripts.

The Docker scripts are properly updated to:

  1. Use consistent environment variable handling with defaults
  2. Maintain consistent formatting across all commands
  3. Provide flexibility in profile selection

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.

1 participant