Docs: add binaryTargets to docs
In case it helps someone, this is how ended up getting this to build in a container:
FROM golang:1.22-bookworm AS builder
ARG PRISMA_CLIENT_BINARY_TARGETS='["darwin-arm64","linux-static-x64"]'
ARG PRISMA_CLIENT_BINARY_TARGETS
RUN echo -e "Prisma Client Go binary targets: $PRISMA_CLIENT_BINARY_TARGETS"
WORKDIR /workspace
COPY ./ ./
ENV CGO_ENABLED=0
# generate the Prisma Client Go client
ENV PRISMA_CLIENT_BINARY_TARGETS="$PRISMA_CLIENT_BINARY_TARGETS"
RUN go run github.com/steebchen/prisma-client-go generate --generator=db
RUN go build -o runtime ./cmd/my-go-program
...
Thanks for the help on this, @steebchen ! We're absolutely loving this tool.
@alampros Thanks for your kind feedback! you can probably omit the ENV PRISMA_CLIENT_BINARY_TARGETS as it should be already set from the ARG
@steebchen not sure if I've missed part of the docs but I can't seem to generate query engine binaries for x64 using my m1 mac. Is that perhaps expected? I.e. the above docker file only gives me the darwin binary. Same if I use the binaryTargets-field in the schema file.
@SiddyP You can use native to select the correct one locally and then any additional ones for your server: PRISMA_CLIENT_BINARY_TARGETS='["native","linux-static-x64"]'
@steebchen thanks. I realise now that the unexpected behaviour for me is that binaries end up in two places when I build the container. The arm64-one ends up in /tmp/prisma-binaries/ and the full set end up in /root/.cache/prisma/binaries/cli/5.19.1/69d742ee20b815d88e17e54db4a2a7a3b30324e3/.
For some reason I was expecting that they'd all end up in the temp dir of the container.
docker run --platform linux/amd64 -it --entrypoint sh myimg:latest
/ # find / -name prisma-query-*
/tmp/prisma-binaries/prisma-query-engine-linux-static-arm64
/root/.cache/prisma/binaries/cli/5.19.1/69d742ee20b815d88e17e54db4a2a7a3b30324e3/prisma-query-engine-linux-static-arm64
/root/.cache/prisma/binaries/cli/5.19.1/69d742ee20b815d88e17e54db4a2a7a3b30324e3/prisma-query-engine-linux-static-arm64.tmp
/root/.cache/prisma/binaries/cli/5.19.1/69d742ee20b815d88e17e54db4a2a7a3b30324e3/prisma-query-engine-darwin-arm64
/root/.cache/prisma/binaries/cli/5.19.1/69d742ee20b815d88e17e54db4a2a7a3b30324e3/prisma-query-engine-linux-static-x64.tmp
/root/.cache/prisma/binaries/cli/5.19.1/69d742ee20b815d88e17e54db4a2a7a3b30324e3/prisma-query-engine-linux-static-x64
/root/.cache/prisma/binaries/cli/5.19.1/69d742ee20b815d88e17e54db4a2a7a3b30324e3/prisma-query-engine-darwin-arm64.tmp
For now I'll just copy the binaries I find in the builder stage of my image. Good enough workaround for the usecase
RUN mkdir -p prisma-engines && \
find /root/.cache/prisma/binaries/cli/ -name 'prisma-query-engine-*' ! -name '*.tmp' \
-exec cp {} ./prisma-engines/ \;