# Reorder image layers so dependency installs cache

A Dockerfile that reinstalls everything whenever any file changes, reordered so dependencies cache.

Category: Build, containers, and artifacts
Source: https://letsship.ai/use-cases/reorder-image-layers
Published: 2026-08-25

## Goal

Reorder container image layers so dependency installation caches between builds.

## Acceptance criteria

- Dependency manifests are copied and installed before application source
- Cold and warm build timings are recorded
- The resulting image contents are unchanged
- The build works from a clean cache

## What lands as proof

Cold and warm timings, where the warm build skips the install entirely.

## Prompt

Copy this to an agent to open the ticket:

```text
Create a Linear issue in my team and assign it to the SHIP agent.

Title: Reorder the layers in the container image

Description: Reorder container image layers so dependency installation caches between builds.

Acceptance criteria:
- Dependency manifests are copied and installed before application source
- Cold and warm build timings are recorded
- The resulting image contents are unchanged
- The build works from a clean cache

Before you create the issue, read this repository's Dockerfile and time a rebuild after a one-line source change.
```

## Questions

### What does the agent actually change?

The ticket is scoped to one outcome: reorder container image layers so dependency installation caches between builds. Work that serves that outcome is in scope, and anything outside it is left for a separate ticket, so the pull request stays reviewable.

### How do I know the work is done?

The pull request carries the evidence, not only the diff. Here that means cold and warm build timings attached, so a reviewer can confirm the result without reproducing the work locally.

### How much oversight does this need?

The run stops once the plan is written. Somebody reads the approach and approves it before any code exists, which is the cheapest moment to redirect the work.
