Closed ladderschool closed 2 months ago
Hi @ladderschool thanks for reporting. Have you been able to reproduce with a minimal docker setup?
Having a repo that I can clone and reproduce this issue would be amazingly helpful.
Btw do you see or have a GraphQL directory? Perhaps the path is failing when generating possible types? https://github.com/redwoodjs/redwood/blob/a3879f37a717105893455028027fe10f2890e853/packages/internal/src/generate/possibleTypes.ts#L54
Btw do you see or have a GraphQL directory? Perhaps the path is failing when generating possible types?
Contents of my deployed web container:
graphql.config.js
web/dist ->
200.html
assets
build-manifest.json
fonts
index.html
I don't see any fragments, you're right there's no graphql folder! There should be a graphql folder since I see it in my local development under /web right? Funnily enough the Dockerfile is missing that copy, but the app works anyway--I haven't removed my fragments in the web side queries and they still resolve.
The graphql.config.js looks like this (I don't need this in production, do I?):
// This file is used by the VSCode GraphQL extension <---- aha!
const { getPaths } = require('@redwoodjs/project-config')
/** @type {import('graphql-config').IGraphQLConfig} */
const config = {
schema: getPaths().generated.schema,
documents: './web/src/fragments/*.ts',
}
module.exports = config
I'll set up a repo tomorrow and link it here but I'll experiment with the Dockerfile tonight 👍
Do I specify the graphql folder here? I thought the first copy copies the whole web folder, which would include graphql, no?
# web build
# ---------
FROM base as web_build
COPY --chown=node:node web web
+COPY --chown=node:node web/graphql web/graphql
RUN yarn rw build web --no-prerender
# web serve
# ---------
FROM node:20-bookworm-slim as web_serve
RUN corepack enable
USER node
WORKDIR /app
COPY --chown=node:node .yarnrc.yml .
COPY --chown=node:node package.json .
COPY --chown=node:node web/package.json web/
COPY --chown=node:node yarn.lock .
RUN mkdir -p /app/.yarn/berry/index
RUN mkdir -p /app/.cache
RUN --mount=type=cache,target=/app/.yarn/berry/cache,uid=1000 \
--mount=type=cache,target=/app/.cache,uid=1000 \
CI=1 yarn workspaces focus web --production
COPY --chown=node:node redwood.toml .
COPY --chown=node:node graphql.config.js .
COPY --chown=node:node --from=web_build /app/web/dist /app/web/dist
ENV NODE_ENV=production \
API_PROXY_TARGET=http://api.app.name:8911
CMD "node_modules/.bin/rw-web-server" "--api-proxy-target" "$API_PROXY_TARGET"
Here's the repo where you can try to deploy it, I just tried it on Coolify and it gave me the same error. Notice when you switch fragments = no in the redwood.toml it works and even the fragments themselves still work!
Here's the repo where you can try to deploy it, I just tried it on Coolify and it gave me the same error. Notice when you switch fragments = no in the redwood.toml it works and even the fragments themselves still work!
Am trying out this repo locally right now.
May I ask why your Docker setup doesn't follow these instructions? https://docs.redwoodjs.com/docs/docker
FYi with the repo and docker compose -f ./docker-compose.yaml up
I do see
=> ERROR [api api_build 3/3] RUN yarn rw build api 6.9s
------
> [api api_build 3/3] RUN yarn rw build api:
2.662 ❯ Generating Prisma Client...
3.440 ✔ Generating Prisma Client...
3.440 ❯ Generating types needed for GraphQL Fragments support...
6.823 ✖ Generating types needed for GraphQL Fragments support... [FAILED: The "path" argument must be of type string or an instance of Buffer or URL. Received null]
So reproduces at moment.
OK, thanks to some help from @Josh-Walker-GM we found the problem and have a fix:
# api build
# ---------
FROM base as api_build
COPY --chown=node:node api api
COPY --chown=node:node web web
COPY --chown=node:node scripts ./scripts/
RUN yarn rw build api
# web prerender build
# -------------------
FROM api_build as web_build_with_prerender
COPY --chown=node:node api api
COPY --chown=node:node web web
RUN yarn rw build web
# web build
# ---------
FROM base as web_build
COPY --chown=node:node api api
COPY --chown=node:node web web
RUN yarn rw build web --no-prerender
In short, for each of the build steps you need to copy over both the api and web in Dockerfile
because in the fragments case the codegen relies on some file paths for both web and api.
We'll think about either documenting this or changing the template, but if you add those copy steps it should succeed:
=> [web web_serve 10/13] RUN --mount=type=cache,target=/app/.yarn/berry/cache,uid=1000 --mount=type=cache,target=/app/.cache,uid=1000 CI=1 yarn workspaces focus web --production 4.9s
=> [web web_build 2/3] COPY --chown=node:node web web 0.0s
=> [web web_build 3/3] RUN yarn rw build web --no-prerender 11.2s
=> [web web_serve 11/13] COPY --chown=node:node redwood.toml . 0.0s
=> [web web_serve 12/13] COPY --chown=node:node graphql.config.js . 0.0s
=> [web web_serve 13/13] COPY --chown=node:node --from=web_build /app/web/dist /app/web/dist 0.0s
=> [web] exporting to image 0.5s
=> => exporting layers 0.5s
=> => writing image sha256:e510e4ece9d3a28dcd4c48f6557bffb13619690763e2289094a7a198e70e1b8b 0.0s
=> => naming to docker.io/library/fragments-deploy-docker-web 0.0s
Error response from daemon: network coolify not found
I don't have the coolify up.
Let us know if this solves the issue and how your cooly experience is!
Btw - thanks so much for taking the time to make the repo that we could use to reproduce. Once we had that and Josh and I could look, it was pretty quick to identify. Without it we would have been scrambling.
Here's the repo where you can try to deploy it, I just tried it on Coolify and it gave me the same error. Notice when you switch fragments = no in the redwood.toml it works and even the fragments themselves still work! https://github.com/ladderschool/fragments-deploy-docker
Am trying out this repo locally right now.
May I ask why your Docker setup doesn't follow these instructions? https://docs.redwoodjs.com/docs/docker
I tried using the original Dockerfile, sadly it did not work on Coolify. Primarily the issue was how paths for the container environment were copied, hence why I had to add /app to most things. If you look at the docker-compose I had to make a few changes there too, but I'm glad it's deploying properly now. The fix to add api and web copies to both builds works for me. I can confirm that seems to have fixed it.
#34 68.84 ✔ Generating types needed for GraphQL Fragments support...
#61 79.37 ✔ Generating types needed for GraphQL Fragments support...
# -> For both api and web build!
Let us know if this solves the issue and how your cooly experience is!
It's pretty nice, honestly. The UI saves me a lot of time tooling on a baremetal myself and it has a lot of goodies; I can just spin up a minIO S3 storage and implement replication/backups easily even with remote servers. Many other services work just out of the box (postgres, redis,..). Having SSL just work out of the box was also a huge boon. If anything I'd say the network configuration is a bit lacking/buggy in the UI and you have to ssh and command line everything when it comes to that (See my problems in the get help thread on the forums). The biggest discovery I've had is that I can run prisma studio and redis over the internet behind a firewall with an ip whitelist to just allow me to access those resources. Build times are as low as 30-50s as well, sometimes 10-20s for smaller commits.
The app works really well though, I've seen a nice jump in responsiveness since I'm not communicating database queries over the internet anymore. Looking forward to testing Trusted Docs. Thank you for being so amazing and for everything the team does. 💪 🚀
The fix to add api and web copies to both builds works for me. I can confirm that seems to have fixed it.
Excellent. And thanks much for the thoughts on Coolify. The team is always looking for more and easier ways to deploy and with upcoming RSC releases, having a several deploy is going to be needed.
The biggest discovery I've had is that I can run prisma studio and redis over the internet behind a firewall with an ip whitelist to just allow me to access those resources.
That is nice. Having Redis available also makes using GraphQL response caching and Realtime much more powerful.
Looking forward to testing Trusted Docs.
Great. Just be sure to update your app when the next release comes as there is a fix for TD with Auth here that's recently been merged: https://github.com/redwoodjs/redwood/pull/10817
Thank you for being so amazing and for everything the team does. 💪 🚀
Welcome! Please do let us know anything we can do to help.
What's not working?
Deployment via docker compose results in the error below when fragmens = true in the redwood.toml file.
Full log:
How do we reproduce the bug?
Follow my guide to set up a Coolify server and deploy Redwood. Make sure fragments are enabled.
https://community.redwoodjs.com/t/self-hosted-with-coolify/7245
What's your environment? (If it applies)
Are you interested in working on this?