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

Significant Refactor #147

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions .env.example

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/update-submodules.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# .env file
.env
.env
docker-compose.override.yml
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

59 changes: 11 additions & 48 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,11 @@
FROM node:16 as builder

WORKDIR /calcom
ARG NEXT_PUBLIC_WEBAPP_URL=http://localhost:3000
ARG NEXT_PUBLIC_APP_URL
ARG NEXT_PUBLIC_LICENSE_CONSENT
ARG CALCOM_TELEMETRY_DISABLED
ARG DATABASE_URL
ARG NEXTAUTH_SECRET=secret
ARG CALENDSO_ENCRYPTION_KEY=secret
ARG MAX_OLD_SPACE_SIZE=4096

ENV NEXT_PUBLIC_WEBAPP_URL=$NEXT_PUBLIC_WEBAPP_URL \
NEXT_PUBLIC_APP_URL=$NEXT_PUBLIC_APP_URL \
NEXT_PUBLIC_LICENSE_CONSENT=$NEXT_PUBLIC_LICENSE_CONSENT \
CALCOM_TELEMETRY_DISABLED=$CALCOM_TELEMETRY_DISABLED \
DATABASE_URL=$DATABASE_URL \
NEXTAUTH_SECRET=${NEXTAUTH_SECRET} \
CALENDSO_ENCRYPTION_KEY=${CALENDSO_ENCRYPTION_KEY} \
NODE_OPTIONS=--max-old-space-size=${MAX_OLD_SPACE_SIZE}

COPY calcom/package.json calcom/yarn.lock calcom/turbo.json ./
COPY calcom/apps/web ./apps/web
COPY calcom/packages ./packages

RUN yarn install --frozen-lockfile

RUN yarn build

FROM node:16 as runner

WORKDIR /calcom
ENV NODE_ENV production

