Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
ukashazia wants to merge 2 commits into gitroomhq:main
base: main
Choose a base branch
Loading
from ukashazia:feat/optimize-docker-image

Conversation

@ukashazia
Copy link

@ukashazia ukashazia commented Sep 3, 2025

What kind of change does this PR introduce?

  • use cache layers and multiple build stages to reduce image size by half (from ~8Gib to ~4Gib)
  • reduce image build time of successive builds
  • replace Dockerfile.dev with Dockerfile in relevant files

Why was this change needed?

  • building container image takes a while and any change in source code invalidated the node dependency caches
  • image took more than 8 Gib on disk

Checklist:

Put a "X" in the boxes below to indicate you have followed the checklist;

  • [X ] I have read the CONTRIBUTING guide.
  • [ X] I checked that there were not similar issues or PRs already open for this.
  • [X ] This PR fixes just ONE issue (do not include multiple issues or types of change in the same PR) For example, don't try and fix a UI issue and include new dependencies in the same PR.

ericwaetke reacted with heart emoji
- use cache layers and multiple build stages to reduce image size (~ 4Gib)
- replace Dockerfile.dev with Dockerfile in relevant files
Copy link

vercel bot commented Sep 3, 2025

@ukashazia is attempting to deploy a commit to the Listinai Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

Copilot AI left a 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 . .
Copy link

Copilot AI Sep 3, 2025

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.

Suggested change
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.
Copy link
Collaborator

egelhaus commented Sep 3, 2025

@sentry review

seer-by-sentry[bot] reacted with eyes emoji

Copy link

seer-by-sentry bot commented Sep 3, 2025

🔒 GenAI Consent Required

To enable PR review and test generation via Prevent, an organization admin needs to:

  1. Go to your Sentry organization settings
  2. Enable GenAI features for your organization
  3. Enable the PR Review and Test Generation toggle

Once enabled, you can re-trigger this review by commenting.

egelhaus reacted with thumbs down emoji

remove redundant cleanup commands
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Please elaborate on the changes, also we can't change Dockerfile.dev to Dockerfile

Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot Copilot left review comments

@nevo-david nevo-david Awaiting requested review from nevo-david

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /