Skip to content

Conversation

@iamsahilchandel
Copy link

@iamsahilchandel iamsahilchandel commented Oct 24, 2025

Feature Issue: #153

Add Dockerfile for multi-stage build and production-ready image
Add .dockerignore to exclude unnecessary files from Docker context
Add docker-compose.yml with environment variable support
Add standalone output setup without disturbing the default app behavior for dev setup
Ensure Prisma client generation during build

Summary by CodeRabbit

  • Chores
    • Added containerization support (Dockerfile) and a .dockerignore to streamline image builds.
    • Updated docker-compose health check to use an HTTP-based Node check.
    • Added/updated environment template with database, auth, and email settings.
    • Adjusted build scripts to produce a standalone output option and separated schema generation into its own script.

@vercel
Copy link

vercel bot commented Oct 24, 2025

@iamsahilchandel is attempting to deploy a commit to the yashdev9274's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Oct 24, 2025

Walkthrough

Adds Docker containerization: a new .dockerignore, a multi-stage Dockerfile (Node 20 Alpine) producing a minimal standalone runtime with Prisma artifacts, docker-compose healthcheck updated to a Node HTTP check, .env.example augmented with DB/auth/email variables, Next.js configured for optional standalone output, and build script adjustments.

Changes

Cohort / File(s) Summary
Dockerfiles & ignore
\.dockerignore, Dockerfile
Adds .dockerignore; introduces a multi-stage Dockerfile (base, deps, builder, runner) using Node 20 Alpine, detects lockfile (yarn/npm/pnpm), installs deps, runs prisma generate, builds the app, and produces a minimal non-root runtime image with standalone Next.js output and Prisma artifacts.
Compose
docker-compose.yml
Updates service healthcheck to use a Node.js HTTP GET against http://localhost:3000 returning success on 200; retains build/context, ports, env_file, restart policy and optional volumes.
Environment example
\.env.example
Normalizes LANGBASE_API_KEY (unquoted) and adds new entries: DATABASE_URL, NEXTAUTH_URL, NEXTAUTH_SECRET, EMAIL_SERVER_HOST, EMAIL_SERVER_PORT, EMAIL_SERVER_USER, EMAIL_SERVER_PASSWORD, EMAIL_FROM; file now ends with newline.
Next config
next.config.js
Adds conditional export output: process.env.BUILD_STANDALONE === "true" ? "standalone" : undefined.
Package scripts
package.json
Changes build script from prisma generate && DISABLE_ESLINT_PLUGIN=true next build to next build; adds prisma:generate script (prisma generate); removes postinstall script.

Sequence Diagram

sequenceDiagram
    participant Dev as Developer / CI
    participant Docker as Docker Build
    participant Deps as Deps Stage
    participant Builder as Builder Stage
    participant Runner as Runner Stage

    Dev->>Docker: docker build context (with .dockerignore)
    Docker->>Deps: copy package files
    note right of Deps: Detect lockfile (yarn/npm/pnpm)
    Deps->>Deps: install dependencies
    Deps->>Builder: copy source & node_modules
    Builder->>Builder: run prisma generate
    Builder->>Builder: build app (next build / standalone if enabled)
    Builder->>Runner: copy .next/standalone, static, public, prisma
    Runner->>Runner: create non-root user, set NODE_ENV=production
    Runner->>Runner: expose 3000 and run server.js
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 In Alpine fields I hop and build,
Stages lined up, each task fulfilled,
Prisma whispers, standalones hum,
Compose checks heartbeat—ready, run!
Docker carrots, neatly tilled 🌱

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Feat: containerization app with docker setup" directly corresponds to the main objective of adding Docker containerization to the application. The changeset clearly reflects this intent through the addition of a Dockerfile with multi-stage build, .dockerignore, docker-compose.yml, and related configuration updates. The title is specific enough to convey the primary change and avoids vague terms, making it clear to developers reviewing the history that this PR introduces Docker containerization infrastructure.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d3b36d1 and 793f08f.

📒 Files selected for processing (6)
  • .dockerignore (1 hunks)
  • .env.example (1 hunks)
  • Dockerfile (1 hunks)
  • docker-compose.yml (1 hunks)
  • next.config.js (1 hunks)
  • package.json (1 hunks)
🧰 Additional context used
🪛 dotenv-linter (4.0.0)
.env.example

[warning] 2-2: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)


[warning] 2-2: [UnorderedKey] The LANGBASE_API_KEY key should go before the POLAR_API_BASE_URL key

(UnorderedKey)


[warning] 4-4: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)


[warning] 6-6: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)


[warning] 6-6: [UnorderedKey] The NEXTAUTH_SECRET key should go before the NEXTAUTH_URL key

(UnorderedKey)


[warning] 8-8: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)


[warning] 10-10: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)


[warning] 11-11: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)


