Skip to content

Comments

fix: docker files for db and app#1127

Merged
MrgSub merged 2 commits intoMail-0:stagingfrom
krakenftw:fix/docker-file
Jun 10, 2025
Merged

fix: docker files for db and app#1127
MrgSub merged 2 commits intoMail-0:stagingfrom
krakenftw:fix/docker-file

Conversation

@krakenftw
Copy link
Contributor

@krakenftw krakenftw commented May 28, 2025

Description

Migrated from Bun to Node.js with pnpm across Docker configurations. This change replaces Bun with pnpm for dependency management, build processes, and runtime execution in both the application and database Dockerfiles. The migration includes updating base images from oven/bun:alpine to node:22-alpine, modifying installation commands, and adjusting file copying processes to work with the pnpm workspace structure.


Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

Areas Affected

  • Deployment/Infrastructure

Testing Done

  • Manual testing performed

Checklist

  • I have read the CONTRIBUTING document
  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in complex areas
  • My changes generate no new warnings
  • All tests pass locally

By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 28, 2025

Walkthrough

The changes transition the Docker build and runtime environments from Bun to Node.js with pnpm as the package manager. Dockerfiles for application and database services are updated accordingly, and the docker-compose production configuration for migrations now uses pnpm instead of Bun for running database migrations.

Changes

File(s) Change Summary
docker-compose.prod.yaml Updated migrations service to use pnpm run db:migrate instead of bun run db:migrate.
docker/app/Dockerfile Switched base image from Bun to Node.js, replaced Bun with pnpm for dependency management and build steps, updated file copying, and changed user/group setup.
docker/db/Dockerfile Changed base image from Bun to Node.js, replaced Bun with pnpm for dependency installation, expanded copied files, and updated working directory.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Docker as Docker Build
    participant Node as Node.js + pnpm
    participant App as Application
    participant DB as Database

    Dev->>Docker: Build app/db images
    Docker->>Node: Use node:22-alpine base image
    Docker->>Node: Install pnpm globally
    Docker->>Node: Install dependencies with pnpm
    Docker->>App: Build application with pnpm run build
    Docker->>DB: Install and prepare server/db with pnpm

    Dev->>Docker: Run migrations service
    Docker->>Node: Use pnpm run db:migrate
    Node->>DB: Execute database migrations
Loading

Assessment against linked issues

Objective Addressed Explanation
Fix production Docker Compose setup to build and run successfully (#1083)
Correct Dockerfiles to remove references to non-existent bun.lock and fix build failures
Ensure all necessary workspace files are present and referenced correctly in Docker build context
Replace bun install commands with pnpm install to resolve missing workspace dependencies
Enable users to run docker compose -f docker-compose.prod.yaml --env-file .env up -d without errors

Possibly related PRs

Poem

From Bun to Node, the winds have spun,
With pnpm’s hop, new builds begun.
Dockerfiles fresh, commands anew,
Migrations run with pnpm too!
A rabbit’s cheer for changes bright—
Our code now leaps with all its might.
🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ace53e5 and 71f3686.

📒 Files selected for processing (1)
  • docker/app/Dockerfile (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docker/app/Dockerfile

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

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

🧹 Nitpick comments (6)
docker/db/Dockerfile (4)

4-7: Pin pnpm for reproducible builds
Switching to node:22-alpine is correct, but installing the latest pnpm can introduce breaking changes over time. Pin to the version matching your lockfile.

- RUN npm install -g pnpm
+ RUN npm install -g pnpm@<your-locked-version>

16-16: Good use of frozen lockfile
Using pnpm install --frozen-lockfile guarantees deterministic installs. If you later hit peer-dependency conflicts, consider adding --shamefully-hoist.


21-24: Eliminate redundant global install in runner
You install pnpm again in the runner stage, but since you copy the full pnpm binary from deps, this step can be removed to slim down the image:

- FROM node:22-alpine AS runner
- RUN npm install -g pnpm
+ FROM node:22-alpine AS runner

26-30: Maintain cache-friendly layer order
Copying lockfiles, node_modules, and workspace configs before other files is ideal for cache utilization. Consider adding a brief comment to document this pattern so future contributors understand the rationale.

docker/app/Dockerfile (2)

31-40: Optimize dependency install caching
You currently copy source (COPY . .) before RUN pnpm install, invalidating the cache on any code change. To speed rebuilds, invert the steps:

COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./
RUN pnpm install --frozen-lockfile
COPY . .

56-59: Review runtime vs. build-time dependencies
You install wrangler in the final image. If wrangler is only needed for the build, remove it here to reduce image size. If it’s required at runtime, pin its version for consistency.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 91205f3 and ace53e5.

📒 Files selected for processing (3)
  • docker-compose.prod.yaml (1 hunks)
  • docker/app/Dockerfile (3 hunks)
  • docker/db/Dockerfile (1 hunks)
🔇 Additional comments (7)
docker-compose.prod.yaml (1)

47-47: Verify migration script existence in workspace
You’ve updated the migrations service to use ['pnpm', 'run', 'db:migrate']. Ensure that the db:migrate script is defined in the correct package.json (root or apps/server workspace) so the command resolves at /app/apps/server.

docker/db/Dockerfile (3)

10-13: Confirm workspace packages coverage
You now copy all workspace configs and packages (apps/server, packages/, patches/). Double-check that pnpm-workspace.yaml includes these paths and no directories are inadvertently omitted.


32-34: Ensure correct working directory for migrations
You copy both apps/server/ and workspace packages before setting WORKDIR /app/apps/server. Confirm that all migration scripts and config files live under /app/apps/server.


36-36: Working directory correctly set for migration commands
Setting WORKDIR /app/apps/server aligns with your pnpm run db:migrate context. This looks good.

docker/app/Dockerfile (3)

4-4: Migrate base image from Bun to Node.js
Switching from oven/bun:alpine to node:22-alpine is the core change. Verify that no Bun-specific assumptions (e.g., environment variables or runtime flags) remain in your app.


47-48: Verify build script path
The build command cd apps/mail && pnpm run build must match your workspace layout. Confirm apps/mail/package.json defines a build script and that this path is correct.


71-72: Proper ownership of build artifacts
Using --chown=nextjs:pnpm ensures the non-root nextjs user owns the application files—excellent for security.

@krakenftw krakenftw changed the base branch from main to staging May 28, 2025 05:54
@BlankParticle BlankParticle force-pushed the staging branch 6 times, most recently from e47318e to a6ec63a Compare May 30, 2025 07:57
@krakenftw
Copy link
Contributor Author

@MrgSub Any reviews here?

@SerhiiMandrykin
Copy link
Contributor

SerhiiMandrykin commented May 31, 2025

Any updates on this? Your docker files not working on the main branch

Copy link
Collaborator

MrgSub commented May 31, 2025

Merge activity

  • May 31, 4:25 PM UTC: Graphite couldn't merge this PR because it failed for an unknown reason (Stack merges are not currently supported for forked repositories. Please create a branch in the target repository in order to merge).

@SerhiiMandrykin
Copy link
Contributor

@MrgSub, Why do you need AI to merge a PR? Just curious.

@MrgSub MrgSub merged commit a822084 into Mail-0:staging Jun 10, 2025
3 checks passed
@MrgSub
Copy link
Collaborator

MrgSub commented Jun 10, 2025

@MrgSub, Why do you need AI to merge a PR? Just curious.

We use Graphite to auto-rebase and avoid conflicts, and streamline merging

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.

3 participants