Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: add binaryTargets to docs #1328

Open
steebchen opened this issue Aug 6, 2024 · 6 comments
Open

Docs: add binaryTargets to docs #1328

steebchen opened this issue Aug 6, 2024 · 6 comments
Labels
kind/docs A documentation change is required.

Comments

@steebchen
Copy link
Owner

No description provided.

@steebchen steebchen added the kind/docs A documentation change is required. label Aug 6, 2024
@alampros
Copy link

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.

@steebchen
Copy link
Owner Author

@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

@SiddyP
Copy link

SiddyP commented Sep 21, 2024

@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.

@steebchen
Copy link
Owner Author

@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"]'

@SiddyP
Copy link

SiddyP commented Sep 22, 2024

@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

@SiddyP
Copy link

SiddyP commented Sep 22, 2024

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/ \;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/docs A documentation change is required.
Projects
Development

No branches or pull requests

3 participants