-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Optimize docker image for production #965
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?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/ |
Copilot uses AI. Check for mistakes.
@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 |
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;