build: optimize Dockerfile for production deployment#157
Open
suncle1993 wants to merge 1 commit intoEverMind-AI:mainfrom
Open
build: optimize Dockerfile for production deployment#157suncle1993 wants to merge 1 commit intoEverMind-AI:mainfrom
suncle1993 wants to merge 1 commit intoEverMind-AI:mainfrom
Conversation
- Multi-stage build: separate build (g++, build-essential) from runtime, reducing final image size by ~270MB (1.96GB -> 1.69GB) - Layer caching: copy pyproject.toml + uv.lock before source code so dependency layer is cached across source code changes - Remove unnecessary packages: ffmpeg, vim, wget, zip/unzip, libgl1, libglib2.0-0 are not used at runtime - Non-root user: run as appuser instead of root for security compliance - Clean apt cache: rm /var/lib/apt/lists/* in both stages - Exclude tests/, docs/, demo/, examples/ etc. from image via .dockerignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Type of Change
Related Issues
N/A
Changes Made
Dockerfile: Rewritten with multi-stage build (builder + runtime), non-root user, minimal apt packages, dependency-first COPY for layer caching.dockerignore: Added tests/, docs/, demo/, examples/, docker/, .claude/, .github/, *.md, Makefile, LICENSE to reduce build contextTesting
Test Configuration:
Test Results:
The apt layer dropped from 869 MB to 6.5 MB, but the total image only shrunk by 270 MB because the
uv syncvirtualenv (~740 MB) dominates and is incompressible.Build time is similar (both dominated by
uv sync), but the new Dockerfile benefits from layer caching — source code changes no longer invalidate the dependency layer, making rebuilds significantly faster.Checklist
Screenshots (if applicable)
N/A
Additional Notes
curlis kept in the runtime image for debugging purposes (e.g., exec into container to test endpoints)procpsis kept forpscommand availability in production debugginglibgomp1is required at runtime by numpy/scikit-learn (OpenMP)Breaking Changes
None. The application behavior is unchanged; only the build process and image composition are optimized.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.