fix: use TARGETARCH for multi-platform Docker builds
All checks were successful
ci / build (push) Successful in 3m10s
All checks were successful
ci / build (push) Successful in 3m10s
Use Docker's TARGETARCH variable to download the correct architecture
binaries for Go and Hugo during multi-platform builds. This fixes the
build failure for linux/arm64 where amd64 binaries were being downloaded.
- Add ARG TARGETARCH to capture target architecture
- Replace hardcoded linux-amd64 with linux-${TARGETARCH}
- Applies to both Go and Hugo downloads
- Backwards compatible with local single-platform builds
This commit is contained in:
parent
267b01162f
commit
7e9e427819
1 changed files with 11 additions and 8 deletions
19
Dockerfile
19
Dockerfile
|
|
@ -6,25 +6,28 @@ ARG HUGO_VERSION=0.151.0
|
|||
# Build stage - use same versions as local devbox environment
|
||||
FROM node:${NODE_VERSION}-bookworm AS builder
|
||||
|
||||
# Get target architecture for multi-platform builds
|
||||
ARG TARGETARCH
|
||||
|
||||
# Install Git (needed for Hugo's enableGitInfo)
|
||||
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Go
|
||||
# Install Go (map TARGETARCH: amd64->amd64, arm64->arm64)
|
||||
ARG GO_VERSION
|
||||
RUN wget -q https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz && \
|
||||
tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \
|
||||
rm go${GO_VERSION}.linux-amd64.tar.gz
|
||||
RUN wget -q https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz && \
|
||||
tar -C /usr/local -xzf go${GO_VERSION}.linux-${TARGETARCH}.tar.gz && \
|
||||
rm go${GO_VERSION}.linux-${TARGETARCH}.tar.gz
|
||||
|
||||
ENV PATH="/usr/local/go/bin:${PATH}"
|
||||
ENV GOPATH="/go"
|
||||
ENV PATH="${GOPATH}/bin:${PATH}"
|
||||
|
||||
# Install Hugo extended
|
||||
# Install Hugo extended (map TARGETARCH: amd64->amd64, arm64->arm64)
|
||||
ARG HUGO_VERSION
|
||||
RUN wget -q https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz && \
|
||||
tar -xzf hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz && \
|
||||
RUN wget -q https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz && \
|
||||
tar -xzf hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz && \
|
||||
mv hugo /usr/local/bin/ && \
|
||||
rm hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz && \
|
||||
rm hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz && \
|
||||
hugo version
|
||||
|
||||
WORKDIR /src
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue