-
Notifications
You must be signed in to change notification settings - Fork 7
Feat: containerization app with docker setup #181
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
base: main
Are you sure you want to change the base?
Feat: containerization app with docker setup #181
Conversation
|
@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. |
WalkthroughAdds 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
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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.
📒 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=trueis 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 sizepackage.json (1)
7-10: Verify Prisma client generation in development workflow.The build script no longer includes
prisma generate, and thepostinstallscript has been removed. While the Dockerfile explicitly runsnpx prisma generate(line 31), developers working locally will need to manually runnpm run prisma:generateafter installing dependencies, otherwise they'll encounter "Cannot find module '@prisma/client'" errors.Consider whether the removal of the
postinstallhook 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:generateafternpm 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.). Thelibc6-compatinstallation 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=trueto enable standalone output (aligns withnext.config.jsline 3)- Runs
npx prisma generatebefore 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.ymlthat requireswgetto be installed. See the docker-compose.yml review comment for details.
There was a problem hiding this 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.
📒 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
|
hey @iamsahilchandel sorry been busy alot lately, will review it for sure! |
|
No Problem @yashdev9274 Let me know if you like to do any tweaks in the PR. Thanks! |
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