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

[Bug?]: can't prerender using Coherence deploy #8333

Open
1 task done
jtoar opened this issue May 15, 2023 · 1 comment
Open
1 task done

[Bug?]: can't prerender using Coherence deploy #8333

jtoar opened this issue May 15, 2023 · 1 comment
Labels
bug/confirmed We have confirmed this is a bug

Comments

@jtoar
Copy link
Contributor

jtoar commented May 15, 2023

What's not working?

When deploying to Coherence, the web's build string has to be: build: ["yarn", "rw", "build", "web", "--no-prerender"]. We can't prerender because the DATABASE_URL env var isn't supplied to the web's build container. When the web side prerenders, it doesn't actually make a call to the api server over the network. Instead it imports the GraphQL handler directly from the api side and runs it programmatically. This means it needs access to the database for the underlying prisma calls. This also means the build container for the web side can't just contain web-side code—it needs the whole project more or less.

How do we reproduce the bug?

Setup up coherence deploy:

  • yarn rw setup deploy coherence
  • remove the --no-prerender line from the build command in coherence.yml and replace it with this (this handles initial deploy where the database hasn't been provisioned yet):
build: ["/bin/bash", "-c", "\"(curl -o /dev/null -s -w \"%{http_code}\" $COHERENCE_ENVIRONMENT_DOMAIN/api/graphql | grep -q \"200\") && ARG=\"\" || ARG=\"--no-prerender\"; yarn rw build web $ARG\""]
  • run a deploy

What's your environment? (If it applies)

n/a

Are you interested in working on this?

  • I'm interested in working on this
@jtoar jtoar added bug/needs-info More information is needed for reproduction bug/confirmed We have confirmed this is a bug and removed bug/needs-info More information is needed for reproduction labels May 15, 2023
@thedavidprice
Copy link
Contributor

@jtoar I think we can use Docker Multi-stage builds to solve this (for now): https://docs.docker.com/build/building/multi-stage/

With multi-stage builds, you use multiple FROM statements in your Dockerfile. Each FROM instruction can use a different base, and each of them begins a new stage of the build. You can selectively copy artifacts from one stage to another, leaving behind everything you don’t want in the final image.

For the Web Dockerfile, we can start with both API and Web, run through the steps, then remove API.

Note: We need to make API Build, Prisma Migrate, and Data-migrate have completed successfully before Building Web and running prerender.

TBD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/confirmed We have confirmed this is a bug
Projects
None yet
Development

No branches or pull requests

2 participants