Skip to content

Ticket #14: Convert to Multi-Stage Build #54

Description

@PuneethM-06

Description

Optimize the linux-sysmonitor Docker image by implementing a multi-stage build. Separate build-time dependencies from runtime dependencies so the final image contains only what is required to execute the application.


Tasks

  • Review the current Dockerfile and identify build-time dependencies that are not required at runtime (e.g., compilers, package managers, development headers).
  • Split the Dockerfile into two stages:
    • Builder stage – installs required packages and prepares the application.
    • Runtime stage – contains only the minimal files and dependencies needed to run the application.
  • Use COPY --from=builder to copy only the necessary artifacts into the final image.
  • Rebuild the optimized image:
    docker build -t linux-sysmonitor:v2 .
  • Compare image sizes:
    docker images | grep linux-sysmonitor
  • Record the before and after image sizes in NOTES.md or the commit description.
  • Verify the optimized container behaves exactly the same as the original.

Acceptance Criteria

  • Multi-stage Dockerfile is implemented successfully.
  • Final image is measurably smaller than linux-sysmonitor:v1.
  • Container builds without errors.
  • Container executes successfully and produces the same output as the previous version.
  • Image optimization results are documented with before/after size comparison.

Commit Message

feat: convert to multi-stage build to reduce image size (closes #14)

Why This Matters

Multi-stage builds are a Docker best practice for production deployments. They help create smaller, faster, and more secure images by excluding unnecessary build tools from the final runtime image.

This ticket reinforces key Docker concepts, including:

  • Multi-stage builds
  • Builder vs Runtime stages
  • COPY --from
  • Image size optimization
  • Security through minimal images
  • Faster image pulls and deployments

Interview Tip: Be ready to explain why multi-stage builds reduce image size, what stays in the builder stage versus the runtime stage, and quantify your optimization with the actual before/after image sizes.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions