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

Added cal.com as template #2119

Open
wants to merge 3 commits into
base: next
Choose a base branch
from
Open

Added cal.com as template #2119

wants to merge 3 commits into from

Conversation

kunumigab
Copy link
Contributor

Scheduling infrastructure for absolutely everyone.

Docker-Compose instructions used here: https://github.com/calcom/docker

Scheduling infrastructure for absolutely everyone.

Docker-Compose instructions used here: https://github.com/calcom/docker
@RayBB
Copy link
Contributor

RayBB commented May 2, 2024

@kunumigab
Not a maintainer but two small bits of feedback based on what I've seen in this repo:

  1. Usually the app service goes before the database service in the compose file (probably just so it's higher up when you edit variables)
  2. Usually template files end with a newline

Unfortunately, I can't test this right now since my main server is ARM.

@RayBB
Copy link
Contributor

RayBB commented May 13, 2024

@andrasbacsai any chance you could review this PR this week?
@kunumigab

@SamAmann
Copy link

@kunumigab

Love, the idea, could really use the template!

I've tried your file, but encountered some hiccups.

What I've done

I've used your docker compose file to install Cal on a coolify instance using the wildcard domain <domain.com>.
My coolify instance is accessible in https://coolify.<domain.com>.
The instance is used to deploy a Next.js web app that is successfully working on https://app.<domain.com>
This is relevant as my issues are related to the proxy not delivering the cert for my Cal instance.
So the proxy IS working correctly in other usage of my coolify instance.

The docker compose ressource is installed on the same 'localhost' server than my coolify instance.

I've tried both to set a custom url for the 'Calcom' service (https://cal.<domain.com>) or to leave it empty (trying to reach it with IP address).

The services are successfully spinning on start up, even if the Calcom service is flagged as 'unhealthy'.

Here are the deployement logs:

Saved configuration files to /data/coolify/services/bskokk8.
Creating Docker network.
Starting service.
Pulling images.
 postgres Pulling 
 calcom Pulling 
 postgres Pulled 
 calcom Pulled 
Starting containers.
 Container postgres-bskokk8  Creating
 Container postgres-bskokk8  Created
 Container calcom-bskokk8  Creating
 Container calcom-bskokk8  Created
 Container postgres-bskokk8  Starting
 Container postgres-bskokk8  Started
 Container calcom-bskokk8  Starting
 Container calcom-bskokk8  Started

My faced issues

Calcom service logs

I have issues with the prismaClient, something to do with the base user table not being properly created?
This error repeat itself every few seconds.

2024-05-31T13:28:37.521481964Z @calcom/web:start: 13:28:37:520	ERROR[redactError] Error:  {"name":"PrismaClientKnownRequestError","code":"P2021","clientVersion":"5.4.2","meta":{"table":"public.Feature"}}
2024-05-31T13:28:37.530654313Z @calcom/web:start: PrismaClientKnownRequestError: 
2024-05-31T13:28:37.530676055Z @calcom/web:start: Invalid `prisma.user.count()` invocation:
2024-05-31T13:28:37.530685713Z @calcom/web:start: 
2024-05-31T13:28:37.530693218Z @calcom/web:start: 
2024-05-31T13:28:37.530699580Z @calcom/web:start: The table `public.users` does not exist in the current database.
2024-05-31T13:28:37.530708577Z @calcom/web:start:     at Cn.handleRequestError (/calcom/node_modules/@prisma/client/runtime/library.js:123:6817)
2024-05-31T13:28:37.530717594Z @calcom/web:start:     at Cn.handleAndLogRequestError (/calcom/node_modules/@prisma/client/runtime/library.js:123:6206)
2024-05-31T13:28:37.530726402Z @calcom/web:start:     at Cn.request (/calcom/node_modules/@prisma/client/runtime/library.js:123:5926)
2024-05-31T13:28:37.530734707Z @calcom/web:start:     at async l (/calcom/node_modules/@prisma/client/runtime/library.js:128:9968)
2024-05-31T13:28:37.530743194Z @calcom/web:start:     at async getServerSideProps (/calcom/apps/web/.next/server/pages/auth/login.js:1:11918) {
2024-05-31T13:28:37.530751269Z @calcom/web:start:   code: 'P2021',
2024-05-31T13:28:37.530758384Z @calcom/web:start:   clientVersion: '5.4.2',
2024-05-31T13:28:37.530766269Z @calcom/web:start:   meta: { table: 'public.users' }
2024-05-31T13:28:37.530771628Z @calcom/web:start: }

Calcom service target URL

I've tried both to leave empty the domain or to fill it with a subdomain, and both have the same result: No cert is created.
I've checked the proxy logs, nothing comes from there (I mean really nothing, no error logs, no success, it seems that it does not even try to obtain a cert).
Result is, even if the service is running (but flagged as 'unhealthy' though), it is impossible to reach the URL, as browser blocks the connexion due to unsecured address. It's not a 404 error, it's just not secured so browser won't connect to it.

Same as @RayBB, I'm no maintainers or nothing to the project.
I've just had the occasion to test out the docker compose file, so I did 😄

After some time on the Discord, (thanks a lot again @iamEvanYT for your time and explanations!), we couldn't find any workaround so I figure here maybe someone has one, or it can help improve the template.

Hope this helps,

@dylancetin
Copy link

Hey i have just solved this issue. I will also help you with the next issue you will be facing :)

I really have no idea why this is the case. I found the scripts from https://github.com/calcom/docker/blob/main/scripts/start.sh that is run during build.

npx prisma migrate deploy --schema /calcom/packages/prisma/schema.prisma

I have run this from command line that is present in coolify dashboard. It gave me the error that DATABASE_DIRECT_URL is not set. Eventhough read me from calcom docker repo says it is optional. I think in this case it is required.

You need to add the following to the docker compose as well for the calcom.

     - 'DATABASE_DIRECT_URL=postgres://${SERVICE_USER_POSTGRES}:${SERVICE_PASSWORD_POSTGRES}@postgres:5432/${POSTGRES_DATABASE:-calcom}'

Then after you create a admin account. You will not be able to get admin privileges, because you can't set a 2fa.

This problem is because of these lines:
- 'NEXTAUTH_SECRET=${SERVICE_BASE64_64_SECRET}' - 'CALENDSO_ENCRYPTION_KEY=${SERVICE_BASE64_64_SECRET}'

If you inspect console logs it will say "ERR_CRYPTO_INVALID_KEYLEN". Because CALENDSO_ENCRYPTION_KEY is too long for this. I have used the following command that i found in original calcom/cal example .env file.
dd if=/dev/urandom bs=1K count=1 | md5sum

When i set this new secret for CALENDSO_ENCRYPTION_KEY. Everything seems to be working fine. I am trying to set my instance up. If i face anything i will let you know.

@dylancetin
Copy link

@SamAmann @kunumigab sorry forgot to mention you guys :)

@kunumigab
Copy link
Contributor Author

kunumigab commented Jun 1, 2024

Hey i have just solved this issue. I will also help you with the next issue you will be facing :)

I really have no idea why this is the case. I found the scripts from https://github.com/calcom/docker/blob/main/scripts/start.sh that is run during build.

npx prisma migrate deploy --schema /calcom/packages/prisma/schema.prisma

I have run this from command line that is present in coolify dashboard. It gave me the error that DATABASE_DIRECT_URL is not set. Eventhough read me from calcom docker repo says it is optional. I think in this case it is required.

You need to add the following to the docker compose as well for the calcom.

     - 'DATABASE_DIRECT_URL=postgres://${SERVICE_USER_POSTGRES}:${SERVICE_PASSWORD_POSTGRES}@postgres:5432/${POSTGRES_DATABASE:-calcom}'

Then after you create a admin account. You will not be able to get admin privileges, because you can't set a 2fa.

This problem is because of these lines: - 'NEXTAUTH_SECRET=${SERVICE_BASE64_64_SECRET}' - 'CALENDSO_ENCRYPTION_KEY=${SERVICE_BASE64_64_SECRET}'

If you inspect console logs it will say "ERR_CRYPTO_INVALID_KEYLEN". Because CALENDSO_ENCRYPTION_KEY is too long for this. I have used the following command that i found in original calcom/cal example .env file. dd if=/dev/urandom bs=1K count=1 | md5sum

When i set this new secret for CALENDSO_ENCRYPTION_KEY. Everything seems to be working fine. I am trying to set my instance up. If i face anything i will let you know.

Hey!, Can you test this again?, I don't have a x86 server right now

@SamAmann
Copy link

SamAmann commented Jun 3, 2024

Hey i have just solved this issue. I will also help you with the next issue you will be facing :)

I really have no idea why this is the case. I found the scripts from https://github.com/calcom/docker/blob/main/scripts/start.sh that is run during build.

npx prisma migrate deploy --schema /calcom/packages/prisma/schema.prisma

