Duplicate build-stage names

Use a unique name for each FROM stage.

Description

Giving different FROM ... AS <name> stages the same name causes an error because the builder cannot uniquely resolve the stage reference.

Potential impact

Conflicting names cause build failures and make the intended COPY --from source unclear.

Remediation

Give each stage a distinct, descriptive name and update any COPY --from or FROM instructions that reference it.

Examples

These excerpts compare stage names only; source-file and dependency preparation is omitted. Set GO_BUILD_IMAGE to a supported Go build image compatible with the project.

Before

dockerfile
ARG GO_BUILD_IMAGE
FROM ${GO_BUILD_IMAGE} AS build
RUN go build -o /out/app .

FROM node:22 AS build
RUN npm ci

After

dockerfile
ARG GO_BUILD_IMAGE
FROM ${GO_BUILD_IMAGE} AS go-builder
RUN go build -o /out/app .

FROM node:22 AS web-builder
RUN npm ci

References