-
Notifications
You must be signed in to change notification settings - Fork 5
Description
User Story
As a software developer,
I want to optimize Docker layer caching in the frontend/Dockerfile by separating npm install from source file copying
so that dependency installation is cached independently of source code changes, reducing build times during CI/CD.
Background
The current frontend/Dockerfile copies all source files (including public/ and src/) before running npm install. This invalidates the Docker cache for dependency installation whenever any source file changes, forcing a full reinstall of npm packages even when only application code is modified. This inefficiency increases build times and resource usage in development and deployment workflows. The specific file requiring modification is frontend/Dockerfile.
Acceptance Criteria
- Modify
frontend/Dockerfileto:- Copy only
package.jsonbefore runningnpm install - Copy remaining source files (
public/andsrc/) after dependency installation
- Copy only
- Ensure
npm installexecutes only whenpackage.jsonchanges - Validation steps:
- After implementation, modify a file in
frontend/src/and rebuild the Docker image.npm installshould not rerun ifpackage.jsonremains unchanged. - Confirm via build logs that the "CACHED" marker appears for the
npm installlayer during rebuilds with unchanged dependencies. - Verify build time reduction by comparing timestamps before/after the change when only source files are modified.
- After implementation, modify a file in