I have run this from command line that is present in coolify dashboard. It gave me the error that DATABASE_DIRECT_URL is not set. Eventhough read me from calcom docker repo says it is optional. I think in this case it is required.

You need to add the following to the docker compose as well for the calcom.

     - 'DATABASE_DIRECT_URL=postgres://${SERVICE_USER_POSTGRES}:${SERVICE_PASSWORD_POSTGRES}@postgres:5432/${POSTGRES_DATABASE:-calcom}'

Then after you create a admin account. You will not be able to get admin privileges, because you can't set a 2fa.

This problem is because of these lines: - 'NEXTAUTH_SECRET=${SERVICE_BASE64_64_SECRET}' - 'CALENDSO_ENCRYPTION_KEY=${SERVICE_BASE64_64_SECRET}'

If you inspect console logs it will say "ERR_CRYPTO_INVALID_KEYLEN". Because CALENDSO_ENCRYPTION_KEY is too long for this. I have used the following command that i found in original calcom/cal example .env file. dd if=/dev/urandom bs=1K count=1 | md5sum

When i set this new secret for CALENDSO_ENCRYPTION_KEY. Everything seems to be working fine. I am trying to set my instance up. If i face anything i will let you know.

Nice job @dylancetin!

I've tested it in 2 different condition:

  • on my localhost server (so where the coolify instance is running)
  • on a separate VPS, integrated with my coolify instance

TEST RESULT

With your fix to the docker compose, both containers are now running and tagged as 'healthy', so I guess it fixes it.

EDIT! After few tries, the container is back to a 'unhealthy' status...

Here are the logs of the container, it seems there is lots of progress, as it started to install apps and run the next.js script to start.