RUN apt-get update && \
apt-get -y install netcat && \
rm -rf /var/lib/apt/lists/* && \
npm install --global prisma

COPY calcom/package.json calcom/yarn.lock calcom/turbo.json ./
COPY --from=builder /calcom/node_modules ./node_modules
COPY --from=builder /calcom/packages ./packages
COPY --from=builder /calcom/apps/web ./apps/web
COPY --from=builder /calcom/packages/prisma/schema.prisma ./prisma/schema.prisma
COPY scripts scripts

EXPOSE 3000
CMD ["/calcom/scripts/start.sh"]
FROM node:16

COPY scripts /opt/scripts
RUN apt-get update && \
apt-get -y install netcat && \
rm -rf /var/lib/apt/lists/* && \
npm install --location=global prisma && \
ln -s /opt/scripts/start.sh /opt/scripts/wait-for-it.sh /usr/bin/

EXPOSE 3000
CMD ["start.sh"]
139 changes: 77 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,98 +26,125 @@ For Production, for the time being, please checkout the repository and build/pus

## Requirements

Make sure you have `docker` & `docker compose` installed on the server / system. Both are installed by most docker utilities, including Docker Desktop and Rancher Desktop.
Make sure you have `docker` & `docker-compose` installed on the server / system. Both are installed by most docker utilities, including Docker Desktop and Rancher Desktop.

Note: `docker compose` without the hyphen is now the primary method of using docker-compose, per the Docker documentation.

## Getting Started

1. Clone calcom-docker
1. wget docker-compose.yml to wherever you plan on running this.

```bash
git clone https://github.com/calcom/docker.git calcom-docker
wget https://raw.githubusercontent.com/calcom/docker/main/docker-compose.yml
```

2. Change into the directory
2. Modify the environment section at the top of the `docker-compose.yml` file.


```yaml
x-environment: &environment
environment:
# Set this value to 'agree' to accept our license:
# LICENSE: https://github.com/calendso/calendso/blob/main/LICENSE
#
# Summary of terms:
# - The codebase has to stay open source, whether it was modified or not
# - You can not repackage or sell the codebase
# - Acquire a commercial license to remove these terms by emailing: [email protected]
## You must agree to these terms manually we can't agree to them for you.
# NEXT_PUBLIC_LICENSE_CONSENT:
# LICENSE:

## Deployment configuration section you may need to change this if you're using a reverse proxy such as nginx, haproxy or træfik.
NEXT_PUBLIC_WEBAPP_URL: http://localhost:3000

# E-mail settings
# Configures the global From: header whilst sending emails.
EMAIL_FROM: [email protected]

# Configure SMTP settings (@see https://nodemailer.com/smtp/).
EMAIL_SERVER_HOST: smtp.example.com
EMAIL_SERVER_PORT: 587
EMAIL_SERVER_USER: email_user
EMAIL_SERVER_PASSWORD: email_password

## Only change these if you know what you're doing. Changes are unlikely to be needed.
## However, you could change the password if you like before you start the first time. Also feel free to read about and implement Docker Secrets.
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
DATABASE_HOST: postgres:5432
DATABASE_URL: ${DATABASE_URL:='postgresql://postgres:postgres@postgres:5432/postgres'}
# GOOGLE_API_CREDENTIALS: {}

# Set this to '1' if you don't want Cal to collect anonymous usage. This is not necessary, however, its kind to give back metrics to the app developers if you trust them.
CALCOM_TELEMETRY_DISABLED: 0

# Used for the Office 365 / Outlook.com Calendar integration.
# MS_GRAPH_CLIENT_ID:
# MS_GRAPH_CLIENT_SECRET:

# Used for the Zoom integration.
# ZOOM_CLIENT_ID:
# ZOOM_CLIENT_SECRET:

## Probably only change this if you know what you're doing.
NODE_ENV: production
```

3. Start Cal.com via docker-compose

```bash
cd calcom-docker
```

3. Update the calcom submodule.
(Most basic users, and for First Run) To run the complete stack, which includes a local Postgres database, Cal.com web app, and Prisma Studio:

```bash
git submodule update --remote --init
docker-compose up -d
```

Note: DO NOT use recursive submodule update, otherwise you will receive a git authentication error.

4. Rename `.env.example` to `.env` and then update `.env`

5. Build the Cal.com docker image:

Note: Due to application configuration requirements, an available database is currently required during the build process.

a) If hosting elsewhere, configure the `DATABASE_URL` in the .env file, and skip the next step

b) If a local or temporary database is required, start a local database via docker compose.

...and if you wish to follow the logs you may run...
```bash
docker compose up -d database
docker-compose logs -f
```
and press `ctrl+c` to end following the console logging output.

6. Build Cal.com via docker compose (DOCKER_BUILDKIT=0 must be provided to allow a network bridge to be used at build time. This requirement will be removed in the future)

```bash
DOCKER_BUILDKIT=0 docker compose build calcom
```
8. (First Run) Open a browser to [http://localhost:5555](http://localhost:5555) to look at or modify the database content.

7. Start Cal.com via docker compose
a. Click on the `User` model to add a new user record.

(Most basic users, and for First Run) To run the complete stack, which includes a local Postgres database, Cal.com web app, and Prisma Studio:
b. Fill out the fields (remembering to encrypt your password with [BCrypt](https://bcrypt-generator.com/)) and click `Save 1 Record` to create your first user.

```bash
docker compose up -d
```
9. Open a browser to [http://localhost:3000](http://localhost:3000) (or your appropriately configured NEXT_PUBLIC_WEBAPP_URL) and login with your just created, first user.

To run Cal.com web app and Prisma Studio against a remote database, ensure that DATABASE_URL is configured for an available database and run:
### Bonus tips
To run Cal.com web app and Prisma Studio against a remote database, ensure that DATABASE_URL is configured for an available database, uncomment the studio segment of the included `docker-compose.yml` and run:

```bash
docker compose up -d calcom studio
docker-compose up -d calcom studio
```

To run only the Cal.com web app, ensure that DATABASE_URL is configured for an available database and run:

```bash
docker compose up -d calcom
docker-compose up -d calcom
```

**Note: to run in attached mode for debugging, remove `-d` from your desired run command.**

8. (First Run) Open a browser to [http://localhost:5555](http://localhost:5555) to look at or modify the database content.

a. Click on the `User` model to add a new user record.

b. Fill out the fields (remembering to encrypt your password with [BCrypt](https://bcrypt-generator.com/)) and click `Save 1 Record` to create your first user.

9. Open a browser to [http://localhost:3000](http://localhost:3000) (or your appropriately configured NEXT_PUBLIC_WEBAPP_URL) and login with your just created, first user.

## Configuration

### Build-time variables

These variables must be provided at the time of the docker build, and can be provided by updating the .env file. Currently, if you require changes to these variables, you must follow the instructions to build and publish your own image.
These variables must be provided at the time of the docker build, and can be provided by updating the .env file. Currently, if you require changes to these variables, you must follow the instructions to build and publish your own image.

Updating these variables is not required for evaluation, but is required for running in production. Instructions for generating variables can be found in the [cal.com instructions](https://github.com/calcom/cal.com)
Updating these variables is not required for evaluation, but is required for running in production. Instructions for generating variables can be found in the [cal.com instructions](https://github.com/calcom/cal.com)

| Variable | Description | Required | Default |
| --- | --- | --- | --- |
| NEXT_PUBLIC_WEBAPP_URL | Base URL injected into static files | required | `http://localhost:3000` |
| NEXT_PUBLIC_LICENSE_CONSENT | license consent - true/false | | |
| CALCOM_TELEMETRY_DISABLED | Allow cal.com to collect anonymous usage data (set to `1` to disable) | | |
| DATABASE_URL | database url with credentials | required | `postgresql://unicorn_user:magical_password@database:5432/calendso` |
| NEXTAUTH_SECRET | Cookie encryption key | required | `secret` |
| CALENDSO_ENCRYPTION_KEY | Authentication encryption key | required | `secret` |
| NEXTAUTH_SECRET | Cookie encryption key | required | `randomly defined on first boot` |
| CALENDSO_ENCRYPTION_KEY | Authentication encryption key | required | `randomly defined on first boot` |

### Important Run-time variables

Expand All @@ -126,22 +153,10 @@ These variables must also be provided at runtime
| Variable | Description | Required | Default |
| --- | --- | --- | --- |
| CALCOM_LICENSE_KEY | Enterprise License Key | | |
| NEXTAUTH_SECRET | must match build variable | required | `secret` |
| CALENDSO_ENCRYPTION_KEY | must match build variable | required | `secret` |
| NEXTAUTH_SECRET | must match build variable | required | `randomly defined on first boot` |
| CALENDSO_ENCRYPTION_KEY | must match build variable | required | `randomly defined on first boot` |
| DATABASE_URL | database url with credentials | required | `postgresql://unicorn_user:magical_password@database:5432/calendso` |

## Git Submodules

This repository uses a git submodule.

To update the calcom submodule, use the following command:

```bash
git submodule update --remote --init
```

For more advanced usage, please refer to the git documentation: [https://git-scm.com/book/en/v2/Git-Tools-Submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules)

## Troubleshooting

* SSL edge termination: If running behind a load balancer which handles SSL certificates, you will need to add the environmental variable `NODE_TLS_REJECT_UNAUTHORIZED=0` to prevent requests from being rejected. Only do this if you know what you are doing and trust the services/load-balancers directing traffic to your service.
Expand Down
1 change: 0 additions & 1 deletion calcom
Submodule calcom deleted from 6b0ac9
Loading