[warning] 11-11: [UnorderedKey] The EMAIL_SERVER_PASSWORD key should go before the EMAIL_SERVER_PORT key

(UnorderedKey)


[warning] 12-12: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)


[warning] 12-12: [UnorderedKey] The EMAIL_FROM key should go before the EMAIL_SERVER_HOST key

(UnorderedKey)

🔇 Additional comments (6)
next.config.js (1)

3-3: LGTM! Standalone output configuration is correct.

The conditional standalone output aligns perfectly with the Docker build workflow. When BUILD_STANDALONE=true is set (as in the Dockerfile line 29), Next.js produces an optimized standalone bundle at .next/standalone, which the Dockerfile copies to the runtime image.

.dockerignore (1)

1-14: LGTM! Comprehensive Docker ignore patterns.

The exclusions are appropriate for a Next.js application:

  • Build artifacts (.next, node_modules) are correctly excluded since they're regenerated during the Docker build
  • Environment files are excluded to prevent secrets from leaking into image layers
  • Development artifacts (.git, .vscode) are excluded to reduce build context size
package.json (1)

7-10: Verify Prisma client generation in development workflow.

The build script no longer includes prisma generate, and the postinstall script has been removed. While the Dockerfile explicitly runs npx prisma generate (line 31), developers working locally will need to manually run npm run prisma:generate after installing dependencies, otherwise they'll encounter "Cannot find module '@prisma/client'" errors.

Consider whether the removal of the postinstall hook was intentional. If not, you may want to restore it for better developer experience:

"postinstall": "prisma generate"

Alternatively, document this requirement clearly in the project README to inform developers they must run npm run prisma:generate after npm install.

Dockerfile (3)

1-16: LGTM! Well-structured dependency installation with multi-package-manager support.

The base image (Node 20 Alpine) is appropriate, and the lockfile detection logic correctly handles yarn, npm, and pnpm with proper flags (--frozen-lockfile, ci, etc.). The libc6-compat installation is a standard requirement for Alpine-based Node images.


19-38: LGTM! Builder stage correctly implements Prisma and Next.js build.

The builder stage correctly:

  • Sets BUILD_STANDALONE=true to enable standalone output (aligns with next.config.js line 3)
  • Runs npx prisma generate before the build to ensure Prisma client is available
  • Detects and uses the appropriate package manager for the build step

40-68: LGTM! Production runtime follows Next.js standalone best practices.

The runner stage implements security and optimization best practices:

  • Runs as non-root user (nextjs:nodejs)
  • Copies only necessary artifacts (standalone output, static files, public, prisma schema)
  • Sets appropriate environment variables for production
  • Uses the standalone server.js entrypoint

Note: There's a related issue with the healthcheck in docker-compose.yml that requires wget to be installed. See the docker-compose.yml review comment for details.

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 (1)
.env.example (1)

1-12: Consider reordering keys alphabetically for consistency with linter preferences.

The dotenv-linter suggests reordering keys alphabetically (e.g., LANGBASE_API_KEY before POLAR_API_BASE_URL, NEXTAUTH_SECRET before NEXTAUTH_URL). While the current logical grouping (APIs, Database/Auth, Email) is arguably more readable, alphabetical ordering would silence the linter warnings and is a common convention for environment variable files.

This is optional and can be deferred if the current grouping is preferred for clarity.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 793f08f and c11bb3d.

📒 Files selected for processing (2)
  • .env.example (1 hunks)
  • docker-compose.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docker-compose.yml
🧰 Additional context used
🪛 dotenv-linter (4.0.0)
.env.example

[warning] 2-2: [UnorderedKey] The LANGBASE_API_KEY key should go before the POLAR_API_BASE_URL key

(UnorderedKey)


[warning] 6-6: [UnorderedKey] The NEXTAUTH_SECRET key should go before the NEXTAUTH_URL key

(UnorderedKey)


[warning] 11-11: [UnorderedKey] The EMAIL_SERVER_PASSWORD key should go before the EMAIL_SERVER_PORT key

(UnorderedKey)


[warning] 12-12: [UnorderedKey] The EMAIL_FROM key should go before the EMAIL_SERVER_HOST key

(UnorderedKey)

🔇 Additional comments (1)
.env.example (1)

2-2: Excellent fix: all quoted values have been removed.

The previous issues flagged in prior reviews regarding quote characters in environment values have been successfully resolved. All variables are now properly unquoted, which ensures they will be parsed correctly at runtime without the quotes becoming part of the actual value.

Also applies to: 4-4, 6-6, 8-12

@yashdev9274
Copy link
Owner

hey @iamsahilchandel sorry been busy alot lately, will review it for sure!
also thank you for contributing.

@iamsahilchandel
Copy link
Author

No Problem @yashdev9274 Let me know if you like to do any tweaks in the PR. Thanks!

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