`; resultsHTML += results .map((item) => { return `
${item.meta.title}

…${item.excerpt}…

`; }) .join(""); if (resultsLength > 5) { resultsHTML += ``; } searchBarResults.innerHTML = resultsHTML; } } searchBarInput.addEventListener("input", search); if (window.heap !== undefined) { searchBarResults.addEventListener('click', function (event) { if (event.target.tagName === 'A' && event.target.closest('.link')) { const searchQuery = event.target.getAttribute('data-query'); const resultIndex = event.target.getAttribute('data-index'); const url = new URL(event.target.href); const properties = { docs_search_target_path: url.pathname, docs_search_target_title: event.target.textContent, docs_search_query_text: searchQuery, docs_search_target_index: resultIndex, docs_search_source_path: window.location.pathname, docs_search_source_title: document.title, }; heap.track("Docs - Search - Click - Result Link", properties); } }); } });

FromPlatformFlagConstDisallowed

Table of contents

Output

FROM --platform flag should not use constant value "linux/amd64"

Description

Specifying --platform in the Dockerfile FROM instruction forces the image to build on only one target platform. This prevents building a multi-platform image from this Dockerfile and you must build on the same platform as specified in --platform.

The recommended approach is to:

  • Omit FROM --platform in the Dockerfile and use the --platform argument on the command line.
  • Use $BUILDPLATFORM or some other combination of variables for the --platform argument.
  • Stage name should include the platform, OS, or architecture name to indicate that it only contains platform-specific instructions.

Examples

❌ Bad: using a constant argument for --platform

FROM --platform=linux/amd64 alpine AS base
RUN apk add --no-cache git

✅ Good: using the default platform

FROM alpine AS base
RUN apk add --no-cache git

✅ Good: using a meta variable

FROM --platform=${BUILDPLATFORM} alpine AS base
RUN apk add --no-cache git

✅ Good: used in a multi-stage build with a target architecture

FROM --platform=linux/amd64 alpine AS build_amd64
...

FROM --platform=linux/arm64 alpine AS build_arm64
...

FROM build_${TARGETARCH} AS build
...