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

Running Hive Gateway with Bun (non-programmatic) #158

Closed
klippx opened this issue Nov 21, 2024 · 1 comment
Closed

Running Hive Gateway with Bun (non-programmatic) #158

klippx opened this issue Nov 21, 2024 · 1 comment
Labels
question Further information is requested

Comments

@klippx
Copy link
Contributor

klippx commented Nov 21, 2024

I want to run hive gateway with bun. But according to the docs, I need to use a programmatic approach.

However, for other issues I have been involved in, I have been strongly advised to use the hive cli to start my gateway; i.e. starting with hive-gateway supergraph. When I adopted this approach, abandoning my programmatic one, I start to see this warning in logs:

You use Bun Node compatibility mode, which is not recommended!
It will affect your performance. Please check our Bun integration recipe, and avoid using 'http' for your server implementation.

My dockerfile:

# e.g. docker buildx build -f Dockerfile.hive-gateway -t hive . && docker run --rm -it --name hivey hive sh
FROM oven/bun:1.1.36 AS bun

FROM bun AS base

WORKDIR /app

COPY package.json package.json.tmp
# bun install needs all the files listed in workspaces, remove unwanted workspaces now:
RUN cat package.json.tmp | grep -v "bebb4185" | grep -v 'scripts' | grep -v 'query-registry' | grep -v 'dashboards' | grep -v 'dgs' > package.json && rm package.json.tmp
COPY gateway/package.json ./gateway/package.json
COPY shared/package.json ./shared/package.json.tmp
RUN cat ./shared/package.json.tmp | grep -v "farmhash" > ./shared/package.json && rm ./shared/package.json.tmp

# Install production deps
COPY patches patches/
RUN bun install --production

### Produce the final artefact:
FROM bun AS final
WORKDIR /app

COPY .local-dev-services.json .local-dev-services.json

# Copy prod dependencies from base:
COPY --from=base /app/node_modules /app/node_modules/
RUN rm -rf /app/node_modules/@vcc/gateway

COPY gateway /app/
COPY shared /app/shared

COPY package.json.dgs ./package.json

ENV HOST=0.0.0.0
ENV PORT=3000

CMD [ "bun", "hive-gateway", "supergraph" ]

What is the recommended approach to run Hive Gateway with Bun (and full speed) without seeing this warning?

@klippx klippx changed the title Running with hive-cli with bun Running Hive Gateway with bun (non-programmatic) Nov 21, 2024
@klippx klippx changed the title Running Hive Gateway with bun (non-programmatic) Running Hive Gateway with Bun (non-programmatic) Nov 21, 2024
@klippx
Copy link
Contributor Author

klippx commented Nov 21, 2024

Answer:

Actually you can ignore the warning and keep using it, it is still way faster than Node even if it is compatibility mode. We are going to ship these changes so our CLI will also use Bun's native API so there will no longer be a warning. #98

@klippx klippx closed this as completed Nov 21, 2024
@enisdenjo enisdenjo added the question Further information is requested label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants