Skip to content
Open
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
31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "Cal.diy",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",

// Override DATABASE_URL/REDIS_URL to use the Docker service names.
// These take precedence over .env, so no need to edit that file for the DB connection.
"remoteEnv": {
"DATABASE_URL": "postgresql://postgres:postgres@database:5432/calendso",
"DATABASE_DIRECT_URL": "postgresql://postgres:postgres@database:5432/calendso",
"REDIS_URL": "redis://redis:6379"
},

// On first container start: copy .env.example → .env only when .env is absent, then always install deps
// HUSKY=0 skips git hook installation, which fails in container environments
"postCreateCommand": "[ -f .env ] || cp .env.example .env; HUSKY=0 yarn install",

// Forward the web app port to the host
"forwardPorts": [3000],

"customizations": {
"vscode": {
"extensions": [
"biomejs.biome",
"bradlc.vscode-tailwindcss",
"prisma.prisma"
]
}
}
}
37 changes: 37 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Dev container services - PostgreSQL and Redis for local development.
# The app itself runs in the devcontainer, not here.
services:
app:
image: mcr.microsoft.com/devcontainers/javascript-node:1-20-bookworm
volumes:
- ..:/workspace:cached
command: sleep infinity
depends_on:
- database
- redis

database:
image: postgres:15-alpine
restart: unless-stopped
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: calendso
ports:
# Expose on 5450 to match DATABASE_URL in .env.example
- "5450:5432"
volumes:
- postgres-data:/var/lib/postgresql/data

redis:
image: redis:7-alpine
restart: unless-stopped
ports:
# Expose on 6379 to allow host access with redis-cli or GUI tools
- "6379:6379"
volumes:
- redis-data:/data

volumes:
postgres-data:
redis-data:
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
# ***********************************************************************************************************

# - DATABASE ************************************************************************************************
DATABASE_URL="postgresql://postgres:@localhost:5450/calendso"
DATABASE_URL="postgresql://postgres:postgres@localhost:5450/calendso"
# Needed to run migrations while using a connection pooler like PgBouncer
# Use the same one as DATABASE_URL if you're not using a connection pooler
DATABASE_DIRECT_URL="postgresql://postgres:@localhost:5450/calendso"
DATABASE_DIRECT_URL="postgresql://postgres:postgres@localhost:5450/calendso"
INSIGHTS_DATABASE_URL=

# ***********************************************************************************************************
Expand All @@ -32,7 +32,7 @@ NEXT_PUBLIC_EMBED_LIB_URL='http://localhost:3000/embed/embed.js'

# To enable SAML login, set both these variables
# @see https://github.com/calcom/cal.diy/tree/main/packages/features/ee#setting-up-saml-login
# SAML_DATABASE_URL="postgresql://postgres:@localhost:5450/cal-saml"
# SAML_DATABASE_URL="postgresql://postgres:postgres@localhost:5450/cal-saml"
SAML_DATABASE_URL=
# SAML_ADMINS='pro@example.com'
SAML_ADMINS=
Expand Down
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,46 @@ for Logger level to be set at info, for example.

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/calcom/cal.diy)

#### Dev Container setup

A Dev Container configuration is included so you can spin up a fully working development environment without installing PostgreSQL or Redis locally. It works with [VS Code Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) and [GitHub Codespaces](https://github.com/features/codespaces).

**Requirements:** [Docker](https://www.docker.com/get-started) and the [VS Code Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).

1. Open the project in VS Code and click **Reopen in Container** when prompted (or run `Dev Containers: Reopen in Container` from the Command Palette).

2. On first start, the container will automatically:
- Copy `.env.example` to `.env` (skipped if `.env` already exists)
- Run `yarn install`

3. Open `.env` and fill in the two required secrets:

```sh
# Generate NEXTAUTH_SECRET
openssl rand -base64 32

# Generate CALENDSO_ENCRYPTION_KEY (must be 32 bytes for AES256)
openssl rand -base64 24
```

> The `DATABASE_URL` and `REDIS_URL` are pre-configured by the Dev Container and do not need to be changed.

Comment thread
gfernandez-me marked this conversation as resolved.
4. Run database migrations:

```sh
yarn workspace @calcom/prisma db-migrate
```

5. Start the dev server:

```sh
yarn dev
```

6. Open [http://localhost:3000](http://localhost:3000).

> **Note:** PostgreSQL is exposed on host port `5450` (credentials: `postgres` / `postgres`) and Redis on `6379`, matching the defaults in `.env.example`. This lets you connect to the database with tools like TablePlus or psql from your host machine. The database URL for host access is `postgresql://postgres:postgres@localhost:5450/calendso`.

#### Manual setup

1. Configure environment variables in the `.env` file. Replace `<user>`, `<pass>`, `<db-host>`, and `<db-port>` with their applicable values
Expand Down
Loading