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

feat: add Docker Compose support and update documentation #3554

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Pratikkale26
Copy link

@Pratikkale26 Pratikkale26 commented Jan 7, 2025

Linked Issue: Closes #3542

This PR adds a docker-compose.yml file to simplify the development setup and updates the README with instructions on using Docker Compose.

Summary by CodeRabbit

  • Documentation

    • Updated README with comprehensive Docker Compose setup instructions.
    • Added new section explaining local development environment configuration.
  • Chores

    • Introduced docker-compose.yml to streamline local development process.
    • Configured Docker service for easier application setup and deployment.

Copy link

coderabbitai bot commented Jan 7, 2025

Walkthrough

The pull request introduces Docker Compose support for the project by adding a new docker-compose.yml file and updating the README.md with comprehensive instructions for local development using Docker Compose. The changes provide developers with an alternative method to set up the development environment, enabling easier container management and facilitating hot reloading of code changes.

Changes

File Change Summary
README.md Added new section "Run locally using Docker Compose" with detailed setup instructions
docker-compose.yml New file created with Docker Compose configuration for the application

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Docker as Docker Compose
    participant App as Application Container

    Dev->>Docker: docker-compose up
    Docker->>App: Build and start container
    Docker->>App: Mount local code volumes
    App-->>Dev: Development server running on localhost:3000
Loading

Assessment against linked issues

Objective Addressed Explanation
Simplify Setup [#3542]
Enable Real-time Code Updates [#3542]
Improve Documentation [#3542]

Poem

🐰 Docker's magic, compose with glee,
Volumes dancing, code running free!
Containers spinning, dev's delight,
No more rebuild, everything's right!
Rabbit's Docker dream comes true today! 🚀


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.

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

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

Copy link

netlify bot commented Jan 7, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1c27600
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/677d563dcf6da700086d4ec9
😎 Deploy Preview https://deploy-preview-3554--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Pratikkale26 Pratikkale26 changed the title Add Docker Compose support and update documentation feat: Add Docker Compose support and update documentation Jan 7, 2025
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: 0

🧹 Nitpick comments (2)
docker-compose.yml (1)

3-15: Consider adding container management configurations.

The service configuration looks good with proper build context, port mapping, volume mounts for hot reloading, and environment settings. However, consider adding the following configurations to improve container management:

 services:
   app:
+    container_name: asyncapi-website  # For easier container identification
     build:
       context: .
       dockerfile: Dockerfile # Path to Dockerfile
     ports:
       - "3000:3000"          # Map host port 3000 to container port 3000
     volumes:
       - .:/async             # Mount the current directory to /async in the container - for hot reloading
       - /async/node_modules  # Exclude node_modules from being overridden
     environment:
       NODE_ENV: development  # it Set environment variable
     command: ["npm", "run", "dev"]
+    restart: unless-stopped  # Automatic container recovery
+    healthcheck:            # Container health monitoring
+      test: ["CMD", "wget", "--spider", "-q", "localhost:3000"]
+      interval: 30s
+      timeout: 10s
+      retries: 3
README.md (1)

137-164: Documentation improvements needed.

The Docker Compose documentation is well-structured with clear prerequisites, steps, and features. However, there are a few improvements needed:

  1. Remove duplicate "Install" word in prerequisites:
 #### Prerequisites:
 
-- [Install Docker](https://docs.docker.com/get-docker/)
-- [Install Docker Compose](https://docs.docker.com/compose/install/)
++ [Docker](https://docs.docker.com/get-docker/)
++ [Docker Compose](https://docs.docker.com/compose/install/)
  1. Remove trailing colons from headings to comply with markdown standards:
-### Run locally using Docker Compose:
+### Run locally using Docker Compose

-#### Prerequisites:
+#### Prerequisites

-#### Steps:
+#### Steps

-#### Features:
+#### Features
  1. Add periods at the end of sentences for consistency:
-The `docker-compose.yml` file automatically sets up the container and maps your local code to the container's `/async` directory
+The `docker-compose.yml` file automatically sets up the container and maps your local code to the container's `/async` directory.
🧰 Tools
🪛 LanguageTool

[grammar] ~141-~141: This phrase is duplicated. You should probably use “Install Docker” only once.
Context: ...Docker Compose #### Prerequisites: - Install Docker - [Install Docker Compose](https://docs.docker.com/compos...

(PHRASE_REPETITION)

🪛 Markdownlint (0.37.0)

139-139: Punctuation: ':'
Trailing punctuation in heading

(MD026, no-trailing-punctuation)


146-146: Punctuation: ':'
Trailing punctuation in heading

(MD026, no-trailing-punctuation)


155-155: Punctuation: ':'
Trailing punctuation in heading

(MD026, no-trailing-punctuation)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d002ce and deba37c.

📒 Files selected for processing (2)
  • README.md (1 hunks)
  • docker-compose.yml (1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[grammar] ~141-~141: This phrase is duplicated. You should probably use “Install Docker” only once.
Context: ...Docker Compose #### Prerequisites: - Install Docker - [Install Docker Compose](https://docs.docker.com/compos...

(PHRASE_REPETITION)

🪛 Markdownlint (0.37.0)
README.md

139-139: Punctuation: ':'
Trailing punctuation in heading

(MD026, no-trailing-punctuation)


146-146: Punctuation: ':'
Trailing punctuation in heading

(MD026, no-trailing-punctuation)


155-155: Punctuation: ':'
Trailing punctuation in heading

(MD026, no-trailing-punctuation)

⏰ Context from checks skipped due to timeout of 180000ms (1)
  • GitHub Check: Lighthouse CI
🔇 Additional comments (1)
docker-compose.yml (1)

1-2: LGTM! Version specification is appropriate.

Using version '3.8' of the Docker Compose format is a good choice as it provides modern features while maintaining compatibility.

@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Jan 7, 2025

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 35
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-3554--asyncapi-website.netlify.app/

Copy link

codecov bot commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (4d002ce) to head (1c27600).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3554   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           19        19           
  Lines          668       668           
=========================================
  Hits           668       668           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Pratikkale26 Pratikkale26 changed the title feat: Add Docker Compose support and update documentation feat: add Docker Compose support and update documentation Jan 7, 2025
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: 1

🧹 Nitpick comments (4)
docker-compose.yml (3)

6-8: Remove redundant comment.

The comment # Path to Dockerfile is redundant as the field name dockerfile is self-explanatory.

    build:
      context: .
-      dockerfile: Dockerfile # Path to Dockerfile
+      dockerfile: Dockerfile

9-10: Improve comment formatting.

The comment is redundant and inconsistently aligned with other comments.

    ports:
-      - "3000:3000"          # Map host port 3000 to container port 3000
+      - "3000:3000"

11-13: Consider using a more standard container path.

The path /async is non-standard. Consider using /app or /usr/src/app which are more commonly used in Node.js containers.

    volumes:
-      - .:/async             # Mount the current directory to /async in the container - for hot reloading
-      - /async/node_modules  # Exclude node_modules from being overridden
+      - .:/usr/src/app       # Mount for hot reloading
+      - /usr/src/app/node_modules  # Exclude node_modules from being overridden
README.md (1)

139-142: Remove duplicate Docker prerequisite.

Docker is listed twice in the prerequisites section since it's already included in Docker Compose installation requirements.

#### Prerequisites

- [Docker](https://docs.docker.com/get-docker/)
- [Docker Compose](https://docs.docker.com/compose/install/)
🧰 Tools
🪛 LanguageTool

[duplication] ~141-~141: Possible typo: you repeated a word
Context: ... Docker Compose #### Prerequisites - Docker - [Docker Compose](https://docs.docker.com/compos...

(ENGLISH_WORD_REPEAT_RULE)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between deba37c and 8e88edc.

📒 Files selected for processing (2)
  • README.md (1 hunks)
  • docker-compose.yml (1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[duplication] ~141-~141: Possible typo: you repeated a word
Context: ... Docker Compose #### Prerequisites - Docker - [Docker Compose](https://docs.docker.com/compos...

(ENGLISH_WORD_REPEAT_RULE)

🔇 Additional comments (4)
docker-compose.yml (3)

1-5: LGTM! Version and service naming are appropriate.

The Docker Compose version and service naming follow best practices:

  • Version 3.8 is suitable for modern Docker installations.
  • Container name is descriptive and matches the project.

14-15: LGTM! Environment configuration is appropriate.

The NODE_ENV setting is correctly configured for development.


16-17: LGTM! Command and restart policy are well configured.

The development command and container recovery settings are appropriate:

  • Uses npm run dev for development server
  • Restart policy ensures container stays up during development
README.md (1)

146-163: LGTM! Documentation is clear and informative.

The steps and features sections are well-structured:

  • Clear instructions for starting and stopping the environment
  • Good explanation of Docker Compose benefits
  • Helpful details about volume mounting and isolation

Comment on lines 18 to 22
healthcheck: # Container health monitoring
test: ["CMD", "wget", "--spider", "-q", "localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use curl instead of wget for health check.

The wget command might not be available in the Node.js base image. Consider using curl which is more commonly available.

    healthcheck:
-      test: ["CMD", "wget", "--spider", "-q", "localhost:3000"]
+      test: ["CMD", "curl", "-f", "http://localhost:3000"]
      interval: 30s
      timeout: 10s
      retries: 3
📝 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
healthcheck: # Container health monitoring
test: ["CMD", "wget", "--spider", "-q", "localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
healthcheck: # Container health monitoring
test: ["CMD", "curl", "-f", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3

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: 0

🧹 Nitpick comments (2)
docker-compose.yml (2)

9-10: Consider using environment variables for port configuration.

While the direct port mapping is fine for development, consider making it configurable through environment variables for better flexibility.

     ports:
-      - "3000:3000"
+      - "${PORT:-3000}:3000"

11-13: Consider using a more conventional mount path.

While the volume configuration correctly handles node_modules, the mount path /async is unconventional. Consider using /app or /usr/src/app which are more commonly used in Node.js containers.

     volumes:
-      - .:/async
-      - /async/node_modules
+      - .:/app
+      - /app/node_modules
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e88edc and 1c27600.

📒 Files selected for processing (1)
  • docker-compose.yml (1 hunks)
🔇 Additional comments (4)
docker-compose.yml (4)

1-5: LGTM! Good choice of version and naming.

The Compose file version 3.8 is appropriate, and the container naming is clear and descriptive.


14-16: LGTM! Appropriate development configuration.

The environment variable and startup command are well-configured for development purposes.


17-22: LGTM! Well-configured container management.

The restart policy and healthcheck configuration are appropriate. The use of curl for healthcheck is correct, as previously suggested.


6-8: Verify Dockerfile existence and compatibility.

The configuration references a Dockerfile in the root directory.

Let's verify the Dockerfile exists and check its content:

✅ Verification successful

Dockerfile verification successful

The referenced Dockerfile exists in the root directory and contains valid Node.js development configuration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if Dockerfile exists and examine its content
if [ -f "Dockerfile" ]; then
    echo "Dockerfile exists. Content:"
    cat Dockerfile
else
    echo "Error: Dockerfile not found in root directory"
    exit 1
fi

Length of output: 476

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.

[FEATURE] Add Docker Compose Support and Update Documentation
2 participants