2024-06-03T07:56:28.933614367Z 📲 Updated app: 'caldav-calendar'
2024-06-03T07:56:28.935392703Z 📲 Created app: 'campfire'
2024-06-03T07:56:28.937010190Z 📲 Created app: 'clic'
2024-06-03T07:56:28.938800280Z 📲 Created app: 'closecom'
2024-06-03T07:56:28.940371486Z 📲 Created app: 'cron'
2024-06-03T07:56:28.942962814Z 📲 Updated app: 'daily-video'
2024-06-03T07:56:28.944725430Z 📲 Created app: 'deel'
2024-06-03T07:56:28.947808900Z 📲 Created app: 'demodesk'
2024-06-03T07:56:28.949396088Z 📲 Created app: 'discord'
2024-06-03T07:56:28.951067227Z 📲 Created app: 'eightxeight'
2024-06-03T07:56:28.952738377Z 📲 Created app: 'element-call'
2024-06-03T07:56:28.955017622Z 📲 Created app: 'exchange2013-calendar'
2024-06-03T07:56:28.956667791Z 📲 Created app: 'exchange2016-calendar'
2024-06-03T07:56:28.958254317Z 📲 Created app: 'exchange'
2024-06-03T07:56:28.959808000Z 📲 Created app: 'facetime'
2024-06-03T07:56:28.961377774Z 📲 Created app: 'fathom'
2024-06-03T07:56:28.970730390Z 📲 Created app: 'feishu-calendar'
2024-06-03T07:56:28.972369878Z 📲 Created app: 'ga4'
2024-06-03T07:56:28.973832805Z 📲 Created app: 'giphy'
2024-06-03T07:56:28.975318707Z 📲 Created app: 'google-calendar'
2024-06-03T07:56:28.976828455Z 📲 Created app: 'google-meet'
2024-06-03T07:56:28.978349033Z 📲 Created app: 'gtm'
2024-06-03T07:56:28.979987711Z 📲 Created app: 'hubspot'
2024-06-03T07:56:28.982392448Z 📲 Updated app: 'huddle01'
2024-06-03T07:56:28.983951881Z 📲 Created app: 'ics-feed'
2024-06-03T07:56:28.985397305Z 📲 Created app: 'intercom'
2024-06-03T07:56:28.987035341Z 📲 Created app: 'jelly'
2024-06-03T07:56:28.989758053Z 📲 Updated app: 'jitsi'
2024-06-03T07:56:28.991545347Z 📲 Created app: 'lark-calendar'
2024-06-03T07:56:28.993202450Z 📲 Created app: 'linear'
2024-06-03T07:56:28.995908600Z 📲 Updated app: 'make'
2024-06-03T07:56:28.997403129Z 📲 Created app: 'matomo'
2024-06-03T07:56:28.998962392Z 📲 Created app: 'metapixel'
2024-06-03T07:56:29.000491467Z 📲 Created app: 'mirotalk'
2024-06-03T07:56:29.002039368Z 📲 Created app: 'mock-payment-app'
2024-06-03T07:56:29.003597851Z 📲 Created app: 'n8n'
2024-06-03T07:56:29.005067101Z 📲 Created app: 'office365-calendar'
2024-06-03T07:56:29.006620242Z 📲 Created app: 'msteams'
2024-06-03T07:56:29.008464206Z 📲 Created app: 'paypal'
2024-06-03T07:56:29.010142209Z 📲 Created app: 'ping'
2024-06-03T07:56:29.012010360Z 📲 Created app: 'pipedream'
2024-06-03T07:56:29.013826900Z 📲 Created app: 'pipedrive-crm'
2024-06-03T07:56:29.015714267Z 📲 Created app: 'plausible'
2024-06-03T07:56:29.017345660Z 📲 Created app: 'posthog'
2024-06-03T07:56:29.019181327Z 📲 Created app: 'qr_code'
2024-06-03T07:56:29.020883097Z 📲 Created app: 'raycast'
2024-06-03T07:56:29.022599654Z 📲 Created app: 'riverside'
2024-06-03T07:56:29.024363153Z 📲 Created app: 'roam'
2024-06-03T07:56:29.026076354Z 📲 Created app: 'routing-forms'
2024-06-03T07:56:29.027787281Z 📲 Created app: 'salesforce'
2024-06-03T07:56:29.029597699Z 📲 Created app: 'salesroom'
2024-06-03T07:56:29.031266505Z 📲 Created app: 'sendgrid'
2024-06-03T07:56:29.032925782Z 📲 Created app: 'shimmervideo'
2024-06-03T07:56:29.034613473Z 📲 Created app: 'signal'
2024-06-03T07:56:29.036340711Z 📲 Created app: 'sirius_video'
2024-06-03T07:56:29.037972104Z 📲 Created app: 'stripe'
2024-06-03T07:56:29.039754980Z 📲 Created app: 'sylapsvideo'
2024-06-03T07:56:29.041375091Z 📲 Created app: 'tandem'
2024-06-03T07:56:29.043172084Z 📲 Created app: 'telegram'
2024-06-03T07:56:29.044861690Z 📲 Created app: 'typeform'
2024-06-03T07:56:29.046524593Z 📲 Created app: 'vimcal'
2024-06-03T07:56:29.048406520Z 📲 Created app: 'vital-automation'
2024-06-03T07:56:29.050174567Z 📲 Created app: 'weather_in_your_calendar'
2024-06-03T07:56:29.052081964Z 📲 Created app: 'webex'
2024-06-03T07:56:29.054021742Z 📲 Created app: 'whatsapp'
2024-06-03T07:56:29.055930251Z 📲 Created app: 'whereby'
2024-06-03T07:56:29.058496751Z 📲 Updated app: 'wipe-my-cal'
2024-06-03T07:56:29.060329994Z 📲 Created app: 'wordpress'
2024-06-03T07:56:29.062028897Z 📲 Created app: 'zapier'
2024-06-03T07:56:29.063714195Z 📲 Created app: 'zoho-bigin'
2024-06-03T07:56:29.065379022Z 📲 Created app: 'zohocalendar'
2024-06-03T07:56:29.067213618Z 📲 Created app: 'zohocrm'
2024-06-03T07:56:29.068942338Z 📲 Created app: 'zoom'
2024-06-03T07:56:29.075305948Z Skipping Routing Form - Seeding - Pro User not found
2024-06-03T07:56:29.116344561Z + yarn start
2024-06-03T07:56:34.131867641Z • Packages in scope: @calcom/web
2024-06-03T07:56:34.131901236Z • Running start in 1 packages
2024-06-03T07:56:34.131910704Z • Remote caching disabled
2024-06-03T07:56:34.133341809Z @calcom/web:start: cache bypass, force executing bfd29c939d824065
2024-06-03T07:56:35.735355314Z @calcom/web:start: warn  EMAIL_FROM environment variable is not set, this may indicate mailing is currently disabled. Please refer to the .env.example file.
2024-06-03T07:56:35.735586972Z @calcom/web:start: Please set NEXT_PUBLIC_API_V2_URL
2024-06-03T07:56:35.736621079Z @calcom/web:start: Duplicate value found in common.json keys:   seats_available_other and seats_available_one
2024-06-03T07:56:35.736987158Z @calcom/web:start: Duplicate value found in common.json keys:   location_variable and location
2024-06-03T07:56:35.737220198Z @calcom/web:start: Duplicate value found in common.json keys:   additional_notes_variable and additional_notes
2024-06-03T07:56:35.737446556Z @calcom/web:start: Duplicate value found in common.json keys:   already_have_account and already_have_an_account
2024-06-03T07:56:35.737649818Z @calcom/web:start: Duplicate value found in common.json keys:   timezone_variable and timezone
2024-06-03T07:56:35.737966790Z @calcom/web:start: Duplicate value found in common.json keys:   scheduling_for_your_team and workflow_automation
2024-06-03T07:56:35.738087233Z @calcom/web:start: Duplicate value found in common.json keys:   saml_sso and saml_config
2024-06-03T07:56:35.738203458Z @calcom/web:start: Duplicate value found in common.json keys:   advanced_managed_events_description and unified_billing_description
2024-06-03T07:56:35.738436668Z @calcom/web:start: Duplicate value found in common.json keys:   org_admin_no_slots|heading and org_admin_no_slots|subject
2024-06-03T07:56:35.738510331Z @calcom/web:start: Duplicate value found in common.json keys:   email_team_invite|subject|invited_to_subteam and user_invited_you_to_subteam
2024-06-03T07:56:35.738580256Z @calcom/web:start: Duplicate value found in common.json keys:   email_team_invite|heading|invited_to_regular_team and email_no_user_invite_heading_team
2024-06-03T07:56:35.738639762Z @calcom/web:start: Duplicate value found in common.json keys:   email_team_invite|content|invited_to_regular_team and email_user_invite_subheading_team
2024-06-03T07:56:35.738839717Z @calcom/web:start: Duplicate value found in common.json keys:   create_an_out_of_office and ooo_create_entry_modal
2024-06-03T07:56:35.910396768Z @calcom/web:start:   ▲ Next.js 13.5.5
2024-06-03T07:56:35.910427688Z @calcom/web:start:   - Local:        http://localhost:3000
2024-06-03T07:56:35.910559513Z @calcom/web:start: 
2024-06-03T07:56:35.910644286Z @calcom/web:start:  ✓ Ready in 763ms
2024-06-03T07:56:56.489665789Z @calcom/web:start: Warning: data for page "/auth/setup" is 156 kB which exceeds the threshold of 128 kB, this amount of data can reduce performance.
2024-06-03T07:56:56.489688343Z @calcom/web:start: See more info here: https://nextjs.org/docs/messages/large-page-data

