Skip to content

Commit a8982f4

Browse files
authored
fix(docker): detect target architecture for vcpkg triplet (#7601)
1 parent 180d13a commit a8982f4

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

docker/Dockerfile-alpine

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,25 @@ WORKDIR /src
5959
# - /vcpkg/buildtrees : partial builds (helps when a single port fails)
6060
COPY vcpkg.json vcpkg-configuration.json ./
6161
COPY vcpkg-overlay-ports/ ./vcpkg-overlay-ports/
62+
# TARGETARCH is auto-populated by BuildKit (amd64, arm64). Map it to the
63+
# matching vcpkg triplet so native ARM64 builds don't fail with a hardcoded
64+
# x64-linux triplet (see docker/build-push-action platforms: linux/arm64).
65+
ARG TARGETARCH
6266
RUN --mount=type=cache,target=/root/.cache/vcpkg/archives,sharing=locked \
6367
--mount=type=cache,target=/vcpkg/downloads,sharing=locked \
6468
--mount=type=cache,target=/vcpkg/buildtrees,sharing=locked \
6569
export VCPKG_DEFAULT_BINARY_CACHE=/root/.cache/vcpkg/archives && \
6670
mkdir -p build/vcpkg_installed "$VCPKG_DEFAULT_BINARY_CACHE" && \
71+
case "${TARGETARCH}" in \
72+
amd64) VCPKG_TRIPLET=x64-linux ;; \
73+
arm64) VCPKG_TRIPLET=arm64-linux ;; \
74+
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \
75+
esac && \
76+
echo "Using vcpkg triplet: ${VCPKG_TRIPLET}" && \
6777
${VCPKG_ROOT}/vcpkg install \
6878
--x-manifest-root=/src \
6979
--x-install-root=/src/build/vcpkg_installed \
70-
--triplet=x64-linux \
80+
--triplet=${VCPKG_TRIPLET} \
7181
--no-print-usage \
7282
--clean-buildtrees-after-build \
7383
--clean-packages-after-build

0 commit comments

Comments
 (0)