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
feat: Make database optional when building #8561
Conversation
Solves calcom#3026 and calcom#6780 We have a few app-store related pages that require a database connection at build time. This change adds try-catch blocks in getStaticPaths or getStaticProps for those pages, and when no database is available we either: - getStaticPaths: Respond with no paths, but fall back to rendering the pages on-demand - getStaticProps: Respond with no data, but enable revalidation until a future request does respond with data This makes Cal.com more compatible with typical Docker-based workflows, that do not expect external services to be available at build time. This includes Docker-based hosting providers, such as Cloudron (calcom#3026).
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
@rjackson is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
📦 Next.js Bundle Analysis for @calcom/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖 Ten Pages Changed SizeThe following pages changed size from the code in this PR compared to its base branch:
DetailsOnly the gzipped size is provided here based on an expert tip. First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If Any third party scripts you have added directly to your app using the The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored. |
Thank you for your contribution. Will review ASAP! |
excited for this! |
Assigned you @zomars, as you have it in your list already, to avoid having the PR in other people's list too, hope that's OK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this PR do?
We have a few app-store related pages that require a database connection at build time.
This change adds try-catch blocks in getStaticPaths for those pages; when no database is available we respond with no paths, but fall back to rendering the pages on-demand.
(Update: 2023-04-30)
I'd previously also added a try...catch block to the
getStaticProps
function used bypages/apps/categories/index.tsx
and set it up to revalidate until a request which loaded categories was processed. I wasn't a fan of how this behaved, however. The first load of the page was empty, but the second load came through with a list of categories.To make the first load of the categories index page nicer, I've gotten rid of the try...catch block and instead changed it over to be server-rendered. That gets it, and its database connection, out of the build path; and it makes sure that its database-loaded info (how many apps are within each category) are always up-to-date.
(End update)
These changes makes Cal.com more compatible with typical Docker-based workflows that do not expect external services to be available at build time. This includes Docker-based hosting providers, such as Cloudron (#3026).
I have also added a GitHub Action to test this, which is the same as the
Production build
GitHub action but without database credentials. I've not been able to test this locally of course, so hopefully this PR will kick that off and prove whether or not it works.Solves #3026 and #6780
/claim #3026
Environment: Staging(main branch)
Type of change
How should this be tested?
Build Cal.com locally, without a database being available
yarn start
with no issuesBuild Cal.com locally, with a database being available
yarn start
with no issuesRun via
yarn dx
with no issuesUsing a modified calcom/docker, build the Dockerfile without a database connection
Deploy the built image to a hosted Cloudron instanceCloudron doesn't seem quite happy taking an existing Docker image and running it directly. It appears they prefer their own intermediary Docker runtime, usually built atop cloudron:base, with bespoke scripts to map their Postgres credentials (CLOUDRON_POSTGRESQL_...) to however an application takes those credentials.
I'm therefore considering testing on Cloudron and related changes for calcom/docker out-of-scope for this issue. I don't think a full Cloudron package was expected from the reported issues, as others were attempting to build those packages themselves. The reported issue was the inability to run
yarn build
without a database, which this PR addresses.See the "Production build (without database)" Github Action work
Checklist
Create associated PR against calcom/docker(out-of-scope)Finish testing against Cloudron(out-of-scope)