Still some troubles with env var like NEXT_PUBLIC_API_V2_URL & EMAIL_FROM but I don't think this are related to current issues (first one might help with auth as it is the NEXTAUTH way of setting routes)

Unfortunately, I still can't manage to reach it, still having problem obtaining the cert for that docker when using a custom subdomain.

On my extra server, can't even reach raw IP of server and gives me either 404 or too long request.

But I think we're on the good track here :)

@dylancetin
Copy link

https://github.com/calcom/docker does have NEXT_PUBLIC_API_V2_URL as an important env variable. I will be guessing that warning from log is unnecessary. But it is set on the .env.example. (I don't have this set, and my instance runs perfectly. My guess will be this is part of the enterprise API. If you need that you probably should set this.)

# api v2
NEXT_PUBLIC_API_V2_URL="http://localhost:5555/api/v2"

https://github.com/calcom/docker?tab=readme-ov-file#client_fetch_error [next-auth][error][CLIENT_FETCH_ERROR]
You might have the problem here. On my current configuration, "NEXTAUTH_URL" is set to "http://localhost:3000/api/auth".

I think email is kinda "optional", but on most instances is used. I have used resend because i find it easiest to set. We might want to add these to the template. @kunumigab what do you say? For mail i have the following variables.

      - EMAIL_SERVER_HOST=smtp.resend.com
      - EMAIL_SERVER_PORT=587
      - EMAIL_SERVER_USER=resend
      - EMAIL_SERVER_PASSWORD=${RESEND_SECRET_KEY}
      - EMAIL_FROM=${EMAIL_ADRESS} // info@mydomain

@SamAmann please check the log with a bigger number of lines like "10000". If you have the CLIENT_FETCH_ERROR do the NEXTAUTH_URL patch. And on first 10 lines there needs to be successful database migrations. Then you might need to set DATABASE_DIRECT_URL.

@kunumigab
Copy link
Contributor Author

kunumigab commented Jun 3, 2024

Added hostname and mail variables, again need testing

Edit: Healthcheck was added too, so the unhealthy status could be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants