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: docker support #131

Open
wants to merge 10 commits into
base: staging
Choose a base branch
from
Open

feat: docker support #131

wants to merge 10 commits into from

Conversation

txj-xyz
Copy link

@txj-xyz txj-xyz commented Feb 9, 2025

  • This can be updated to run production based instance when ready to ship.

This PR adds in Docker support for running dev mode

If you are not familiar with Docker Compose you can build out the image each time with docker compose up --build -d

Summary by CodeRabbit

  • New Features
    • Added containerized deployment support for the application, enabling smooth, consistent setup and startup.
    • Introduced a configuration for orchestrated services, allowing customizable environment parameters for production and local setups.

Copy link

vercel bot commented Feb 9, 2025

@txj-xyz is attempting to deploy a commit to the Projects Team on Vercel.

A member of the Team first needs to authorize it.

@mezotv
Copy link
Contributor

mezotv commented Feb 9, 2025

Does it make sense to run next dev in the dockerfile instead of next start?

@txj-xyz
Copy link
Author

txj-xyz commented Feb 9, 2025

Updated to run pnpm build and start in prod mode. Can easily swap around if needed or add conditional flags

@mezotv
Copy link
Contributor

mezotv commented Feb 9, 2025

Awesome, thanks!

@txj-xyz txj-xyz changed the title feat: docker support for dev feat: docker support Feb 9, 2025
Copy link

vercel bot commented Feb 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mail ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 9, 2025 8:10pm

@txj-xyz
Copy link
Author

txj-xyz commented Feb 10, 2025

Applied changes to ENV usage, and updated fork

Copy link
Author

@txj-xyz txj-xyz left a comment

Choose a reason for hiding this comment

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

applied fixes

@txj-xyz txj-xyz requested review from Praashh and nizzyabi February 10, 2025 20:04
@MrgSub MrgSub added the Low Priority Low Priority Work label Feb 10, 2025
@MrgSub
Copy link
Collaborator

MrgSub commented Mar 2, 2025

We should update this to support the monorepo

Copy link
Contributor

coderabbitai bot commented Mar 4, 2025

Walkthrough

A new Dockerfile has been added to containerize a Node.js application using the node:22-slim base image. It sets a designated working directory, copies the necessary package files, installs dependencies with PNPM, builds the application, and configures environment variables for runtime. Additionally, the docker-compose.yaml has been updated to introduce a mail0 service that depends on a database service, builds from the current directory, sets a custom container name, and maps port 3000.

Changes

File Change Summary
Dockerfile New file to containerize the Node.js application. Sets /mail0 as the working directory; copies package files; installs corepack and dependencies using PNPM; builds and runs the app on port 3000.
docker-compose.yaml Added a new mail0 service. Specifies a dependency on the db service; builds from the current directory; sets container name as mail0-interface; uses the Node image, restarts always, pulls environment variables from .env, and maps port 3000.

Sequence Diagram(s)

sequenceDiagram
    participant DC as Docker Compose
    participant DB as Database Service
    participant M0 as Mail0 Container

    DC->>DB: Start DB service
    DB-->>DC: DB ready
    DC->>M0: Initialize mail0 container
    M0-->>DC: Run "pnpm start" on port 3000
Loading

Poem

Hoppin' in a Docker dream,
Where Node and PNPM gleam,
Mail0 rises as DB paves the way,
Containers align to brighten the day,
Cheers from this rabbit, coding with gleam! 🐇


🪧 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.
  • @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.

@txj-xyz
Copy link
Author

txj-xyz commented Mar 4, 2025

Hello, I can merge this into origin/staging if you'd like me to re-open or re-base. @nizzyabi Let me know what target branch you want and I'll update this accordingly.

Currently I updated my fork but I'd like to remove all the commits in here and re-base

@ahmetskilinc
Copy link
Collaborator

hey @txj-xyz, this would need to be updated to Mail-0/staging as the base

@txj-xyz txj-xyz changed the base branch from main to staging March 7, 2025 17:49
@txj-xyz
Copy link
Author

txj-xyz commented Mar 7, 2025

Updated base to target staging

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

🧹 Nitpick comments (4)
docker-compose.yaml (1)

26-26: Resolve Trailing Whitespace.
Trailing spaces were detected on line 26. Removing these helps maintain consistency and prevents potential linter warnings.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 26-26: trailing spaces

(trailing-spaces)

Dockerfile (3)

4-8: Include the Lock File for Consistent Dependency Resolution.
The instruction COPY package*.json ./ is effective for caching dependency installation layers. If your project uses a lock file (e.g., pnpm-lock.yaml), consider copying it as well to ensure reproducible builds.


12-13: Optimize the COPY Instruction with a .dockerignore File.
Using COPY . . copies all files from the build context into the image, which might include unnecessary files. Adding a .dockerignore file (if not already present) to exclude temporary files, logs, and other non-essential directories can speed up the build and reduce image size.


29-29: Optional Enhancement: Add a HEALTHCHECK Instruction.
Consider adding a HEALTHCHECK directive (e.g., after the EXPOSE 3000 line) to routinely monitor the container’s health. This can improve operational reliability in production environments.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1965c0c and 8b6bebe.

📒 Files selected for processing (2)
  • Dockerfile (1 hunks)
  • docker-compose.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
docker-compose.yaml

[error] 26-26: trailing spaces

(trailing-spaces)

🔇 Additional comments (4)
docker-compose.yaml (1)

16-25: New 'mail0' Service Configuration: Verify Build and Image Usage.
The new service definition for mail0 properly sets dependencies, build context, container name, and port mapping. However, note that both build: . and an explicit image (node:22-slim) are provided. In Docker Compose, this combination instructs Docker to build the image and then tag it with the given name. Please confirm that this is the intended behavior—especially if future modifications (e.g., for monorepo support) or production optimizations are planned.

Dockerfile (3)

1-4: Base Image and Working Directory Setup: Approved.
The Dockerfile correctly uses node:22-slim as the base image and sets the working directory to /mail0, which aligns with the PR objectives for Docker support.


17-27: Environment Variable Defaults: Verify Security and Override Strategies.
The ENV block defines defaults for various environment variables, including critical ones such as DATABASE_URL. Although these are meant to be overridden via the .env file, please ensure that the default values (especially any sensitive information) are appropriate for development only, and that production deployments enforce secure overrides.


31-31: Startup Command: Approved.
The command CMD ["pnpm", "start"] clearly defines how the container should start and is appropriate given the Dockerfile’s setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Low Priority Low Priority Work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants