Optimize docker image for production#965
Conversation
- use cache layers and multiple build stages to reduce image size (~ 4Gib) - replace Dockerfile.dev with Dockerfile in relevant files
|
@ukashazia is attempting to deploy a commit to the Listinai Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes the Docker build process for production by implementing multi-stage builds and build caching to reduce image size from ~8GB to ~4GB and improve build times. The changes replace the previous Dockerfile.dev with an optimized production Dockerfile across all build workflows.
- Implements multi-stage Docker build with separate stages for dependencies, build, production dependencies, and runtime
- Adds build caching layers and optimizes package installation to reduce successive build times
- Updates all CI/CD workflows and build scripts to use the new optimized Dockerfile
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Moves prisma from devDependencies to dependencies for production builds |
| Dockerfile | New multi-stage production-optimized Dockerfile with caching and cleanup |
| Jenkinsfile | Updates Docker build command to use new Dockerfile |
| .github/workflows/pr-docker-build.yml | Updates PR workflow to use optimized Dockerfile |
| .github/workflows/build-containers.yml | Updates container build workflow to use new Dockerfile |
| .dockerignore | Comprehensive ignore rules to reduce build context size |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY . . |
There was a problem hiding this comment.
Copying the entire source code (COPY . .) before installing production dependencies defeats the purpose of layer caching. Consider copying only package files first, then installing dependencies, then copying source code.
| COPY . . | |
| COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ | |
| COPY apps/*/package.json ./apps/ | |
| COPY libraries/*/package.json ./libraries/ |
|
@sentry review |
|
🔒 GenAI Consent Required To enable PR review and test generation via Prevent, an organization admin needs to:
Once enabled, you can re-trigger this review by commenting. |
remove redundant cleanup commands Co-authored-by: Copilot <[email protected]>
|
Please elaborate on the changes, also we can't change Dockerfile.dev to Dockerfile |
i've mentioned the reasons an changes up in the messages. could you please let me know if you want me to elaborate on certain specifics |
What kind of change does this PR introduce?
Why was this change needed?
Checklist:
Put a "X" in the boxes below to indicate you have followed the checklist;