ARG BASE_IMAGE
FROM $BASE_IMAGE

# Install Go 1.26 — DDEV's base image doesn't ship Go
ENV GO_VERSION=1.26.3
RUN set -eux; \
    arch="$(dpkg --print-architecture)"; \
    case "$arch" in \
      amd64)  GO_ARCH=amd64 ;; \
      arm64)  GO_ARCH=arm64 ;; \
      *)      echo "unsupported arch $arch" >&2; exit 1 ;; \
    esac; \
    curl -fsSL "https://go.dev/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz" -o /tmp/go.tgz; \
    tar -C /usr/local -xzf /tmp/go.tgz; \
    rm /tmp/go.tgz
ENV GOPATH=/var/www/html/.ddev/gocache/path
ENV GOCACHE=/var/www/html/.ddev/gocache/build
ENV PATH="/usr/local/go/bin:${GOPATH}/bin:${PATH}"

# git, build-essential, sqlite, and node 24 are already in the ddev-webserver base
RUN go version

# Pre-warm pnpm cache root for the build step
ENV PNPM_HOME=/var/www/html/.ddev/gocache/pnpm
ENV PATH="${PNPM_HOME}:${PATH}"
